Advertisement
Guest User

lol

a guest
Dec 3rd, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.44 KB | None | 0 0
  1. //includes
  2. #include <sourcemod>
  3. #include <sdktools>
  4. #include <cstrike>
  5. #include <clientprefs>
  6. #include <store>
  7.  
  8. //Compiler Options
  9. #pragma semicolon 1
  10. #pragma newdecls required
  11.  
  12. //ConVars
  13. ConVar gc_bPlugin;
  14. bool g_tag[MAXPLAYERS+1] = false;
  15. Handle cookie_tag;
  16.  
  17. ArrayList g_aClanTag;
  18.  
  19. public Plugin myinfo =
  20. {
  21.     name = "Admin & PlayerTags",
  22.     description = "Define player tags in stats with translation",
  23.     author = "shanapu",
  24.     version = "5.0",
  25.     url = "shanapu.de"
  26. }
  27.  
  28. public void OnPluginStart()
  29. {
  30.  
  31.     g_aClanTag = new ArrayList(PLATFORM_MAX_PATH);
  32.  
  33.     CreateConVar("sm_admintag_version", "5.0", "The version of this SourceMod plugin", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
  34.     gc_bPlugin = CreateConVar("sm_admintag_enable", "1", "0 - disabled, 1 - enable this SourceMod plugin", _, true,  0.0, true, 1.0);
  35.    
  36.     RegAdminCmd("sm_tag", escondertag, ADMFLAG_CUSTOM1);
  37.     cookie_tag = RegClientCookie("tag cookie", "tag_state" , CookieAccess_Public);
  38.    
  39.     Store_RegisterHandler("clantag", "clantag", ClanTag_OnMapStart, ClanTag_Reset, ClanTag_Config, ClanTag_Equip, ClanTag_Remove, true);
  40.    
  41.     //Hooks
  42.     HookEvent("player_connect", checkTag);
  43.     HookEvent("player_team", checkTag);
  44.     HookEvent("player_spawn", checkTag);
  45.     HookEvent("round_start", checkTag);
  46.     HookEvent("round_end", checkTag);
  47.  
  48. }
  49.  
  50. public void ClanTag_OnMapStart()
  51. {
  52.    
  53. }
  54.  
  55. public void OnClientPutInServer(int client)
  56. {
  57.     HandleTag(client);
  58.     return;
  59. }
  60.  
  61. public void OnClientCookiesCached(int client)
  62. {
  63.     char cookie[5];
  64.     GetClientCookie(client, cookie_tag, cookie, sizeof(cookie));
  65.     if(StringToInt(cookie) == 0)
  66.     {
  67.         g_tag[client] = false;
  68.     }
  69.     if(StringToInt(cookie) == 1)
  70.     {
  71.         g_tag[client] = true;
  72.     }
  73. }
  74.  
  75. public int ClanTag_Remove(int client, int itemid)
  76. {
  77.     return g_aClanTag.Get(Store_GetDataIndex(itemid));
  78. }
  79.  
  80. public void ClanTag_Reset()
  81. {
  82.     g_aClanTag.Clear();
  83. }
  84.  
  85. public bool ClanTag_Config(Handle &kv, int itemid)
  86. {
  87.     char sClanTag[PLATFORM_MAX_PATH];
  88.     KvGetString(kv, "nome_clantag", sClanTag, sizeof(sClanTag));
  89.     Store_SetDataIndex(itemid, g_aClanTag.PushString(sClanTag));
  90.     return true;
  91. }
  92.  
  93. public int ClanTag_Equip(int client, int itemid)
  94. {
  95.    
  96.     int iIndex = Store_GetDataIndex(itemid);
  97.    
  98.     char sClanTag[PLATFORM_MAX_PATH];
  99.     g_aClanTag.GetString(iIndex, sClanTag, sizeof(sClanTag));
  100.     DataPack pack = new DataPack();
  101.     pack.WriteCell(GetClientUserId(client));
  102.     pack.WriteString(sClanTag);
  103.     CS_SetClientClanTag(client, sClanTag);
  104.     return g_aClanTag.Get(iIndex);
  105. }
  106.  
  107. public Action escondertag(int client, int args)
  108. {
  109.     if (IsValidClient(client))
  110.     {
  111.         if (g_tag[client])
  112.         {
  113.             g_tag[client] = false;
  114.             PrintToChat(client, "[PT'Fun] A tua \x0BTag do Scoreboard\x01 foi \x04ativada\x01 com sucesso!");
  115.             PrintToChat(client, "[PT'Fun] Escreve \x0B!tag\x01 para a \x07desativares\x01!");
  116.             SetClientCookie(client, cookie_tag, "0");
  117.         }
  118.         else if (!(g_tag[client]))
  119.         {
  120.             g_tag[client] = true;
  121.             if (GetClientTeam(client) >= 2)
  122.             {
  123.                 CS_SetClientClanTag(client, "");
  124.             }
  125.             PrintToChat(client, "[PT'Fun] A tua \x0BTag do Scoreboard\x01 foi \x07desativada\x01 com sucesso!");
  126.             PrintToChat(client, "[PT'Fun] Escreve \x0B!tag\x01 para a \x04ativares\x01!");
  127.             SetClientCookie(client, cookie_tag, "1");
  128.         }
  129.     }
  130. }
  131.  
  132. public Action checkTag(Handle event, char[] name, bool dontBroadcast)
  133. {
  134.     int client = GetClientOfUserId(GetEventInt(event, "userid"));
  135.     int itemid = Store_GetEquippedItem(client, "clantag", 0);
  136.     if(itemid < 0)
  137.     {
  138.         CreateTimer(0.1, DelayCheck);
  139.     }
  140.    
  141.     return Action;
  142. }
  143.  
  144. public Action DelayCheck(Handle timer)
  145. {
  146.     int itemid;
  147.     for(int client = 1; client <= MaxClients; client++) if(IsClientInGame(client))
  148.     {
  149.         itemid = Store_GetEquippedItem(client, "clantag", 0);
  150.         if (itemid > 0)
  151.         {
  152.             int iIndex = Store_GetDataIndex(itemid);
  153.             char sClanTag[PLATFORM_MAX_PATH];
  154.             g_aClanTag.GetString(iIndex, sClanTag, sizeof(sClanTag));
  155.             DataPack pack = new DataPack();
  156.             pack.WriteCell(GetClientUserId(client));
  157.             pack.WriteString(sClanTag);
  158.             CS_SetClientClanTag(client, sClanTag);
  159.             return g_aClanTag.Get(iIndex);
  160.         }
  161.         else if(0 < client && itemid == 0)
  162.         {
  163.             HandleTag(client);
  164.         }
  165.     }
  166.     return Action;
  167. }
  168.  
  169. public int HandleTag(int client)
  170. {
  171.     if(gc_bPlugin.BoolValue)
  172.     {
  173.         char SteamID[255];
  174.         char tagsVIP[255], tagsADM[255], tagsHADM[255], tagsCADM[255];
  175.        
  176.         GetClientAuthId(client, AuthId_Steam3, SteamID, sizeof(SteamID), true);
  177.        
  178.         if (g_tag[client])
  179.         {
  180.             CS_SetClientClanTag(client, "");
  181.         }
  182.        
  183.         else if (GetUserFlagBits(client) & ADMFLAG_ROOT)
  184.         {
  185.             Format(tagsHADM, sizeof(tagsHADM), "PT'Fun Head-Adm", LANG_SERVER);
  186.             CS_SetClientClanTag(client, tagsHADM);
  187.         }
  188.        
  189.         else if (GetUserFlagBits(client) & ADMFLAG_UNBAN)
  190.         {
  191.             Format(tagsCADM, sizeof(tagsCADM), "PT'Fun Mod", LANG_SERVER);
  192.             CS_SetClientClanTag(client, tagsCADM);
  193.         }
  194.        
  195.         else if (GetUserFlagBits(client) & ADMFLAG_GENERIC)
  196.         {
  197.             Format(tagsADM, sizeof(tagsADM), "PT'Fun Admin", LANG_SERVER);
  198.             CS_SetClientClanTag(client, tagsADM);
  199.         }
  200.        
  201.         else if (GetUserFlagBits(client) & ADMFLAG_CUSTOM1)
  202.         {
  203.             Format(tagsVIP, sizeof(tagsVIP), "PT'Fun VIP", LANG_SERVER);
  204.             CS_SetClientClanTag(client, tagsVIP);
  205.         }
  206.        
  207.         else
  208.         {
  209.             CS_SetClientClanTag(client, "");
  210.         }
  211.     }
  212. }
  213.  
  214. stock bool IsValidClient( int client )
  215. {
  216.     if ( client < 1 || client > MaxClients ) return false;
  217.     if ( !IsClientConnected( client )) return false;
  218.     if ( !IsClientInGame( client )) return false;
  219.     return true;
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement