Something like this might work - untested - it's SM1.7+ syntax - it's just for the weapon_m4a1 - edit that to what you want. And only admins who have the generic admin flag (or whatever you override the command "allow_admin_weapon" to)
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_GENERIC);
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_m4a1", 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;
}
__________________