Skip to content

Commit

Permalink
Add sm_hidetags command
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexer10 committed Jan 9, 2020
1 parent 627f71e commit 601cf69
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions addons/sourcemod/scripting/hextags.sp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ bool bSteamWorks = true;
bool bForceTag[MAXPLAYERS+1];

int iRank[MAXPLAYERS+1] = {-1, ...};
bool bHideTag[MAXPLAYERS+1];

char sTags[MAXPLAYERS+1][eTags][128];

Expand Down Expand Up @@ -122,6 +123,7 @@ public void OnPluginStart()

//Reg Cmds
RegAdminCmd("sm_reloadtags", Cmd_ReloadTags, ADMFLAG_GENERIC, "Reload HexTags plugin config");
RegAdminCmd("sm_toggletags", Cmd_ToggleTags, ADMFLAG_GENERIC, "Toggle the visibility of your tags");
RegConsoleCmd("sm_getteam", Cmd_GetTeam, "Get current team name");

//Event hooks
Expand Down Expand Up @@ -224,7 +226,10 @@ public void OnLibraryRemoved(const char[] name)
//Thanks to https://forums.alliedmods.net/showpost.php?p=2573907&postcount=6
public Action OnClientCommandKeyValues(int client, KeyValues kv)
{
char sKey[64];
if (bHideTag[client])
return Plugin_Continue;

char sKey[64];

if (!bCSGO | !kv.GetSectionName(sKey, sizeof(sKey)))
return Plugin_Continue;
Expand Down Expand Up @@ -260,6 +265,7 @@ public void OnClientDisconnect(int client)
{
ResetTags(client);
iRank[client] = -1;
bHideTag[client] = false;
}

public void warden_OnWardenCreated(int client)
Expand Down Expand Up @@ -301,6 +307,22 @@ public Action Cmd_ReloadTags(int client, int args)
return Plugin_Handled;
}

public Action Cmd_ToggleTags(int client, int args)
{
if (bHideTag[client])
{
bHideTag[client] = false;
LoadTags(client);
ReplyToCommand(client, "[SM] Your tags are visible again.");
}
else
{
bHideTag[client] = true;
CS_SetClientClanTag(client, "");
ReplyToCommand(client, "[SM] Your tags are no longer visible.");
}
}

public Action Cmd_GetTeam(int client, int args)
{
char sTeam[32];
Expand Down Expand Up @@ -359,6 +381,11 @@ public Action RankMe_LoadTags(int client, int rank, any data)

public Action CP_OnChatMessage(int& author, ArrayList recipients, char[] flagstring, char[] name, char[] message, bool& processcolors, bool& removecolors)
{
if (bHideTag[author])
{
return Plugin_Continue;
}

Action result = Plugin_Continue;
//Call the forward
Call_StartForward(fMessagePreProcess);
Expand Down Expand Up @@ -608,6 +635,9 @@ void LoadKv()
}
void LoadTags(int client, KeyValues kv = null)
{
if (bHideTag[client])
return;

if (!IsValidClient(client, true, true))
return;

Expand Down Expand Up @@ -656,7 +686,7 @@ public Action Timer_ForceTag(Handle timer)
if (!bCSGO)
return;

for (int i = 1; i <= MaxClients; i++)if (IsClientInGame(i) && bForceTag[i] && sTags[i][ScoreTag][0] != '\0')
for (int i = 1; i <= MaxClients; i++)if (IsClientInGame(i) && bForceTag[i] && sTags[i][ScoreTag][0] != '\0' && !bHideTag[i])
{
char sTag[32];
CS_GetClientClanTag(i, sTag, sizeof(sTag));
Expand Down

0 comments on commit 601cf69

Please sign in to comment.