make stoptimer confirmation menu work with styles and add some more forwards

This commit is contained in:
rtldg 2021-12-28 20:19:04 +00:00
parent 62c2a26e48
commit 35391f36d1
3 changed files with 70 additions and 5 deletions

View File

@ -678,6 +678,17 @@ forward void Shavit_OnPause(int client, int track);
*/ */
forward void Shavit_OnResume(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. * Called when a player changes their bhopstyle.
* Note: Doesn't guarantee that the player is in-game or connected. * Note: Doesn't guarantee that the player is in-game or connected.

View File

@ -73,6 +73,7 @@ Handle gH_Forwards_OnEndPre = null;
Handle gH_Forwards_OnEnd = null; Handle gH_Forwards_OnEnd = null;
Handle gH_Forwards_OnPause = null; Handle gH_Forwards_OnPause = null;
Handle gH_Forwards_OnResume = null; Handle gH_Forwards_OnResume = null;
Handle gH_Forwards_OnStyleCommandPre = null;
Handle gH_Forwards_OnStyleChanged = null; Handle gH_Forwards_OnStyleChanged = null;
Handle gH_Forwards_OnTrackChanged = null; Handle gH_Forwards_OnTrackChanged = null;
Handle gH_Forwards_OnChatConfigLoaded = 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_OnEnd = CreateGlobalForward("Shavit_OnEnd", ET_Event, Param_Cell, Param_Cell);
gH_Forwards_OnPause = CreateGlobalForward("Shavit_OnPause", 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_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_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_OnTrackChanged = CreateGlobalForward("Shavit_OnTrackChanged", ET_Event, Param_Cell, Param_Cell, Param_Cell);
gH_Forwards_OnChatConfigLoaded = CreateGlobalForward("Shavit_OnChatConfigLoaded", ET_Event); gH_Forwards_OnChatConfigLoaded = CreateGlobalForward("Shavit_OnChatConfigLoaded", ET_Event);
@ -1210,6 +1212,27 @@ public Action Command_Style(int client, int args)
return Plugin_Handled; return Plugin_Handled;
} }
// allow !style <number>
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 menu = new Menu(StyleMenu_Handler);
menu.SetTitle("%T", "StyleMenuTitle", client); menu.SetTitle("%T", "StyleMenuTitle", client);
@ -1395,6 +1418,19 @@ void ChangeClientStyle(int client, int style, bool manual)
if(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)) if(!Shavit_StopTimer(client, false))
{ {
return; return;

View File

@ -70,7 +70,7 @@ int gI_Style[MAXPLAYERS+1];
Function gH_AfterWarningMenu[MAXPLAYERS+1]; Function gH_AfterWarningMenu[MAXPLAYERS+1];
int gI_LastWeaponTick[MAXPLAYERS+1]; int gI_LastWeaponTick[MAXPLAYERS+1];
int gI_LastNoclipTick[MAXPLAYERS+1]; int gI_LastNoclipTick[MAXPLAYERS+1];
int gI_LastRestartTrack[MAXPLAYERS+1]; int gI_LastStopInfo[MAXPLAYERS+1];
// cookies // cookies
Handle gH_HideCookie = null; Handle gH_HideCookie = null;
@ -1785,12 +1785,18 @@ void DoNoclip(int client)
void DoEnd(int client) void DoEnd(int client)
{ {
Shavit_GotoEnd(client, gI_LastRestartTrack[client]); Shavit_GotoEnd(client, gI_LastStopInfo[client]);
} }
void DoRestart(int 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) 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) public Action Shavit_OnEndPre(int client, int track)
{ {
if (ShouldDisplayStopWarning(client)) if (ShouldDisplayStopWarning(client))
{ {
gI_LastRestartTrack[client] = track; gI_LastStopInfo[client] = track;
OpenStopWarningMenu(client, DoEnd); OpenStopWarningMenu(client, DoEnd);
return Plugin_Handled; return Plugin_Handled;
} }
@ -2197,7 +2215,7 @@ public Action Shavit_OnRestartPre(int client, int track)
if (ShouldDisplayStopWarning(client)) if (ShouldDisplayStopWarning(client))
{ {
gI_LastRestartTrack[client] = track; gI_LastStopInfo[client] = track;
OpenStopWarningMenu(client, DoRestart); OpenStopWarningMenu(client, DoRestart);
return Plugin_Handled; return Plugin_Handled;
} }