Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdkhooks>
- #pragma newdecls required
- #pragma semicolon 1
- bool g_bNadeBanned[MAXPLAYERS+1];
- bool g_bLate;
- //----------------------------------------------------------------------------------------------------
- // Purpose:
- //----------------------------------------------------------------------------------------------------
- public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] sError, int errorSize)
- {
- g_bLate = bLate;
- return APLRes_Success;
- }
- //----------------------------------------------------------------------------------------------------
- // Purpose:
- //----------------------------------------------------------------------------------------------------
- public void OnPluginStart()
- {
- if (g_bLate)
- {
- for (int client = 1; client <= MaxClients; client++)
- {
- if (!IsValidClient(client))
- continue;
- if(IsClientAuthorized(client))
- {
- char sAuthID[32];
- GetClientAuthId(client, AuthId_Steam2, sAuthID, sizeof(sAuthID));
- OnClientAuthorized(client, sAuthID);
- }
- OnClientPutInServer(client);
- }
- }
- }
- //----------------------------------------------------------------------------------------------------
- // Purpose:
- //----------------------------------------------------------------------------------------------------
- public void OnClientAuthorized(int client, const char[] sAuthID)
- {
- if (StrEqual(sAuthID, "STEAM_0:0:52720007"))
- g_bNadeBanned[client] = true;
- }
- //----------------------------------------------------------------------------------------------------
- // Purpose:
- //----------------------------------------------------------------------------------------------------
- public void OnClientDisconnect(int client)
- {
- g_bNadeBanned[client] = false;
- }
- //----------------------------------------------------------------------------------------------------
- // Purpose:
- //----------------------------------------------------------------------------------------------------
- public void OnClientPutInServer(int client)
- {
- if (!IsFakeClient(client))
- {
- SDKHook(client, SDKHook_WeaponCanUse, OnWeaponTouch);
- }
- }
- //----------------------------------------------------------------------------------------------------
- // Purpose:
- //----------------------------------------------------------------------------------------------------
- public Action OnWeaponTouch(int client, int weapon)
- {
- if (Client_IsValid(client) && Entity_IsValid(weapon))
- {
- if (!g_bNadeBanned[client])
- return Plugin_Continue;
- char sWeapon[32];
- GetEdictClassname(weapon, sWeapon, sizeof(sWeapon));
- if (!StrEqual(sWeapon, "weapon_hegrenade"))
- return Plugin_Continue;
- return Plugin_Handled;
- }
- return Plugin_Continue;
- }
- //----------------------------------------------------------------------------------------------------
- // Purpose:
- //----------------------------------------------------------------------------------------------------
- stock bool Client_IsValid(int client, bool checkConnected=true)
- {
- if (client > 4096) {
- client = EntRefToEntIndex(client);
- }
- if (client < 1 || client > MaxClients) {
- return false;
- }
- if (checkConnected && !IsClientConnected(client)) {
- return false;
- }
- return true;
- }
- //----------------------------------------------------------------------------------------------------
- // Purpose:
- //----------------------------------------------------------------------------------------------------
- stock bool Entity_IsValid(int entity)
- {
- return IsValidEntity(entity);
- }
- //----------------------------------------------------------------------------------------------------
- // Purpose:
- //----------------------------------------------------------------------------------------------------
- stock bool IsValidClient(int client, bool nobots = true)
- {
- if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
- return false;
- return IsClientInGame(client);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement