From 10f4cacd55098d6596ad49e86f9204f7ea19f29c Mon Sep 17 00:00:00 2001 From: BotoX Date: Sun, 26 Feb 2017 01:08:08 +0100 Subject: [PATCH] Add AdminIcon --- AdminIcon/scripting/AdminIcon.sp | 73 ++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 AdminIcon/scripting/AdminIcon.sp diff --git a/AdminIcon/scripting/AdminIcon.sp b/AdminIcon/scripting/AdminIcon.sp new file mode 100644 index 00000000..8e91798b --- /dev/null +++ b/AdminIcon/scripting/AdminIcon.sp @@ -0,0 +1,73 @@ +#pragma semicolon 1 +#pragma newdecls required + +#include +#include +#include + +bool g_bIsAdmin[MAXPLAYERS + 1] = {false, ...}; + +public Plugin myinfo = +{ + name = "AdminIcon", + author = "BotoX", + description = "Gives admins a defuser.", + version = "1.0", + url = "" +}; + +public void OnPluginStart() +{ + for(int client = 1; client <= MaxClients; client++) + { + g_bIsAdmin[client] = false; + if(IsClientInGame(client) && !IsFakeClient(client) && IsClientAuthorized(client)) + OnClientPostAdminCheck(client); + } +} + +public void OnClientConnected(int client) +{ + g_bIsAdmin[client] = false; +} + +public void OnClientDisconnect(int client) +{ + g_bIsAdmin[client] = false; +} + +public void OnClientPostAdminCheck(int client) +{ + if(IsFakeClient(client)) + return; + + if(GetAdminFlag(GetUserAdmin(client), Admin_Generic)) + g_bIsAdmin[client] = true; +} + +public void OnGameFrame() +{ + for(int client = 1; client <= MaxClients; client++) + { + if(g_bIsAdmin[client]) + { + if(IsClientObserver(client)) + SetEntProp(client, Prop_Send, "m_bHasDefuser", 0); + else + SetEntProp(client, Prop_Send, "m_bHasDefuser", 1); + } + } +} + +public void OnEntityCreated(int entity, const char[] classname) +{ + if(IsValidEntity(entity) && StrEqual(classname, "item_defuser")) + { + SDKHook(entity, SDKHook_Spawn, OnWeaponSpawned); + } +} + +public void OnWeaponSpawned(int entity) +{ + AcceptEntityInput(entity, "Kill"); +}