Skip to content

Commit

Permalink
Fixed Bug with wrong wall jumps and optimized trail color detection/a…
Browse files Browse the repository at this point in the history
…ppliment
  • Loading branch information
1mi0 committed Sep 1, 2019
1 parent 5ed4951 commit e4217f9
Show file tree
Hide file tree
Showing 6 changed files with 389 additions and 62 deletions.
8 changes: 6 additions & 2 deletions catchmod_main.sma
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ public OnPlayerThink(id)
}

// Wall Touch
if (get_entvar(id, var_flags) & FL_ONGROUND && g_iWallTouches[id] != get_pcvar_num(g_iCvarTouches))
{
g_iWallTouches[id] = get_pcvar_num(g_iCvarTouches)
}

if (g_bJump[id])
{
Expand Down Expand Up @@ -604,7 +608,7 @@ public SpeedEntityThink()
fSpeed = vector_length(fVelocity)
f2dmSpeed = floatsqroot(fVelocity[0] * fVelocity[0] + fVelocity[1] * fVelocity[1])

set_hudmessage(255, 255, 255, -1.0, 0.7, 0, 0.0, 0.2, 0.01, 0.0)
set_hudmessage(255, 0, 0, -1.0, 0.7, 0, 0.0, 0.2, 0.01, 0.0)
ShowSyncHudMsg(i, g_iHud[HudSpeedEnt][HudSync], "%3.2f units/second^n%3.2f velocity", fSpeed, f2dmSpeed)
}

Expand Down Expand Up @@ -660,7 +664,7 @@ public OnPlayerSpawn(id)

g_fPlayerSpeed[id] = get_pcvar_float(g_iCvarSpeed)

UpdateHud(id)
set_entvar(g_iHud[HudStatusEnt][TaskEntity], var_nextthink, get_gametime() + 0.5)
}

// Stopping some functions
Expand Down
158 changes: 158 additions & 0 deletions catchmod_ranksystem.sma
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// Defaults
#include <amxmodx>
// #include <amxmisc>

// Modules
// #include <cstrike>
// #include <reapi>
// #include <engine>
// #include <fakemeta>
// #include <hamsandwich>
// #include <fun>
// #include <xs>
// #include <sqlx>

// 3rd Part
// Add your code here...

// mi0 utils
// #define UTIL_FADEEFFECT
// #define UTIL_HUDMESSAGE
// #define UTIL_CLIENTCMD
// #define UTIL_LICENSE 0
// #define UTIL_KUR print_chat

// #include <mi0_utils>

// Defines
// Main plugin Defines
#define PLUGIN "Catch Mod: Rank System"
#define VERSION CATCHMOD_VER
#define AUTHOR "mi0"

#define MAXPLAYERSVAR MAX_PLAYERS + 1

// Enums
enum CfgSections
{
SectionNone,
SectionSettings,
SectionLevels
}

enum _:LevelInfo
{
LevelName[64],
LevelColor[64],
LevelXP,
LevelInfo[64]
}

// Global Vars
new g_iPlayersXP[MAXPLAYERSVAR], g_iPlayerLevel[MAXPLAYERSVAR]
new g_iLevels, Array:g_aLevels

// Plugin forwards
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

// Add your code here...
}

public plugin_cfg()
{
g_aLevels = ArrayCreate(LevelInfo)
LoadCfg()
}

public plugin_end()
{
ArrayDestroy(g_aLevels)
}

// Cmds
// Add your code here...

// Ham/Reapi/Fm/Engine Forwards
// Add your code here...

// Custom Functions
LoadCfg()
{
new szFileDir[128]
get_configsdir(szFileDir, charsmax(szFileDir))
add(szFileDir, charsmax(szFileDir), "/RankConfig.ini")

new iFile = fopen(szFileDir, "rt")
if (iFile)
{
new szLine[256], CfgSections:iSection
new szKey[32], szValue[32]
new eTempArray[LevelInfo]

while (!feof(iFile))
{
fgets(iFile, szLine, charsmax(szLine))
trim(szLine)

if (szLine[0] == EOS || szLine[0] == '#' || szLine[0] == ';' || (szLine[0] == '/' && szLine[1] == '/'))
{
continue
}
else if (szLine[0] == '[')
{
switch (szLine[1])
{
case 'S':
{
iSection = SectionSettings
}

case 'L':
{
iSection = SectionLevels
}

default:
{
iSection = SectionNone
}
}

continue
}

switch (iSection)
{
case SectionSettings:
{
strtok(szLine, szKey, charsmax(szKey), szValue, charsmax(szValue), "=")
trim(szKey)
trim(szValue)


}

case SectionLevels:
{
parse(szLine, eTempArray[LevelName], charsmax(eTempArray[LevelName]),
eTempArray[LevelColor], charsmax(eTempArray[LevelColor]),
szValue, charsmax(szValue),
eTempArray[LevelInfo], charsmax(eTempArray[LevelInfo]))

eTempArray[LevelXP] = str_to_num(szValue)

ArrayPushArray(g_aLevels, eTempArray)
g_iLevels++
}
}
}
}
}

