Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //includes
- #include <sourcemod>
- #include <sdktools>
- #include <cstrike>
- #include <clientprefs>
- #include <store>
- //Compiler Options
- #pragma semicolon 1
- #pragma newdecls required
- //ConVars
- ConVar gc_bPlugin;
- bool g_tag[MAXPLAYERS+1] = false;
- Handle cookie_tag;
- ArrayList g_aClanTag;
- public Plugin myinfo =
- {
- name = "Admin & PlayerTags",
- description = "Define player tags in stats with translation",
- author = "shanapu",
- version = "5.0",
- url = "shanapu.de"
- }
- public void OnPluginStart()
- {
- g_aClanTag = new ArrayList(PLATFORM_MAX_PATH);
- CreateConVar("sm_admintag_version", "5.0", "The version of this SourceMod plugin", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
- gc_bPlugin = CreateConVar("sm_admintag_enable", "1", "0 - disabled, 1 - enable this SourceMod plugin", _, true, 0.0, true, 1.0);
- RegAdminCmd("sm_tag", escondertag, ADMFLAG_CUSTOM1);
- cookie_tag = RegClientCookie("tag cookie", "tag_state" , CookieAccess_Public);
- Store_RegisterHandler("clantag", "clantag", ClanTag_OnMapStart, ClanTag_Reset, ClanTag_Config, ClanTag_Equip, ClanTag_Remove, true);
- //Hooks
- HookEvent("player_connect", checkTag);
- HookEvent("player_team", checkTag);
- HookEvent("player_spawn", checkTag);
- HookEvent("round_start", checkTag);
- HookEvent("round_end", checkTag);
- }
- public void ClanTag_OnMapStart()
- {
- }
- public void OnClientPutInServer(int client)
- {
- HandleTag(client);
- return;
- }
- public void OnClientCookiesCached(int client)
- {
- char cookie[5];
- GetClientCookie(client, cookie_tag, cookie, sizeof(cookie));
- if(StringToInt(cookie) == 0)
- {
- g_tag[client] = false;
- }
- if(StringToInt(cookie) == 1)
- {
- g_tag[client] = true;
- }
- }
- public int ClanTag_Remove(int client, int itemid)
- {
- return g_aClanTag.Get(Store_GetDataIndex(itemid));
- }
- public void ClanTag_Reset()
- {
- g_aClanTag.Clear();
- }
- public bool ClanTag_Config(Handle &kv, int itemid)
- {
- char sClanTag[PLATFORM_MAX_PATH];
- KvGetString(kv, "nome_clantag", sClanTag, sizeof(sClanTag));
- Store_SetDataIndex(itemid, g_aClanTag.PushString(sClanTag));
- return true;
- }
- public int ClanTag_Equip(int client, int itemid)
- {
- int iIndex = Store_GetDataIndex(itemid);
- char sClanTag[PLATFORM_MAX_PATH];
- g_aClanTag.GetString(iIndex, sClanTag, sizeof(sClanTag));
- DataPack pack = new DataPack();
- pack.WriteCell(GetClientUserId(client));
- pack.WriteString(sClanTag);
- CS_SetClientClanTag(client, sClanTag);
- return g_aClanTag.Get(iIndex);
- }
- public Action escondertag(int client, int args)
- {
- if (IsValidClient(client))
- {
- if (g_tag[client])
- {
- g_tag[client] = false;
- PrintToChat(client, "[PT'Fun] A tua \x0BTag do Scoreboard\x01 foi \x04ativada\x01 com sucesso!");
- PrintToChat(client, "[PT'Fun] Escreve \x0B!tag\x01 para a \x07desativares\x01!");
- SetClientCookie(client, cookie_tag, "0");
- }
- else if (!(g_tag[client]))
- {
- g_tag[client] = true;
- if (GetClientTeam(client) >= 2)
- {
- CS_SetClientClanTag(client, "");
- }
- PrintToChat(client, "[PT'Fun] A tua \x0BTag do Scoreboard\x01 foi \x07desativada\x01 com sucesso!");
- PrintToChat(client, "[PT'Fun] Escreve \x0B!tag\x01 para a \x04ativares\x01!");
- SetClientCookie(client, cookie_tag, "1");
- }
- }
- }
- public Action checkTag(Handle event, char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"));
- int itemid = Store_GetEquippedItem(client, "clantag", 0);
- if(itemid < 0)
- {
- CreateTimer(0.1, DelayCheck);
- }
- return Action;
- }
- public Action DelayCheck(Handle timer)
- {
- int itemid;
- for(int client = 1; client <= MaxClients; client++) if(IsClientInGame(client))
- {
- itemid = Store_GetEquippedItem(client, "clantag", 0);
- if (itemid > 0)
- {
- int iIndex = Store_GetDataIndex(itemid);
- char sClanTag[PLATFORM_MAX_PATH];
- g_aClanTag.GetString(iIndex, sClanTag, sizeof(sClanTag));
- DataPack pack = new DataPack();
- pack.WriteCell(GetClientUserId(client));
- pack.WriteString(sClanTag);
- CS_SetClientClanTag(client, sClanTag);
- return g_aClanTag.Get(iIndex);
- }
- else if(0 < client && itemid == 0)
- {
- HandleTag(client);
- }
- }
- return Action;
- }
- public int HandleTag(int client)
- {
- if(gc_bPlugin.BoolValue)
- {
- char SteamID[255];
- char tagsVIP[255], tagsADM[255], tagsHADM[255], tagsCADM[255];
- GetClientAuthId(client, AuthId_Steam3, SteamID, sizeof(SteamID), true);
- if (g_tag[client])
- {
- CS_SetClientClanTag(client, "");
- }
- else if (GetUserFlagBits(client) & ADMFLAG_ROOT)
- {
- Format(tagsHADM, sizeof(tagsHADM), "PT'Fun Head-Adm", LANG_SERVER);
- CS_SetClientClanTag(client, tagsHADM);
- }
- else if (GetUserFlagBits(client) & ADMFLAG_UNBAN)
- {
- Format(tagsCADM, sizeof(tagsCADM), "PT'Fun Mod", LANG_SERVER);
- CS_SetClientClanTag(client, tagsCADM);
- }
- else if (GetUserFlagBits(client) & ADMFLAG_GENERIC)
- {
- Format(tagsADM, sizeof(tagsADM), "PT'Fun Admin", LANG_SERVER);
- CS_SetClientClanTag(client, tagsADM);
- }
- else if (GetUserFlagBits(client) & ADMFLAG_CUSTOM1)
- {
- Format(tagsVIP, sizeof(tagsVIP), "PT'Fun VIP", LANG_SERVER);
- CS_SetClientClanTag(client, tagsVIP);
- }
- else
- {
- CS_SetClientClanTag(client, "");
- }
- }
- }
- stock bool IsValidClient( int client )
- {
- if ( client < 1 || client > MaxClients ) return false;
- if ( !IsClientConnected( client )) return false;
- if ( !IsClientInGame( client )) return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement