Skip to content

Commit

Permalink
Merge pull request #745 from kidfearless/KiDFearless
Browse files Browse the repository at this point in the history
Add forwards for topleft hud and clantag changes
  • Loading branch information
shavitush authored Mar 9, 2019
2 parents a0d2052 + ef8af78 commit 9065e6d
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
31 changes: 31 additions & 0 deletions addons/sourcemod/scripting/include/shavit.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
20 changes: 20 additions & 0 deletions addons/sourcemod/scripting/shavit-hud.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
26 changes: 26 additions & 0 deletions addons/sourcemod/scripting/shavit-misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9065e6d

Please sign in to comment.