From 9cca23010c1ff6621d9cfa7597cb632a805d5fa4 Mon Sep 17 00:00:00 2001 From: mi0epro Date: Thu, 25 Jul 2019 19:45:40 +0300 Subject: [PATCH] Added Default Trails --- catchmod_main.sma | 103 ++++++++++++++++++++++++++----------- catchmod_trail.sma | 60 ++++++++++++++++++++- configs/TrailsSettings.ini | 9 +++- include/catch_const.inc | 16 +----- include/catchmod.inc | 8 +++ 5 files changed, 149 insertions(+), 47 deletions(-) create mode 100644 include/catchmod.inc diff --git a/catchmod_main.sma b/catchmod_main.sma index cf6d59b..a9610a6 100644 --- a/catchmod_main.sma +++ b/catchmod_main.sma @@ -35,6 +35,20 @@ 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() { @@ -42,9 +56,9 @@ public plugin_init() // 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") @@ -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) { @@ -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 @@ -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) { @@ -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) @@ -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)] } \ No newline at end of file diff --git a/catchmod_trail.sma b/catchmod_trail.sma index ac6cecc..0e66738 100644 --- a/catchmod_trail.sma +++ b/catchmod_trail.sma @@ -1,7 +1,8 @@ #include #include +#include #include -#include +#include enum LiteType { @@ -51,6 +52,7 @@ enum _:TrailsSettings CustomColorFlags, TrailModeAdd } +new g_eTeamsColors[Teams][3] new Array:g_aColorsArray new Array:g_aTypesArray @@ -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") } @@ -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] @@ -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]) + } } } } @@ -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) diff --git a/configs/TrailsSettings.ini b/configs/TrailsSettings.ini index 40e9ce5..33a3fc5 100644 --- a/configs/TrailsSettings.ini +++ b/configs/TrailsSettings.ini @@ -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] // diff --git a/include/catch_const.inc b/include/catch_const.inc index 2139f3a..8367051 100644 --- a/include/catch_const.inc +++ b/include/catch_const.inc @@ -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] \ No newline at end of file +} \ No newline at end of file diff --git a/include/catchmod.inc b/include/catchmod.inc new file mode 100644 index 0000000..3e02a78 --- /dev/null +++ b/include/catchmod.inc @@ -0,0 +1,8 @@ +#if defined _catchmod_included + #endinput +#endif +#define _catchmod_included + +#include + +native Teams:catchmod_get_user_team(id) \ No newline at end of file