Skip to content

Commit 242a8a3

Browse files
committed
Cache default user tag #50
1 parent 8e9f24f commit 242a8a3

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

addons/sourcemod/scripting/hextags.sp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* by: Hexah
44
* https://github.com/Hexer10/HexTags
55
*
6-
* Copyright (C) 2017-2019 Mattia (Hexah|Hexer10|Papero)
6+
* Copyright (C) 2017-2020 Mattia (Hexah|Hexer10|Papero)
77
*
88
* This file is part of the HexTags SourceMod Plugin.
99
*
@@ -76,6 +76,7 @@ bool bHideTag[MAXPLAYERS+1];
7676

7777
// TODO: Workaround for sm 1.11, implement eTags enum struct
7878
char sTags[MAXPLAYERS+1][4][128];
79+
char sUserTag[MAXPLAYERS+1][64];
7980

8081
//Plugin info
8182
public Plugin myinfo =
@@ -251,7 +252,7 @@ public Action OnClientCommandKeyValues(int client, KeyValues kv)
251252

252253
if(StrEqual(sKey, "ClanTagChanged"))
253254
{
254-
//RequestFrame(Frame_SetTag, GetClientUserId(client));
255+
kv.GetString("tag", sUserTag[client], sizeof(sUserTag[]));
255256
LoadTags(client);
256257

257258
if(sTags[client][ScoreTag][0] == '\0')
@@ -265,16 +266,12 @@ public Action OnClientCommandKeyValues(int client, KeyValues kv)
265266
return Plugin_Continue;
266267
}
267268

268-
public void Frame_SetTag(any client)
269-
{
270-
LoadTags(GetClientOfUserId(client));
271-
}
272-
273269
public void OnClientDisconnect(int client)
274270
{
275271
ResetTags(client);
276272
iRank[client] = -1;
277273
bHideTag[client] = false;
274+
sUserTag[client][0] = '\0';
278275
}
279276

280277
public void warden_OnWardenCreated(int client)
@@ -284,9 +281,8 @@ public void warden_OnWardenCreated(int client)
284281

285282
public void warden_OnWardenRemoved(int client)
286283
{
287-
//TODO Set the original clantag
288284
if (bCSGO)
289-
CS_SetClientClanTag(client, "");
285+
CS_SetClientClanTag(client, sUserTag[client]);
290286

291287
RequestFrame(Frame_LoadTag, client);
292288

@@ -299,9 +295,8 @@ public void warden_OnDeputyCreated(int client)
299295

300296
public void warden_OnDeputyRemoved(int client)
301297
{
302-
//TODO Set the original clantag
303298
if (bCSGO)
304-
CS_SetClientClanTag(client, "");
299+
CS_SetClientClanTag(client, sUserTag[client]);
305300

306301
RequestFrame(Frame_LoadTag, client);
307302
}
@@ -327,7 +322,7 @@ public Action Cmd_ToggleTags(int client, int args)
327322
else
328323
{
329324
bHideTag[client] = true;
330-
CS_SetClientClanTag(client, "");
325+
CS_SetClientClanTag(client, sUserTag[client]);
331326
ReplyToCommand(client, "[SM] Your tags are no longer visible.");
332327
}
333328

@@ -387,9 +382,11 @@ public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
387382

388383
public Action RankMe_LoadTags(int client, int rank, any data)
389384
{
385+
Debug_Print("Callback load rankme-tags");
390386
if (IsValidClient(client, true, true))
391387
{
392388
iRank[client] = rank;
389+
Debug_Print("Callback valid rank %L - %i", client, rank);
393390
char sRank[16];
394391
IntToString(iRank[client], sRank, sizeof(sRank));
395392
ReplaceString(sTags[client][ScoreTag], sizeof(sTags[][]), "{rmRank}", sRank);
@@ -635,6 +632,7 @@ void LoadKv()
635632
SetFailState("Couldn't find: \"%s\"", sConfig); //Check if cfg exist
636633

637634
GetOrder(file);
635+
delete file;
638636
BuildPath(Path_SM, sConfig, sizeof(sConfig), "configs/hextags.cfg"); //Get cfg file
639637

640638
if (OpenFile(sConfig, "rt") == null)
@@ -968,6 +966,7 @@ void GetTags(int client, KeyValues kv, bool final = false)
968966
}
969967
if (bRankme && StrContains(sTags[client][ScoreTag], "{rmRank}") != -1)
970968
{
969+
Debug_Print("Contains rmRank");
971970
RankMe_GetRank(client, RankMe_LoadTags);
972971
}
973972

0 commit comments

Comments
 (0)