Add topleft hud and clantag forwards

This commit is contained in:
KiD Fearless 2019-03-08 18:08:02 -07:00
parent a0d205247a
commit ef8af7807d
3 changed files with 77 additions and 0 deletions

View File

@ -575,6 +575,37 @@ forward void Shavit_OnReplayStart(int client);
*/
forward void Shavit_OnReplayEnd(int client);
/**
* Called when top left HUD updates.
*
* @param client Client index that recieves the hud.
* @param target Client index that recieves the hud.
* @param topleft Reference to the HUD buffer.
* @param topleftlength Max length of the topleft buffer.
* @return Plugin_Handled or Plugin_Stop to block the HUD message from appearing. Anything else to pass along new values.
*/
forward Action Shavit_OnTopLeftHUD(int client, int target, char[] topleft, const int topleftlength);
/**
* Called before clan tag variables are processed
*
* @param client Client index.
* @param clantag Reference to the clan tag buffer.
* @param clantaglength Max length of the customtag buffer.
* @return Plugin_Handled or Plugin_Stop to block the clan tag from changing. Anything else to pass along new values.
*/
forward Action Shavit_OnClanTagChangePre(int client, char[] clantag, int clantaglength);
/**
* Called after clan tags are changed
*
* @param client Client index.
* @param customtag Reference to the custom clan tag buffer.
* @param customtaglength Max length of the customtag buffer.
* @noreturn
*/
forward void Shavit_OnClanTagChangePost(int client, char[] customtag, int customtaglength);
/**
* Returns the game type the server is running.
*

View File

@ -81,6 +81,9 @@ enum struct color_t
// game type (CS:S/CS:GO/TF2)
EngineVersion gEV_Type = Engine_Unknown;
// forwards
Handle gH_Forwards_OnTopLeftHUD = null;
// modules
bool gB_Replay = false;
bool gB_Zones = false;
@ -133,6 +136,10 @@ public Plugin myinfo =
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
// forwards
gH_Forwards_OnTopLeftHUD = CreateGlobalForward("Shavit_OnTopLeftHUD", ET_Event, Param_Cell, Param_Cell, Param_String, Param_Cell);
// natives
CreateNative("Shavit_ForceHUDUpdate", Native_ForceHUDUpdate);
CreateNative("Shavit_GetHUDSettings", Native_GetHUDSettings);
@ -1585,6 +1592,19 @@ void UpdateTopLeftHUD(int client, bool wait)
Format(sTopLeft, 128, "%s\n%s (#%d)", sTopLeft, sSelfPB, Shavit_GetRankForTime(style, fSelfPB, track));
}
Action result = Plugin_Continue;
Call_StartForward(gH_Forwards_OnTopLeftHUD);
Call_PushCell(client);
Call_PushCell(target);
Call_PushStringEx(sTopLeft, 128, SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
Call_PushCell(128);
Call_Finish(result);
if(result != Plugin_Continue && result != Plugin_Changed)
{
return;
}
SetHudTextParams(0.01, 0.01, 2.5, 255, 255, 255, 255, 0, 0.0, 0.0, 0.0);
ShowSyncHudText(client, gH_HUD, "%s", sTopLeft);
}

View File

@ -147,6 +147,10 @@ ConVar gCV_SpectatorList = null;
ConVar gCV_MaxCP = null;
ConVar gCV_MaxCP_Segmented = null;
// forwards
Handle gH_Forwards_OnClanTagChangePre = null;
Handle gH_Forwards_OnClanTagChangePost = null;
// cached cvars
int gI_HumanTeam = 0;
@ -176,6 +180,10 @@ public Plugin myinfo =
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
// forwards
gH_Forwards_OnClanTagChangePre = CreateGlobalForward("Shavit_OnClanTagChangePre", ET_Event, Param_Cell, Param_String, Param_Cell);
gH_Forwards_OnClanTagChangePost = CreateGlobalForward("Shavit_OnClanTagChangePost", ET_Event, Param_Cell, Param_String, Param_Cell);
gB_Late = late;
return APLRes_Success;
@ -888,7 +896,25 @@ void UpdateClanTag(int client)
ReplaceString(sCustomTag, 32, "{tr}", sTrack);
ReplaceString(sCustomTag, 32, "{rank}", sRank);
Action result = Plugin_Continue;
Call_StartForward(gH_Forwards_OnClanTagChangePre);
Call_PushCell(client);
Call_PushStringEx(sTag, 32, SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
Call_PushCell(32);
Call_Finish(result);
if(result != Plugin_Continue && result != Plugin_Changed)
{
return;
}
CS_SetClientClanTag(client, sCustomTag);
Call_StartForward(gH_Forwards_OnClanTagChangePost);
Call_PushCell(client);
Call_PushStringEx(sCustomTag, 32, SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
Call_PushCell(32);
Call_Finish();
}
void RemoveRagdoll(int client)