Skip to content

Commit

Permalink
Added Default Trails
Browse files Browse the repository at this point in the history
  • Loading branch information
1mi0 committed Jul 25, 2019
1 parent 0195cd7 commit 9cca230
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 47 deletions.
103 changes: 74 additions & 29 deletions catchmod_main.sma
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,30 @@ new bool:g_bJump[MAXPLAYERSVAR]
new bool:g_bHasSemiclip[MAXPLAYERSVAR]
new bool:g_bSolid[MAXPLAYERSVAR]
new bool:g_bSpeedOn[MAXPLAYERSVAR]
// Hud
enum _:HudEntities
{
HudStatusEnt,
HudSpeedEnt
}

enum _:HudSE
{
TaskEntity,
HudSync
}

new g_iHud[HudEntities][HudSE]

public plugin_init()
{
register_plugin("Catch Mod: Main", CATCHMOD_VER, "mi0")

// Cvars
g_iCvarSpeed = register_cvar("catch_speed", "640.0")
g_iCvarTouches = register_cvar("catch_touches", "3")
g_iCvarTurboSpeed = register_cvar("catch_turbospeed", "840.0")
g_iCvarTurbo = register_cvar("catch_turbo", "30")
g_iCvarTurboSpeed = register_cvar("catch_turbo_speed", "840.0")
g_iCvarTouches = register_cvar("catch_walls_touches", "3")

new iTempPointer
iTempPointer = get_cvar_pointer("sv_gravity")
Expand Down Expand Up @@ -123,12 +137,23 @@ public plugin_precache()
// Reset Vars, Update Stats
public client_putinserver(id)
{
SetDefaultCatchSettings(id)

g_bSpeedOn[id] = true
g_iPlayerStats[id][0] = 0
g_iPlayerStats[id][1] = 0
set_task(0.5, "UpdateStats", id)
}

SetDefaultCatchSettings(id)
{
client_cmd_ex(id, "cl_forwardspeed 9999")
client_cmd_ex(id, "cl_sidespeed 9999")
client_cmd_ex(id, "cl_backspeed 9999")
client_cmd_ex(id, "fps_max 100")
client_cmd_ex(id, "fps_override 0")
}

// Think
public OnPlayerThink(id)
{
Expand Down Expand Up @@ -190,7 +215,11 @@ public OnPlayerJump(id)
{
g_iWallTouches[id] = get_pcvar_num(g_iCvarTouches) // wall jump, cuz he is not in bhop
}

return HC_SUPERCEDE
}

return HC_CONTINUE
}

// Touch Wall
Expand Down Expand Up @@ -579,17 +608,6 @@ public SpeedEntityThink()
set_entvar(g_iHud[HudSpeedEnt][TaskEntity], var_nextthink, get_gametime() + 0.1)
}

// Natives
public plugin_natives()
{
register_native("catch_get_user_team", "_native_get_user_team")
}

public Teams:_native_get_user_team()
{
return g_iPlayerTeams[get_param(1)]
}

// Restrictions, models and physics
public OnPlayerResetMaxSpeed(id)
{
Expand All @@ -616,27 +634,24 @@ public OnPlayerSpawn(id)
rg_give_item(id, "weapon_knife")
}

set_entvar(id, var_renderfx, kRenderFxGlowShell)

if (g_iPlayerTeams[id] == FLEER)
switch(g_iPlayerTeams[id])
{
g_iTurbo[id] = get_pcvar_num(g_iCvarTurbo)
case FLEER:
{
g_iTurbo[id] = get_pcvar_num(g_iCvarTurbo)
}

set_entvar(id, var_rendercolor, {0.0, 255.0, 0.0})
}
else if (g_iPlayerTeams[id] == CATCHER)
{
g_iTurbo[id] = -1
case CATCHER, NONE:
{
g_iTurbo[id] = -1
}

set_entvar(id, var_rendercolor, {255.0, 0.0, 0.0})
}
else
{
set_entvar(id, var_rendercolor, {0.0, 0.0, 255.0})
case TRAINING:
{
g_iTurbo[id] = 100
}
}

set_entvar(id, var_renderamt, 25.0)

g_fPlayerSpeed[id] = get_pcvar_float(g_iCvarSpeed)

UpdateHud(id)
Expand All @@ -651,4 +666,34 @@ public ReapiSupercedeHandler()
public HamSupercedeHandler()
{
return HAM_SUPERCEDE
}

// Stocks
stock client_cmd_ex(id, const szText[], any:...)
{
#pragma unused szText

if (id == 0 || is_user_connected(id))
{
new szMessage[256]

format_args(szMessage, charsmax(szMessage), 1)

message_begin(id == 0 ? MSG_ALL : MSG_ONE, 51, _, id)
write_byte(strlen(szMessage) + 2)
write_byte(10)
write_string(szMessage)
message_end()
}
}

// Natives
public plugin_natives()
{
register_native("catchmod_get_user_team", "_native_get_user_team")
}

