mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-07 10:28:26 +00:00
make stoptimer confirmation menu work with styles and add some more forwards
This commit is contained in:
parent
62c2a26e48
commit
35391f36d1
@ -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.
|
||||
|
||||
@ -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 <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.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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user