如果要在sma里面设定玩家掉下武器,应该写什么?
我的错误:
我的sma:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
public plugin_init()
{
register_plugin("BuyMenu", "0.1", "2012die day")
register_clcmd("buygun", "buygun")
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)
const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
}
public plugin_cfg()
{
new cfgdir[32]
get_configsdir(cfgdir, charsmax(cfgdir))
/*
server_cmd("exec %s/weapon.cfg", cfgdir)
*/
}
public buygun(id)
{
if(!is_user_alive(id))
{
client_print(id, print_center, "死了不能买枪!")
return PLUGIN_HANDLED
}
if(!cs_get_user_buyzone(id))
{
client_print(id, print_center, "你要在购物区才能买!")
return PLUGIN_HANDLED
}
show_buymenu(id)
return PLUGIN_HANDLED
}
public show_buymenu(id)
{
new menu = menu_create("\y购买枪械 : ", "buymenu_handler")
menu_additem(menu, "\w手枪", "1", 0)
menu_additem(menu, "\w散弹枪", "2", 0)
menu_additem(menu, "\w冲锋枪", "3", 0)
menu_additem(menu, "\w自动步枪", "4", 0)
menu_additem(menu, "\w机关枪", "5", 0)
menu_additem(menu, "\w其他武器", "6", 0)
menu_additem(menu, "\w装备^n ", "7", 0)
menu_additem(menu, "\w购买主武器子弹", "8", 0)
menu_additem(menu, "\w购买副武器子弹", "9", 0)
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, menu, 0)
}
public buymenu_handler(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new access, callback
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
new key = str_to_num(data)
switch(key)
{
case 1:
{
cmd_111(id)
menu_destroy(menu)
return PLUGIN_HANDLED
}
case 2:{
cmd_222(id)
menu_destroy(menu)
return PLUGIN_HANDLED
}
case 3:{
cmd_333(id)
... ...(消失)
stock drop_weapons(id, dropwhat) // dropwhat: 1 = primary weapon , 2 = secondary weapon
{
// Get user weapons
static weapons[32], num, i, weaponid
num = 0 // reset passed weapons count (bugfix)
get_user_weapons(id, weapons, num)
// Loop through them and drop primaries or secondaries
for (i = 0; i < num; i++)
{
// Prevent re-indexing the array
weaponid = weapons
if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
{
// Get weapon name
static wname[32]
get_weaponname(weaponid, wname, charsmax(wname))
// Drop weapon
engclient_cmd(id, "drop", wname)
}
}
}