public Teams:_native_get_user_team()
{
return g_iPlayerTeams[get_param(1)]
}
60 changes: 58 additions & 2 deletions catchmod_trail.sma
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <amxmodx>
#include <amxmisc>
#include <reapi>
#include <cromchat>
#include <catch_const>
#include <catchmod>

enum LiteType
{
Expand Down Expand Up @@ -51,6 +52,7 @@ enum _:TrailsSettings
CustomColorFlags,
TrailModeAdd
}
new g_eTeamsColors[Teams][3]

new Array:g_aColorsArray
new Array:g_aTypesArray
Expand All @@ -74,6 +76,8 @@ public plugin_init()
{
register_plugin("Catch Mod: Trails", CATCHMOD_VER, "mi0")

RegisterHookChain(RG_CBasePlayer_Spawn, "OnPlayerSpawn", 1)

register_clcmd("say /trails", "cmd_trails")
register_clcmd("CT_CUSTOM_COLOR", "cmd_custom_color")
}
Expand Down Expand Up @@ -105,6 +109,7 @@ LoadFile()
{
new szLine[256], Sections:iSection = SectionNone
new szKey[32], szValue[32]
new Teams:iTeam
new szParsedColor[3][4]
new eTempColorArray[ColorsData], eTempTypeArray[TrailTypeData]

Expand Down Expand Up @@ -193,13 +198,44 @@ LoadFile()
{
g_eTrailsSettings[CustomColorFlags] = read_flags(szValue)
}
else if (equali((szKey), "CHAT_PREFIX"))
else if (equali(szKey, "CHAT_PREFIX"))
{
if (szValue[0] != EOS)
{
CC_SetPrefix(szValue)
}
}
else if (equali(szKey, "FLEER_COLOR") || equali(szKey, "CATCHER_COLOR") || equali(szKey, "TRAINING_COLOR") || equali(szKey, "NONE_COLOR"))
{
parse(szValue, szParsedColor[0], charsmax(szParsedColor[]), szParsedColor[1], charsmax(szParsedColor[]), szParsedColor[2], charsmax(szParsedColor[]))

switch (szKey[0])
{
case 'F':
{
iTeam = FLEER
}

case 'C':
{
iTeam = CATCHER
}

case 'T':
{
iTeam = TRAINING
}

case 'N':
{
iTeam = NONE
}
}

g_eTeamsColors[iTeam][0] = str_to_num(szParsedColor[0])
g_eTeamsColors[iTeam][1] = str_to_num(szParsedColor[1])
g_eTeamsColors[iTeam][2] = str_to_num(szParsedColor[2])
}
}
}
}
Expand Down Expand Up @@ -434,6 +470,26 @@ public TypesMenu_Handler(id, iMenu, iItem)
return PLUGIN_HANDLED
}

public OnPlayerSpawn(id)
{
if (g_eUserSettings[id][TrailOn])
{
return HC_CONTINUE
}

new Teams:iPlayerTeam = catchmod_get_user_team(id)

copy(g_eUserSettings[id][TrailColors], 3, g_eTeamsColors[iPlayerTeam])

set_entvar(id, var_renderfx, kRenderFxGlowShell)
set_entvar(id, var_rendercolor, g_eTeamsColors[iPlayerTeam])
set_entvar(id, var_renderamt, 25.0)

CC_SendMatched(id, id, "Your Trail colors and Render colors are set to %s", g_szTeamsNames[iPlayerTeam])

return HC_CONTINUE
}

StartUserTrail(id)
{
UpdateUserTrail(id)
Expand Down
9 changes: 8 additions & 1 deletion configs/TrailsSettings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ TRAIL_LIFE = 2
// The prefix in the chat messages
// Example - CHAT_PREFIX = !g[!nColorful Trails!g]
CHAT_PREFIX = !g[!nColorful Trails!g]
CHAT_PREFIX = !g[CatchMod] !t>> Colorful Trails >>
// Teams Colors - The color of the specified team
// Example - FLEER_COLOR = 0 255 0
FLEER_COLOR = 0 255 0
CATCHER_COLOR = 255 0 0
TRAINING_COLOR = 0 0 255
NONE_COLOR = 255 255 255
[Types]
//
Expand Down
16 changes: 1 addition & 15 deletions include/catch_const.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,4 @@ new g_szTeamsNames[Teams][32] =
"Fleer",
"Catcher",
"Training"
}

enum _:HudEntities
{
HudStatusEnt,
HudSpeedEnt
}

enum _:HudSE
{
TaskEntity,
HudSync
}

new g_iHud[HudEntities][HudSE]
}
8 changes: 8 additions & 0 deletions include/catchmod.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#if defined _catchmod_included
#endinput
#endif
#define _catchmod_included

#include <catch_const>

native Teams:catchmod_get_user_team(id)

0 comments on commit 9cca230

Please sign in to comment.