Skip to content

Commit 072a072

Browse files
authored
Merge pull request #46 from z4cH3r/master
added cookie for the toogle tags
2 parents 2f33a13 + 14ae8de commit 072a072

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

addons/sourcemod/scripting/hextags.sp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <geoip>
2828
#include <hexstocks>
2929
#include <hextags>
30+
#include <clientprefs>
3031

3132
#undef REQUIRE_EXTENSIONS
3233
#undef REQUIRE_PLUGIN
@@ -50,6 +51,7 @@ Handle fTagsUpdated;
5051
Handle fMessageProcess;
5152
Handle fMessageProcessed;
5253
Handle fMessagePreProcess;
54+
Handle g_hPref_HideTags;
5355

5456
DataPack dataOrder;
5557

@@ -130,6 +132,8 @@ public void OnPluginStart()
130132
//Event hooks
131133
if (!HookEventEx("round_end", Event_RoundEnd))
132134
LogError("Failed to hook \"round_end\", \"sm_hextags_roundend\" won't produce any effect.");
135+
136+
g_hPref_HideTags = RegClientCookie("Hextags_Visability", "Show or hide the tags.", CookieAccess_Private);
133137

134138
#if defined DEBUG
135139
RegConsoleCmd("sm_gettagvars", Cmd_GetVars);
@@ -158,6 +162,19 @@ public void OnAllPluginsLoaded()
158162
CreateTimer(5.0, Timer_ForceTag, _, TIMER_REPEAT);
159163
}
160164

165+
public void OnClientCookiesCached(int client)
166+
{
167+
char sValue[8];
168+
GetClientCookie(client, g_hPref_HideTags, sValue, sizeof(sValue));
169+
170+
if (strlen(sValue) == 0)
171+
{
172+
strcopy(sValue, sizeof(sValue), "1");
173+
SetClientCookie(client, g_hPref_HideTags, "1");
174+
}
175+
176+
bHideTag[client] = (sValue[0] != '\0' && StringToInt(sValue));
177+
}
161178

162179
public void OnLibraryAdded(const char[] name)
163180
{
@@ -322,6 +339,8 @@ public Action Cmd_ToggleTags(int client, int args)
322339
CS_SetClientClanTag(client, "");
323340
ReplyToCommand(client, "[SM] Your tags are no longer visible.");
324341
}
342+
343+
SetClientCookie(client, g_hPref_HideTags, bHideTag[client] ? "1" : "0");
325344
}
326345

327346
public Action Cmd_GetTeam(int client, int args)

0 commit comments

Comments
 (0)