Код
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <biohazard>
#include <hamsandwich>
#include <fakemeta>
#define PLUGIN "BEI shield"
#define VERSION "1.0"
#define AUTHOR "Emilioneri"
new g_Cost
new const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
stock strip_primary_weapons( id )
{
if( !is_user_alive( id ) )
return
new i, szWeapons[ 32 ], iNum, iWeaponID
get_user_weapons( id, szWeapons, iNum )
for( i = 0; i < iNum; i++ )
{
iWeaponID = szWeapons[ i ]
if( ( 1 << iWeaponID ) & PRIMARY_WEAPONS_BIT_SUM )
{
new szWeaponName[ 32 ]
get_weaponname( iWeaponID, szWeaponName, charsmax( szWeaponName ) )
ham_strip_weapon( id, szWeaponName )
}
}
}
// http://amxxmodx.ru/poleznye_funkcii/351-ham_strip_weapon-funkciya-otbiraet-opredelennoe-oruzhie-u-igroka.html
stock ham_strip_weapon(id,weapon[])
{
if(!equal(weapon,"weapon_",7)) return 0
new wId = get_weaponid(weapon)
if(!wId) return 0
new wEnt
while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
if(!wEnt) return 0
if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)
if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0
ExecuteHamB(Ham_Item_Kill,wEnt);
set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId))
return 1
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
// Add your code here...
g_Cost = register_cvar("bio_shield_cost", "300")
register_clcmd("buyshield", "cmd_buyshield")
}
public cmd_buyshield(id)
{
if (!is_user_alive(id) || is_user_zombie(id))
{
client_print(id, print_center, "Недопустимая команда")
return PLUGIN_HANDLED
}
new iMoney = cs_get_user_money(id)
new iCost = get_pcvar_num(g_Cost)
if (iMoney >= iCost)
{
strip_primary_weapons(id)
give_item (id, "weapon_shield")
cs_set_user_money(id, iMoney - iCost)
return PLUGIN_HANDLED
}
else
{
client_print(id, print_center, "Недостаточно денег", iCost)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}