works with sm 6024 but spams error messages in log.
PHP Code:
#include <sourcemod>
#include <sdkhooks>
#pragma semicolon 1
#pragma newdecls required
bool PlayerIsAdmin[MAXPLAYERS+1];
public void OnClientPostAdminCheck(int client)
{
PlayerIsAdmin[client] = CheckCommandAccess(client, "allow_admin_weapon", ADMFLAG_ROOT);
SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
}
public void OnClientDisconnect(int client)
{
SDKUnhook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
}
public Action CS_OnBuyCommand(int client, const char[] weapon)
{
if (!IsClientInGame(client) || GetClientTeam(client) <= 1)
{
return Plugin_Continue;
}
if (!PlayerCanUseWeapon(client, weapon))
{
return Plugin_Handled;
}
return Plugin_Continue;
}
bool PlayerCanUseWeapon(int client, const char[] weapon)
{
if (StrEqual("weapon_g3sg1", weapon, false) || (StrEqual("weapon_scar20", weapon, false) && !PlayerIsAdmin[client]))
{
return false;
}
return true;
}
public Action OnWeaponCanUse(int client, int weapon)
{
char g_sWeapon[50];
GetEntityClassname(weapon, g_sWeapon, sizeof(g_sWeapon));
if (!PlayerCanUseWeapon(client, g_sWeapon))
{
return Plugin_Handled;
}
return Plugin_Continue;
}