Could anyone edit this code so it works for all snipers
The purpose of this plugin is to allow snipers only for VIPs (can't buy or pick...)
Weapons that should be included: id:
AWP (Magnum Sniper Rifle): CSW_AWP
Krieg 550 Commando: CSW_SG550
D3/AU-1: CSW_G3SG1
Thanks in advance!
Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#define VERSION "1.0.0"
#define MAX_PLAYERS 32
#define XO_WEAPONBOX 4
#define m_rgpPlayerItems_wpnbx_slot1 35
new g_iLastTouchedBox[MAX_PLAYERS+1]
public plugin_init()
{
register_plugin("Awp VIP", VERSION, "ConnorMcLeod")
RegisterHam(Ham_Spawn, "player", "Player_Spawn_Post", 1)
RegisterHam(Ham_Touch, "weaponbox", "WeaponBox_Touch")
register_menucmd(register_menuid("T_BuyRifle", 1), MENU_KEY_5, "BuyAwp")
register_menucmd(register_menuid("CT_BuyRifle", 1), MENU_KEY_6, "BuyAwp")
}
public client_putinserver(id)
{
g_iLastTouchedBox[id] = 0
}
public Player_Spawn_Post( id )
{
g_iLastTouchedBox[id] = 0
}
public WeaponBox_Touch(iWpnBx, id)
{
if( is_user_alive(id) && pev(iWpnBx, pev_flags) & FL_ONGROUND )
{
new iWeapon = get_pdata_cbase(iWpnBx, m_rgpPlayerItems_wpnbx_slot1, XO_WEAPONBOX)
if( iWeapon > 0 && cs_get_weapon_id(iWeapon) == CSW_AWP && !CanHaveAwp( id ) )
{
if( g_iLastTouchedBox[id] != iWpnBx )
{
if( !user_has_weapon(id, CSW_SCOUT) )
{
client_print(id, print_center, "#Cstrike_TitlesTXT_Cannot_Buy_This")
}
g_iLastTouchedBox[id] = iWpnBx
}
return HAM_SUPERCEDE
}
}
return HAM_IGNORED
}
public BuyAwp(id)
{
if( !CanHaveAwp( id ) )
{
client_print(id, print_center, "#Cstrike_TitlesTXT_Cannot_Buy_This")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public client_command(id)
{
static szCommand[8]
if( read_argv(0, szCommand, charsmax(szCommand)) < 7 )
{
return CheckArgAwp(id, szCommand)
}
return PLUGIN_CONTINUE
}
public CS_InternalCommand(id, const szCommand[])
{
return CheckArgAwp(id, szCommand)
}
CheckArgAwp(id, const szCommand[])
{
static const awp[] = "awp"
static const magnum[] = "magnum"
if( !CanHaveAwp( id )
&& ( equali(szCommand, awp) || equali(szCommand, magnum) ) )
{
client_print(id, print_center, "#Cstrike_TitlesTXT_Cannot_Buy_This")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
bool:CanHaveAwp( id )
{
return !!(get_user_flags(id) & ADMIN_LEVEL_H)
}
__________________