// Stocks
// Add your code here...

// Natives
// Add your code here...
115 changes: 55 additions & 60 deletions catchmod_trail.sma
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,8 @@
#include <reapi>
#include <catchmod>

//TODO:
/*
new sprite = get_pcvar_num(g_model)
message_begin(0, 23, 812, 0)
write_byte(17)
write_coord(g_lorigin[id][0])
write_coord(g_lorigin[id][1])
new var1
if (sprite)
{
var1 = g_offset[id][1]
}
else
{
var1 = g_offset[id][0]
}
write_coord(g_lorigin[id][2] - var1)
new var2
if (sprite)
{
var2 = g_fire
}
else
{
var2 = g_sprite
}
write_short(var2)
new var3
if (sprite)
{
var3 = g_size[1]
}
else
{
var3 = g_size[0]
}
write_byte(var3)
new var4
if (sprite)
{
var4 = g_brightness[1]
}
else
{
var4 = g_brightness[0]
}
write_byte(var4)
message_end()*/
#define TASKID 1000
//#define DEBUG

enum Sections
{
Expand Down Expand Up @@ -454,26 +408,67 @@ public TypesMenu_Handler(id, iMenu, iItem)

public OnPlayerHudReset(id)
{
if (g_eUserSettings[id][TrailOn])
new iTaskID = id + TASKID
if (task_exists(iTaskID))
{
return HC_CONTINUE
remove_task(iTaskID)
}

new Teams:iPlayerTeam = catchmod_get_user_team(id)
new Float:fColors[3]
set_task_ex(1.0, "task_PreApply", iTaskID)
return HC_CONTINUE
}

public task_PreApply(iTaskID)
{
new id = iTaskID - TASKID

#if defined DEBUG
client_print_color(id, id, "^x04[DEBUG]^x01 Function - PreApply")
client_print_color(id, id, "^x04---------------------------")
#endif

copy(g_eUserSettings[id][TrailColors], 3, g_eTeamsColors[iPlayerTeam])
fColors[0] = float(g_eTeamsColors[iPlayerTeam][0])
fColors[1] = float(g_eTeamsColors[iPlayerTeam][1])
fColors[2] = float(g_eTeamsColors[iPlayerTeam][2])
if (!g_eUserSettings[id][TrailOn])
{
new Teams:iPlayerTeam = catchmod_get_user_team(id)
new Float:fColors[3]

g_eUserSettings[id][TrailColors][0] = g_eTeamsColors[iPlayerTeam][0]
g_eUserSettings[id][TrailColors][1] = g_eTeamsColors[iPlayerTeam][1]
g_eUserSettings[id][TrailColors][2] = g_eTeamsColors[iPlayerTeam][2]
fColors[0] = float(g_eTeamsColors[iPlayerTeam][0])
fColors[1] = float(g_eTeamsColors[iPlayerTeam][1])
fColors[2] = float(g_eTeamsColors[iPlayerTeam][2])

set_entvar(id, var_renderfx, kRenderFxGlowShell)
set_entvar(id, var_rendercolor, fColors)
set_entvar(id, var_renderamt, 25.0)

#if defined DEBUG
client_print_color(id, id, "Teams - %i %i %i", g_eTeamsColors[iPlayerTeam][0], g_eTeamsColors[iPlayerTeam][1], g_eTeamsColors[iPlayerTeam][2])
client_print_color(id, id, "User - %i %i %i", g_eUserSettings[id][TrailColors][0], g_eUserSettings[id][TrailColors][1], g_eUserSettings[id][TrailColors][2])
client_print_color(id, id, "Floats - %f %f %f", fColors[0], fColors[1], fColors[2])
#endif
}
#if defined DEBUG
else
{
client_print_color(id, id, "Function Cutted")
}
client_print_color(id, id, "^x04---------------------------")
#endif

set_entvar(id, var_renderfx, kRenderFxGlowShell)
set_entvar(id, var_rendercolor, fColors)
set_entvar(id, var_renderamt, 25.0)
UpdateUserTrail(id)
set_task_ex(10.0, "task_Apply", id + TASKID, .flags = SetTask_Repeat)
}

public task_Apply(iTaskID)
{
new id = iTaskID - TASKID
UpdateUserTrail(id)

return HC_CONTINUE
#if defined DEBUG
client_print_color(id, id, "^x04[DEBUG]^x01 Function - Apply")
#endif
}

UpdateUserTrail(id)
Expand Down
Loading

0 comments on commit e4217f9

Please sign in to comment.