View Single Post
asdfxD
Veteran Member
Join Date: Apr 2011
Old 08-20-2017 , 14:28   Re: My restrict plugin not working :(
Reply With Quote #8

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(clientSDKHook_WeaponCanUseOnWeaponCanUse);
}

public 
void OnClientDisconnect(int client)
{
    
SDKUnhook(clientSDKHook_WeaponCanUseOnWeaponCanUse);
}

public 
Action CS_OnBuyCommand(int client, const char[] weapon)
{
    if (!
IsClientInGame(client) || GetClientTeam(client) <= 1)
    {
        return 
Plugin_Continue;
    }

    if (!
PlayerCanUseWeapon(clientweapon))
    {
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;
}

bool PlayerCanUseWeapon(int client, const char[] weapon)
{
    if (
StrEqual("weapon_g3sg1"weaponfalse) || (StrEqual("weapon_scar20"weaponfalse) && !PlayerIsAdmin[client]))
    {
        return 
false;
    }
    
    return 
true;
}

public 
Action OnWeaponCanUse(int clientint weapon)
{
    
char g_sWeapon[50];
    
GetEntityClassname(weapong_sWeaponsizeof(g_sWeapon));    
    
    if (!
PlayerCanUseWeapon(clientg_sWeapon))
    {
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;


Last edited by asdfxD; 08-20-2017 at 14:34.
asdfxD is offline