Код:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <zombieplague>
#define PLUGIN "[ZP] Choose the weapons survivor"
#define VERSION "1.6.1"
#define AUTHOR "alan_el_more"
#define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))
new const PRIMARY_NAMES[][] =
{
"MP5 Navy",
"M4A1 Carbine",
"AK-47 Kalashnikov",
"Steyr AUG A1",
"SG-552 Commando",
"M3 Super 90",
"XM1014 M4"
}
new const SECONDARY_NAMES[][] =
{
"",
"",
"",
"",
"",
"",
""
}
new const SECONDARY_ID[][] =
{
"",
"",
"",
"",
"",
"",
""
}
new const PRIMARY_ID[][] =
{
"weapon_mp5navy",
"weapon_m4a1",
"weapon_ak47",
"weapon_aug",
"weapon_sg552",
"weapon_m3",
"weapon_xm1014"
}
new pcvar, pcvar_secondary
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)
const PEV_ADDITIONAL_AMMO = pev_iuser1
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_dictionary("zp_choose_weapons_survivor.txt")
pcvar = register_cvar("zp_cws_enable", "1", FCVAR_SERVER)
pcvar_secondary = register_cvar("zp_cws_secondary", "1")
}
public mostrarmenu(id)
{
new menu = menu_create("\yВыберите оружие", "mostrar_cliente")
menu_additem(menu, "\rMP5 Navy", "0", 0)
menu_additem(menu, "\rM4A1 Carbine", "1", 0)
menu_additem(menu, "\rAK-47 Kalashnikov", "2", 0)
menu_additem(menu, "\rSteyr AUG A1", "3", 0)
menu_additem(menu, "\rSG-552 Commando", "4", 0)
menu_additem(menu, "\rM3 Super 90", "5", 0)
menu_additem(menu, "\rXM1014 M4", "6", 0)
menu_display(id, menu, 0)
}
public mostrar_cliente(id, menu, item)
{
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)
if(key == 7)
key = random_num(0, 7)
drop_weapons(id, 1)
fm_give_item(id, PRIMARY_ID[key])
ChatColor(id, "!g[ZP] !y%L: !g%s", id, "CHOOSE_WEAPON", PRIMARY_NAMES[key])
if(get_pcvar_num(pcvar_secondary))
mostrarmenu2(id)
menu_destroy(menu)
return PLUGIN_HANDLED
}
public mostrarmenu2(id)
{
}
public mostrar_cliente2(id, menu, item)
{
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)
if(key == 7)
key = random_num(0, 7)
drop_weapons(id, 2)
fm_give_item(id, SECONDARY_ID[key])
ChatColor(id, "!g[ZP] !y%L: !g%s", id, "CHOOSE_WEAPON", SECONDARY_NAMES[key])
menu_destroy(menu)
return PLUGIN_HANDLED
}
public zp_user_humanized_post(id)
{
if (zp_get_user_survivor(id) && get_pcvar_num(pcvar))
set_task(1.0, "mostrarmenu", id)
}
stock drop_weapons(id, dropwhat)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)
for (i = 0; i < num; i++)
{
weaponid = weapons[i]
if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
{
static wname[32], weapon_ent
get_weaponname(weaponid, wname, sizeof wname - 1)
weapon_ent = fm_find_ent_by_owner(-1, wname, id);
set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, cs_get_user_bpammo(id, weaponid))
engclient_cmd(id, "drop", wname)
cs_set_user_bpammo(id, weaponid, 0)
}
}
}
stock fm_give_item(index, const item[]) {
if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
return 0
new ent = fm_create_entity(item)
if (!pev_valid(ent))
return 0
new Float:origin[3]
pev(index, pev_origin, origin)
set_pev(ent, pev_origin, origin)
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
dllfunc(DLLFunc_Spawn, ent)
new save = pev(ent, pev_solid)
dllfunc(DLLFunc_Touch, ent, index)
if (pev(ent, pev_solid) != save)
return ent
engfunc(EngFunc_RemoveEntity, ent)
return -1
}
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) {}
return entity;
}
stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4")
replace_all(msg, 190, "!y", "^1")
replace_all(msg, 190, "!t", "^3")
if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}