diff --git a/addons/sourcemod/scripting/include/shavit/core.inc b/addons/sourcemod/scripting/include/shavit/core.inc index 317037d2..e271576e 100644 --- a/addons/sourcemod/scripting/include/shavit/core.inc +++ b/addons/sourcemod/scripting/include/shavit/core.inc @@ -678,6 +678,17 @@ forward void Shavit_OnPause(int client, int track); */ forward void Shavit_OnResume(int client, int track); +/** + * Called when a player tries to change their bhopstyle. + * + * @param client Client index. + * @param oldstyle Old bhop style. + * @param newstyle New bhop style. + * @param track Timer track. + * @return Plugin_Continue to do nothing. Anything else to block. + */ +forward Action Shavit_OnStyleCommandPre(int client, int oldstyle, int newstyle, int track); + /** * Called when a player changes their bhopstyle. * Note: Doesn't guarantee that the player is in-game or connected. diff --git a/addons/sourcemod/scripting/shavit-core.sp b/addons/sourcemod/scripting/shavit-core.sp index ed4f6fe0..85889a07 100644 --- a/addons/sourcemod/scripting/shavit-core.sp +++ b/addons/sourcemod/scripting/shavit-core.sp @@ -73,6 +73,7 @@ Handle gH_Forwards_OnEndPre = null; Handle gH_Forwards_OnEnd = null; Handle gH_Forwards_OnPause = null; Handle gH_Forwards_OnResume = null; +Handle gH_Forwards_OnStyleCommandPre = null; Handle gH_Forwards_OnStyleChanged = null; Handle gH_Forwards_OnTrackChanged = null; Handle gH_Forwards_OnChatConfigLoaded = null; @@ -235,6 +236,7 @@ public void OnPluginStart() gH_Forwards_OnEnd = CreateGlobalForward("Shavit_OnEnd", ET_Event, Param_Cell, Param_Cell); gH_Forwards_OnPause = CreateGlobalForward("Shavit_OnPause", ET_Event, Param_Cell, Param_Cell); gH_Forwards_OnResume = CreateGlobalForward("Shavit_OnResume", ET_Event, Param_Cell, Param_Cell); + gH_Forwards_OnStyleCommandPre = CreateGlobalForward("Shavit_OnStyleCommandPre", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell); gH_Forwards_OnStyleChanged = CreateGlobalForward("Shavit_OnStyleChanged", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell); gH_Forwards_OnTrackChanged = CreateGlobalForward("Shavit_OnTrackChanged", ET_Event, Param_Cell, Param_Cell, Param_Cell); gH_Forwards_OnChatConfigLoaded = CreateGlobalForward("Shavit_OnChatConfigLoaded", ET_Event); @@ -1210,6 +1212,27 @@ public Action Command_Style(int client, int args) return Plugin_Handled; } + // allow !style + if (args > 0) + { + char sArgs[16]; + GetCmdArg(1, sArgs, sizeof(sArgs)); + int style = StringToInt(sArgs); + + if (style < 0 || style >= Shavit_GetStyleCount()) + { + return Plugin_Handled; + } + + if (GetStyleSettingBool(style, "inaccessible")) + { + return Plugin_Handled; + } + + ChangeClientStyle(client, style, true); + return Plugin_Handled; + } + Menu menu = new Menu(StyleMenu_Handler); menu.SetTitle("%T", "StyleMenuTitle", client); @@ -1395,6 +1418,19 @@ void ChangeClientStyle(int client, int style, bool manual) if(manual) { + Action result = Plugin_Continue; + Call_StartForward(gH_Forwards_OnStyleCommandPre); + Call_PushCell(client); + Call_PushCell(gA_Timers[client].bsStyle); + Call_PushCell(style); + Call_PushCell(gA_Timers[client].iTimerTrack); + Call_Finish(result); + + if (result > Plugin_Continue) + { + return; + } + if(!Shavit_StopTimer(client, false)) { return; diff --git a/addons/sourcemod/scripting/shavit-misc.sp b/addons/sourcemod/scripting/shavit-misc.sp index 4a73fd50..788c99c8 100644 --- a/addons/sourcemod/scripting/shavit-misc.sp +++ b/addons/sourcemod/scripting/shavit-misc.sp @@ -70,7 +70,7 @@ int gI_Style[MAXPLAYERS+1]; Function gH_AfterWarningMenu[MAXPLAYERS+1]; int gI_LastWeaponTick[MAXPLAYERS+1]; int gI_LastNoclipTick[MAXPLAYERS+1]; -int gI_LastRestartTrack[MAXPLAYERS+1]; +int gI_LastStopInfo[MAXPLAYERS+1]; // cookies Handle gH_HideCookie = null; @@ -1785,12 +1785,18 @@ void DoNoclip(int client) void DoEnd(int client) { - Shavit_GotoEnd(client, gI_LastRestartTrack[client]); + Shavit_GotoEnd(client, gI_LastStopInfo[client]); } void DoRestart(int client) { - Shavit_RestartTimer(client, gI_LastRestartTrack[client]); + Shavit_RestartTimer(client, gI_LastStopInfo[client]); +} + +void DoStyleChange(int client) +{ + Shavit_StopTimer(client); + FakeClientCommandEx(client, "sm_style %d", gI_LastStopInfo[client]); } void DoStopTimer(int client) @@ -2158,11 +2164,23 @@ public void Shavit_OnRestart(int client, int track) } } +public Action Shavit_OnStyleCommandPre(int client, int oldstyle, int newstyle, int track) +{ + if (ShouldDisplayStopWarning(client)) + { + gI_LastStopInfo[client] = newstyle; + OpenStopWarningMenu(client, DoStyleChange); + return Plugin_Handled; + } + + return Plugin_Continue; +} + public Action Shavit_OnEndPre(int client, int track) { if (ShouldDisplayStopWarning(client)) { - gI_LastRestartTrack[client] = track; + gI_LastStopInfo[client] = track; OpenStopWarningMenu(client, DoEnd); return Plugin_Handled; } @@ -2197,7 +2215,7 @@ public Action Shavit_OnRestartPre(int client, int track) if (ShouldDisplayStopWarning(client)) { - gI_LastRestartTrack[client] = track; + gI_LastStopInfo[client] = track; OpenStopWarningMenu(client, DoRestart); return Plugin_Handled; }