Здравствуйте, помогите пожалуйста! Я пытаюсь поменять оружие в меню привилегии. Переписываю native, добавляю оружие в плагины меняю карту или перезапускаю, а он выключается и не включается
Меню випа
1 оружие
2 оружие
Меню випа
Код:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <fun>
#include <zombieplague>
#include <menu_button>
new g_item1[33], g_item2[33], g_item3[33], g_item4[33], g_item5[33]
native give_weapon_sfgun(id)
native give_weapon_buffm4(id)
#define MENU_OFF "BuB9neC/off.wav"
#define MAX_CLIENTS 32
new gl_vhook[MAX_CLIENTS + 1];
const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
new g_iGlobalka;
public plugin_init()
{
register_plugin ("[ZP] VIP menu", "1.2" , "NoNameNPC edited" )
register_menu("X Menu", KEYSMENU, "menu_main")
register_clcmd("vip_menu", "bog_menu")
register_dictionary("zombie_plague.txt")
register_logevent("fw_new_round", 2, "1=Round_Start")
g_iGlobalka = get_maxplayers()
}
public plugin_precache()
{
precache_sound(MENU_OFF)
}
public bog_menu(id)
{
static menu[512], userflags
new len
userflags = get_user_flags(id)
if(userflags & ADMIN_LEVEL_H)
{
len += formatex(menu[len], charsmax(menu) - len, "%s %L", UTIL_MenuButton(), id, "ZP_SERVER_NAME")
len += formatex(menu[len], charsmax(menu) - len, "\r[\y#\r] \wМеню випа^n")
if(g_item1[id] == 0)
len += formatex(menu[len] , charsmax(menu) - len , "\r[\y1\r] \r[\wВзять\r]\y Blaster SFGUN^n" )
else len += formatex(menu[len] , charsmax(menu) - len , "\r[\y1\r] \d[Взять] Blaster SFGUN^n^n" )
if(g_item2[id] == 0)
len += formatex(menu[len] , charsmax(menu) - len , "\r[\y2\r] \r[\wВзять\r]\y M4A1 Dark Knight^n^n" )
else len += formatex(menu[len] , charsmax(menu) - len , "\r[\y2\r] \d[Взять] M4A1 Dark Knight^n^n" )
if(g_item3[id] == 0)
len += formatex(menu[len] , charsmax(menu) - len , "\r[\y3\r] \wВзять \r(\y+100\r) \wЗвезд^n" )
else len += formatex(menu[len] , charsmax(menu) - len , "\r[\y3\r] \dВзять (+100) Звезд^n" )
if(g_item4[id] == 0)
len += formatex(menu[len] , charsmax(menu) - len , "\r[\y4\r] \wВзять \r(\y+100\r) \wБрони^n" )
else len += formatex(menu[len] , charsmax(menu) - len , "\r[\y4\r] \dВзять (+100) Брони^n" )
if(g_item5[id] == 0)
len += formatex(menu[len] , charsmax(menu) - len , "\r[\y5\r] \wВзять \r(\y+100\r) \wЖизней^n^n" )
else len += formatex(menu[len] , charsmax(menu) - len , "\r[\y5\r] \dВзять (+100) Жизней^n^n" )
len += formatex(menu[len] , charsmax(menu) - len , "^n\r[\y0\r] \wВыход" )
}
else
{
len += formatex(menu[len], charsmax(menu) - len, "%s %L", UTIL_MenuButton(), id, "ZP_SERVER_NAME")
len += formatex(menu[len], charsmax(menu) - len, "\r[\y#\r] \wМеню випа^n")
len += formatex(menu[len] , charsmax(menu) - len , "\r[\y1\r] \d[Взять] Blaster SFGUN^n" )
len += formatex(menu[len] , charsmax(menu) - len , "\r[\y2\r] \d[Взять] M4A1 Dark Knight^n^n" )
len += formatex(menu[len] , charsmax(menu) - len , "\r[\y3\r] \d[Взять] (+100) Звезд^n" )
len += formatex(menu[len] , charsmax(menu) - len , "\r[\y4\r] \d[Взять] (+100) Брони^n" )
len += formatex(menu[len] , charsmax(menu) - len , "\r[\y5\r] \d[Взять] (+100) Жизней^n^n" )
len += formatex(menu[len] , charsmax(menu) - len , "^n\r[\y0\r] \wВыход" )
len += formatex(menu[len] , charsmax(menu) - len,"^n\yВы не \rвип\y игрок!")
}
set_pdata_int(id , 205 , 0 )
show_menu(id, KEYSMENU , menu , -1 , "X Menu" )
}
public menu_main(id,key)
{
if (!is_user_connected(id))
return PLUGIN_HANDLED;
static userflags
userflags = get_user_flags(id)
if(!(userflags & ADMIN_LEVEL_H))
{
client_cmd(id, "spk ^"%s^"", MENU_OFF)
ChatColor(id, "!g[%L]!y Вы не !tВип !yигрок. Приобрести можно в !tВК: !g%L", id, "GRUPPA", id, "GRUPPA")
return 1
}
else if(!is_user_alive(id))
{
client_cmd(id, "spk ^"%s^"", MENU_OFF)
ChatColor(id, "!g[%L]!y Недоступно для мертвых.", id, "GRUPPA")
return 1
}
switch (key)
{
case 0:
{
if(!is_user_connected(id))
return PLUGIN_HANDLED;
else if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
{
ChatColor(id, "!g[%L]!y Доступно только !tЛюдям!y.", id, "GRUPPA")
return PLUGIN_HANDLED;
}
else if(g_item1[id] == 0)
{
g_item1[id] = 1;
give_weapon_sfgun(id);
}
else
{
client_cmd(id, "spk ^"%s^"", MENU_OFF)
ChatColor(id, "!g[%L]!y Можно брать только раз за раунд.", id, "GRUPPA");
return PLUGIN_HANDLED;
}
}
case 1:
{
if(!is_user_connected(id))
return PLUGIN_HANDLED;
else if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
{
ChatColor(id, "!g[%L]!y Доступно только !tЛюдям!y.", id, "GRUPPA")
return PLUGIN_HANDLED;
}
else if(g_item2[id] == 0)
{
g_item2[id] = 1;
give_weapon_buffm4(id);
}
else
{
client_cmd(id, "spk ^"%s^"", MENU_OFF)
ChatColor(id, "!g[%L]!y Можно брать только раз за раунд.", id, "GRUPPA");
return PLUGIN_HANDLED;
}
}
case 2:
{
if(!is_user_connected(id))
return PLUGIN_HANDLED;
else if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
{
ChatColor(id, "!g[%L]!y Доступно только !tЛюдям!y.", id, "GRUPPA")
return PLUGIN_HANDLED;
}
else if(g_item3[id] == 0)
{
g_item3[id] = 1;
zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + 100);
bog_menu(id)
}
else
{
client_cmd(id, "spk ^"%s^"", MENU_OFF)
ChatColor(id, "!g[%L]!y Можно брать только раз за раунд.", id, "GRUPPA");
return PLUGIN_HANDLED;
}
}
case 3:
{
if(!is_user_connected(id))
return PLUGIN_HANDLED;
else if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
{
ChatColor(id, "!g[%L]!y Доступно только !tЛюдям!y.", id, "GRUPPA")
return PLUGIN_HANDLED;
}
else if(g_item4[id] == 0)
{
g_item4[id] = 1;
set_pev(id, pev_armorvalue, pev(id, pev_armorvalue) + 100.0);
bog_menu(id)
}
else
{
client_cmd(id, "spk ^"%s^"", MENU_OFF)
ChatColor(id, "!g[%L]!y Можно брать только раз за раунд.", id, "GRUPPA");
return PLUGIN_HANDLED;
}
}
case 4:
{
if(!is_user_connected(id))
return PLUGIN_HANDLED;
else if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
{
ChatColor(id, "!g[%L]!y Доступно только !tЛюдям!y.", id, "GRUPPA")
return PLUGIN_HANDLED;
}
else if(g_item5[id] == 0)
{
g_item5[id] = 1;
set_pev(id, pev_health, pev(id, pev_health) + 100.0);
bog_menu(id)
}
else
{
client_cmd(id, "spk ^"%s^"", MENU_OFF)
ChatColor(id, "!g[%L]!y Можно брать только раз за раунд.", id, "GRUPPA");
return PLUGIN_HANDLED;
}
}
}
return PLUGIN_HANDLED;
}
public plugin_natives()
{
register_native("GetVHook", "func_GetVHook", 1);
}
public func_GetVHook(iPlayer)
return gl_vhook[iPlayer];
public fw_new_round()
{
for(new id = 1; id <= g_iGlobalka; id++)
{
if(g_item1[id] > 0)
{
g_item1[id] -= 1
}
if(g_item2[id] > 0)
{
g_item2[id] -= 1
}
if(g_item3[id] > 0)
{
g_item3[id] -= 1
}
if(g_item4[id] > 0)
{
g_item4[id] -= 1
}
if(g_item5[id] > 0)
{
g_item5[id] -= 1
}
}
}
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();
}
}
}
}
Код:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <xs>
#include <cstrike>
#include <zombieplague>
#define ENG_NULLENT -1
#define EV_INT_WEAPONKEY EV_INT_impulse
#define sfgun_WEAPONKEY 861
#define MAX_PLAYERS 32
#define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)
const USE_STOPPED = 0
const OFFSET_ACTIVE_ITEM = 373
const OFFSET_WEAPONOWNER = 41
const OFFSET_LINUX = 5
const OFFSET_LINUX_WEAPONS = 4
#define WEAP_LINUX_XTRA_OFF 4
#define m_fKnown 44
#define m_flNextPrimaryAttack 46
#define m_flTimeWeaponIdle 48
#define m_iClip 51
#define m_fInReload 54
#define PLAYER_LINUX_XTRA_OFF 5
#define m_flNextAttack 83
#define sfgun_RELOAD_TIME 3.0
#define sfgun_RELOAD 1
#define sfgun_DRAW 2
#define sfgun_SHOOT1 3
#define sfgun_SHOOT2 4
#define write_coord_f(%1) engfunc(EngFunc_WriteCoord,%1)
new const Fire_Sounds[][] = { "weapons/sfgun_shoot1.wav" }
new sfgun_V_MODEL[64] = "models/v_sfgun.mdl"
new sfgun_P_MODEL[64] = "models/p_sfgun.mdl"
new sfgun_W_MODEL[64] = "models/w_sfgun.mdl"
new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }
new cvar_dmg_sfgun, cvar_recoil_sfgun, g_itemid_sfgun, cvar_clip_sfgun, cvar_spd_sfgun, cvar_sfgun_ammo
new g_MaxPlayers, g_orig_event_sfgun, g_IsInPrimaryAttack
new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
new g_has_sfgun[33], g_clip_ammo[33], g_sfgun_TmpClip[33], oldweap[33]
new gmsgWeaponList
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)
new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
"weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
"weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
"weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
"weapon_ak47", "weapon_knife", "weapon_p90" }
public plugin_init()
{
register_plugin("[ZP] Extra: Blaster [SFGUN]", "1.0", "Crock / =) (Poprogun4ik) / TeRKe")
register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
register_event("CurWeapon","CurrentWeapon","be","1=1")
RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_sfgun_AddToPlayer")
RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_sfgun_PrimaryAttack")
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_sfgun_PrimaryAttack_Post", 1)
RegisterHam(Ham_Item_PostFrame, "weapon_mp5navy", "sfgun_ItemPostFrame")
RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "sfgun_Reload")
RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "sfgun_Reload_Post", 1)
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
register_forward(FM_SetModel, "fw_SetModel")
register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)
cvar_dmg_sfgun = register_cvar("zp_sfgun_dmg", "11")
cvar_recoil_sfgun = register_cvar("zp_sfgun_recoil", "1.0")
cvar_clip_sfgun = register_cvar("zp_sfgun_clip", "45")
cvar_spd_sfgun = register_cvar("zp_sfgun_spd", "1.0")
cvar_sfgun_ammo = register_cvar("zp_sfgun_ammo", "200")
g_itemid_sfgun = zp_register_extra_item("[Automat] \rBlaster SFGUN", 6, ZP_TEAM_HUMAN)
g_MaxPlayers = get_maxplayers()
gmsgWeaponList = get_user_msgid("WeaponList")
}
public plugin_precache()
{
precache_model(sfgun_V_MODEL)
precache_model(sfgun_P_MODEL)
precache_model(sfgun_W_MODEL)
for(new i = 0; i < sizeof Fire_Sounds; i++)
precache_sound(Fire_Sounds[i])
precache_sound("weapons/sfgun_clipin.wav")
precache_sound("weapons/sfgun_clipout.wav")
precache_sound("weapons/sfgun_draw.wav")
m_iBlood[0] = precache_model("sprites/blood.spr")
m_iBlood[1] = precache_model("sprites/bloodspray.spr")
precache_generic("sprites/weapon_sfgun.txt")
precache_generic("sprites/640hud58.spr")
register_clcmd("weapon_sfgun", "weapon_hook")
register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
}
public weapon_hook(id)
{
engclient_cmd(id, "weapon_mp5navy")
return PLUGIN_HANDLED
}
public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType)
{
if(!is_user_alive(iAttacker))
return
new g_currentweapon = get_user_weapon(iAttacker)
if(g_currentweapon != CSW_MP5NAVY) return
if(!g_has_sfgun[iAttacker]) return
static Float:flEnd[3]
get_tr2(ptr, TR_vecEndPos, flEnd)
if(iEnt)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_DECAL)
write_coord_f(flEnd[0])
write_coord_f(flEnd[1])
write_coord_f(flEnd[2])
write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
write_short(iEnt)
message_end()
}
else
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_WORLDDECAL)
write_coord_f(flEnd[0])
write_coord_f(flEnd[1])
write_coord_f(flEnd[2])
write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
message_end()
}
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_GUNSHOTDECAL)
write_coord_f(flEnd[0])
write_coord_f(flEnd[1])
write_coord_f(flEnd[2])
write_short(iAttacker)
write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)])
message_end()
}
public zp_user_humanized_post(id)
{
g_has_sfgun[id] = false
}
public plugin_natives ()
{
register_native("give_weapon_sfgun", "native_give_weapon_add", 1)
}
public native_give_weapon_add(id)
{
give_sfgun(id)
}
public fwPrecacheEvent_Post(type, const name[])
{
if (equal("events/mp5n.sc", name))
{
g_orig_event_sfgun = get_orig_retval()
return FMRES_HANDLED
}
return FMRES_IGNORED
}
public client_connect(id)
{
g_has_sfgun[id] = false
}
public client_disconnect(id)
{
g_has_sfgun[id] = false
}
public zp_user_infected_post(id)
{
if (zp_get_user_zombie(id))
{
g_has_sfgun[id] = false
}
}
public fw_SetModel(entity, model[])
{
if(!is_valid_ent(entity))
return FMRES_IGNORED
static szClassName[33]
entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
if(!equal(szClassName, "weaponbox"))
return FMRES_IGNORED
static iOwner
iOwner = entity_get_edict(entity, EV_ENT_owner)
if(equal(model, "models/w_mp5.mdl"))
{
static iStoredAugID
iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_mp5navy", entity)
if(!is_valid_ent(iStoredAugID))
return FMRES_IGNORED
if(g_has_sfgun[iOwner])
{
entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, sfgun_WEAPONKEY)
g_has_sfgun[iOwner] = false
entity_set_model(entity, sfgun_W_MODEL)
return FMRES_SUPERCEDE
}
}
return FMRES_IGNORED
}
public give_sfgun(id)
{
drop_weapons(id, 1)
new iWep2 = give_item(id,"weapon_mp5navy")
if( iWep2 > 0 )
{
cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_sfgun))
cs_set_user_bpammo (id, CSW_MP5NAVY, get_pcvar_num(cvar_sfgun_ammo))
UTIL_PlayWeaponAnimation(id, sfgun_DRAW)
set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
message_begin(MSG_ONE, gmsgWeaponList, _, id)
write_string("weapon_sfgun")
write_byte(10)
write_byte(120)
write_byte(-1)
write_byte(-1)
write_byte(0)
write_byte(7)
write_byte(CSW_MP5NAVY)
message_end()
}
g_has_sfgun[id] = true
}
public zp_extra_item_selected(id, itemid)
{
if(itemid != g_itemid_sfgun)
return
give_sfgun(id)
}
public fw_sfgun_AddToPlayer(sfgun, id)
{
if(!is_valid_ent(sfgun) || !is_user_connected(id))
return HAM_IGNORED
if(entity_get_int(sfgun, EV_INT_WEAPONKEY) == sfgun_WEAPONKEY)
{
g_has_sfgun[id] = true
entity_set_int(sfgun, EV_INT_WEAPONKEY, 0)
message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
write_string("weapon_sfgun")
write_byte(10)
write_byte(120)
write_byte(-1)
write_byte(-1)
write_byte(0)
write_byte(7)
write_byte(CSW_MP5NAVY)
message_end()
return HAM_HANDLED
}
else
{
message_begin(MSG_ONE, gmsgWeaponList, {0,0,0}, id)
write_string("weapon_mp5navy")
write_byte(10)
write_byte(120)
write_byte(-1)
write_byte(-1)
write_byte(0)
write_byte(7)
write_byte(CSW_MP5NAVY)
message_end()
}
return HAM_IGNORED
}
public fw_UseStationary_Post(entity, caller, activator, use_type)
{
if (use_type == USE_STOPPED && is_user_connected(caller))
replace_weapon_models(caller, get_user_weapon(caller))
}
public fw_Item_Deploy_Post(weapon_ent)
{
static owner
owner = fm_cs_get_weapon_ent_owner(weapon_ent)
static weaponid
weaponid = cs_get_weapon_id(weapon_ent)
replace_weapon_models(owner, weaponid)
}
public CurrentWeapon(id)
{
replace_weapon_models(id, read_data(2))
if(read_data(2) != CSW_MP5NAVY || !g_has_sfgun[id])
return
static Float:iSpeed
if(g_has_sfgun[id])
iSpeed = get_pcvar_float(cvar_spd_sfgun)
static weapon[32],Ent
get_weaponname(read_data(2),weapon,31)
Ent = find_ent_by_owner(-1,weapon,id)
if(Ent)
{
static Float:Delay
Delay = get_pdata_float( Ent, 46, 4) * iSpeed
if (Delay > 0.0)
{
set_pdata_float(Ent, 46, Delay, 4)
}
}
}
replace_weapon_models(id, weaponid)
{
switch (weaponid)
{
case CSW_MP5NAVY:
{
if (zp_get_user_zombie(id) || zp_get_user_survivor(id))
return
if(g_has_sfgun[id])
{
set_pev(id, pev_viewmodel2, sfgun_V_MODEL)
set_pev(id, pev_weaponmodel2, sfgun_P_MODEL)
if(oldweap[id] != CSW_MP5NAVY)
{
UTIL_PlayWeaponAnimation(id, sfgun_DRAW)
set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
message_begin(MSG_ONE, gmsgWeaponList, _, id)
write_string("weapon_sfgun")
write_byte(10)
write_byte(120)
write_byte(-1)
write_byte(-1)
write_byte(0)
write_byte(7)
write_byte(CSW_MP5NAVY)
message_end()
}
}
}
}
oldweap[id] = weaponid
}
public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)
{
if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_MP5NAVY || !g_has_sfgun[Player]))
return FMRES_IGNORED
set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
return FMRES_HANDLED
}
public fw_sfgun_PrimaryAttack(Weapon)
{
new Player = get_pdata_cbase(Weapon, 41, 4)
if (!g_has_sfgun[Player])
return
g_IsInPrimaryAttack = 1
pev(Player,pev_punchangle,cl_pushangle[Player])
g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
}
public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
if ((eventid != g_orig_event_sfgun) || !g_IsInPrimaryAttack)
return FMRES_IGNORED
if (!(1 <= invoker <= g_MaxPlayers))
return FMRES_IGNORED
playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
return FMRES_SUPERCEDE
}
public fw_sfgun_PrimaryAttack_Post(Weapon)
{
g_IsInPrimaryAttack = 0
new Player = get_pdata_cbase(Weapon, 41, 4)
new szClip, szAmmo
get_user_weapon(Player, szClip, szAmmo)
if(!is_user_alive(Player))
return
if(g_has_sfgun[Player])
{
if (!g_clip_ammo[Player])
return
new Float:push[3]
pev(Player,pev_punchangle,push)
xs_vec_sub(push,cl_pushangle[Player],push)
xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil_sfgun),push)
xs_vec_add(push,cl_pushangle[Player],push)
set_pev(Player,pev_punchangle,push)
emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
UTIL_PlayWeaponAnimation(Player, random_num(sfgun_SHOOT1, sfgun_SHOOT2))
}
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
if (victim != attacker && is_user_connected(attacker))
{
if(get_user_weapon(attacker) == CSW_MP5NAVY)
{
if(g_has_sfgun[attacker])
SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_sfgun))
}
}
}
public message_DeathMsg(msg_id, msg_dest, id)
{
static szTruncatedWeapon[33], iAttacker, iVictim
get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
iAttacker = get_msg_arg_int(1)
iVictim = get_msg_arg_int(2)
if(!is_user_connected(iAttacker) || iAttacker == iVictim)
return PLUGIN_CONTINUE
if(equal(szTruncatedWeapon, "mp5navy") && get_user_weapon(iAttacker) == CSW_MP5NAVY)
{
if(g_has_sfgun[iAttacker])
set_msg_arg_string(4, "mp5navy")
}
return PLUGIN_CONTINUE
}
stock fm_cs_get_current_weapon_ent(id)
{
return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
}
stock fm_cs_get_weapon_ent_owner(ent)
{
return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
}
stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
{
set_pev(Player, pev_weaponanim, Sequence)
message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
write_byte(Sequence)
write_byte(pev(Player, pev_body))
message_end()
}
public sfgun_ItemPostFrame(weapon_entity)
{
new id = pev(weapon_entity, pev_owner)
if (!is_user_connected(id))
return HAM_IGNORED
if (!g_has_sfgun[id])
return HAM_IGNORED
static iClipExtra
iClipExtra = get_pcvar_num(cvar_clip_sfgun)
new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)
new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY)
new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF)
if( fInReload && flNextAttack <= 0.0 )
{
new j = min(iClipExtra - iClip, iBpAmmo)
set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
cs_set_user_bpammo(id, CSW_MP5NAVY, iBpAmmo-j)
set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
fInReload = 0
}
return HAM_IGNORED
}
public sfgun_Reload(weapon_entity)
{
new id = pev(weapon_entity, pev_owner)
if (!is_user_connected(id))
return HAM_IGNORED
if (!g_has_sfgun[id])
return HAM_IGNORED
static iClipExtra
if(g_has_sfgun[id])
iClipExtra = get_pcvar_num(cvar_clip_sfgun)
g_sfgun_TmpClip[id] = -1
new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY)
new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)
if (iBpAmmo <= 0)
return HAM_SUPERCEDE
if (iClip >= iClipExtra)
return HAM_SUPERCEDE
g_sfgun_TmpClip[id] = iClip
return HAM_IGNORED
}
public sfgun_Reload_Post(weapon_entity)
{
new id = pev(weapon_entity, pev_owner)
if (!is_user_connected(id))
return HAM_IGNORED
if (!g_has_sfgun[id])
return HAM_IGNORED
if (g_sfgun_TmpClip[id] == -1)
return HAM_IGNORED
set_pdata_int(weapon_entity, m_iClip, g_sfgun_TmpClip[id], WEAP_LINUX_XTRA_OFF)
set_pdata_float(weapon_entity, m_flTimeWeaponIdle, sfgun_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)
set_pdata_float(id, m_flNextAttack, sfgun_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)
set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)
UTIL_PlayWeaponAnimation(id, sfgun_RELOAD)
return HAM_IGNORED
}
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))
{
static wname[32]
get_weaponname(weaponid, wname, sizeof wname - 1)
engclient_cmd(id, "drop", wname)
}
}
}
Код:
#include <amxmodx>
#include <fakemeta_util>
#include <hamsandwich>
#include <zombieplague>
#define PLUGIN "[CSO] Weapon: M4A1 Dark Knight"
#define VERSION "1.0"
#define AUTHOR "Base: Batcon; ReEdit: t3rkecorejz"
#define CustomItem(%0) (pev(%0, pev_impulse) == WEAPON_SPECIAL_CODE)
// CWeaponBox
#define m_rgpPlayerItems_CWeaponBox 34
// CBasePlayerItem
#define m_pPlayer 41
#define m_pNext 42
#define m_iId 43
// CBasePlayerWeapon
#define m_flNextPrimaryAttack 46
#define m_flNextSecondaryAttack 47
#define m_flTimeWeaponIdle 48
#define m_iPrimaryAmmoType 49
#define m_iClip 51
#define m_fInReload 54
#define m_iWeaponState 74
// CBaseMonster
#define m_flNextAttack 83
// CBasePlayer
#define m_iFOV 363
#define m_rpgPlayerItems 367
#define m_pActiveItem 373
#define m_rgAmmo 376
#define ANIM_IDLE 0
#define ANIM_ATTACK random_num(3,4)
#define ANIM_ATTACK_SE 5
#define ANIM_RELOAD 1
#define ANIM_DRAW 2
#define ANIM_IDLE_TIME 1.7
#define ANIM_RELOAD_TIME 1.94
#define ANIM_DRAW_TIME 1.04
#define WEAPON_SPECIAL_CODE 510
#define WEAPON_CSW CSW_GALIL
#define WEAPON_REFERENCE "weapon_galil"
#define WEAPON_NEW_NAME "x-cso/weapon_buffm4"
#define WEAPON_HUD "sprites/x-cso/640hud132.spr"
#define WEAPON_HUD_AMMO "sprites/x-cso/640hud7.spr"
#define WEAPON_ITEM_NAME "M4A1 Dark Knight"
#define WEAPON_ITEM_COST 0
#define WEAPON_MODEL_VIEW "models/x-cso/v_buffm4.mdl"
#define WEAPON_MODEL_PLAYER "models/x-cso/p_buffm4.mdl"
#define WEAPON_MODEL_WORLD "models/x-cso/w_buffm4.mdl"
#define WEAPON_SOUND_SHOOT "weapons/m4a1buff-1.wav"
#define WEAPON_SOUND_SHOOTE "weapons/m4a1buff-2.wav"
#define WEAPON_BODY 0
#define WEAPON_MAX_CLIP 50
#define WEAPON_DEFAULT_AMMO 150
#define WEAPON_RATE 0.1
#define WEAPON_RATE_EX 0.2
#define WEAPON_PUNCHAGNLE 0.6
#define WEAPON_PUNCHAGNLE_EX 0.8
#define WEAPON_DAMAGE 2.0
#define WEAPON_DAMAGE_EX 3.0
new const iWeaponList[ ] = {
4, 90, -1, -1, 0, 17,14, 0 // weapon_galil
}
new g_AllocString_V, g_AllocString_P, g_AllocString_E
new HamHook:g_fw_TraceAttack[4]
new Float:g_flvecEndPos[3]
new g_iMsgID_Weaponlist
new iSpriteIndexTrail
new g_iItemID
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
RegisterHam(Ham_Item_Deploy, WEAPON_REFERENCE, "fw_Item_Deploy_Post", 1);
RegisterHam(Ham_Item_PostFrame, WEAPON_REFERENCE, "fw_Item_PostFrame");
RegisterHam(Ham_Item_AddToPlayer, WEAPON_REFERENCE, "fw_Item_AddToPlayer_Post", 1);
RegisterHam(Ham_Weapon_Reload, WEAPON_REFERENCE, "fw_Weapon_Reload");
RegisterHam(Ham_Weapon_WeaponIdle, WEAPON_REFERENCE, "fw_Weapon_WeaponIdle");
RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_REFERENCE, "fw_Weapon_PrimaryAttack");
g_fw_TraceAttack[0] = RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack");
g_fw_TraceAttack[1] = RegisterHam(Ham_TraceAttack, "info_target", "fw_TraceAttack");
g_fw_TraceAttack[2] = RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack");
g_fw_TraceAttack[3] = RegisterHam(Ham_TraceAttack, "hostage_entity", "fw_TraceAttack");
fm_ham_hook(false);
register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1);
register_forward(FM_PlaybackEvent, "fw_PlaybackEvent");
register_forward(FM_SetModel, "fw_SetModel");
g_iMsgID_Weaponlist = get_user_msgid("WeaponList");
register_clcmd(WEAPON_NEW_NAME, "HookSelect");
g_iItemID = zp_register_extra_item(WEAPON_ITEM_NAME, WEAPON_ITEM_COST, ZP_TEAM_HUMAN);
}
public plugin_precache() {
new szBuffer[64]; formatex(szBuffer, charsmax(szBuffer), "sprites/%s.txt", WEAPON_NEW_NAME);
engfunc(EngFunc_PrecacheGeneric, szBuffer);
engfunc(EngFunc_PrecacheGeneric, WEAPON_HUD);
engfunc(EngFunc_PrecacheGeneric, WEAPON_HUD_AMMO);
g_AllocString_V = engfunc(EngFunc_AllocString, WEAPON_MODEL_VIEW);
g_AllocString_P = engfunc(EngFunc_AllocString, WEAPON_MODEL_PLAYER);
g_AllocString_E = engfunc(EngFunc_AllocString, WEAPON_REFERENCE);
iSpriteIndexTrail = engfunc(EngFunc_PrecacheModel, "sprites/laserbeam.spr");
engfunc(EngFunc_PrecacheModel, WEAPON_MODEL_VIEW);
engfunc(EngFunc_PrecacheModel, WEAPON_MODEL_PLAYER);
engfunc(EngFunc_PrecacheModel, WEAPON_MODEL_WORLD);
new const WPN_SOUND[][] = {
"weapons/m4a1buff_clipin1.wav",
"weapons/m4a1buff_clipin2.wav",
"weapons/m4a1buff_clipout.wav",
"weapons/m4a1buff_idle.wav"
}
for(new i = 0; i < sizeof WPN_SOUND;i++) engfunc(EngFunc_PrecacheSound, WPN_SOUND[i]);
engfunc(EngFunc_PrecacheSound, WEAPON_SOUND_SHOOT);
engfunc(EngFunc_PrecacheSound, WEAPON_SOUND_SHOOTE);
}
public plugin_natives() {
register_native("give_weapon_buffm4", "give_weapon", 1);
}
public HookSelect(iPlayer) {
engclient_cmd(iPlayer, WEAPON_REFERENCE);
return PLUGIN_HANDLED;
}
public zp_extra_item_selected(iPlayer, iItemID) {
if(iItemID == g_iItemID)
give_weapon(iPlayer);
}
public give_weapon(iPlayer) {
static iEnt; iEnt = engfunc(EngFunc_CreateNamedEntity, g_AllocString_E);
if(iEnt <= 0) return 0;
set_pev(iEnt, pev_spawnflags, SF_NORESPAWN);
set_pev(iEnt, pev_impulse, WEAPON_SPECIAL_CODE);
ExecuteHam(Ham_Spawn, iEnt);
UTIL_DropWeapon(iPlayer, 1);
if(!ExecuteHamB(Ham_AddPlayerItem, iPlayer, iEnt)) {
engfunc(EngFunc_RemoveEntity, iEnt);
return 0;
}
ExecuteHamB(Ham_Item_AttachToPlayer, iEnt, iPlayer);
set_pdata_int(iEnt, m_iClip, WEAPON_MAX_CLIP, 4);
new iAmmoType = m_rgAmmo +get_pdata_int(iEnt, m_iPrimaryAmmoType, 4);
if(get_pdata_int(iPlayer, m_rgAmmo, 5) < WEAPON_DEFAULT_AMMO)
set_pdata_int(iPlayer, iAmmoType, WEAPON_DEFAULT_AMMO, 5);
emit_sound(iPlayer, CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
return 1;
}
public fw_Item_Deploy_Post(iItem) {
if(!CustomItem(iItem)) return;
static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, 4);
set_pev_string(iPlayer, pev_viewmodel2, g_AllocString_V);
set_pev_string(iPlayer, pev_weaponmodel2, g_AllocString_P);
UTIL_SendWeaponAnim(iPlayer, ANIM_DRAW);
set_pdata_float(iPlayer, m_flNextAttack, ANIM_DRAW_TIME, 5);
set_pdata_float(iItem, m_flTimeWeaponIdle, ANIM_DRAW_TIME, 4);
}
public fw_Item_PostFrame(iItem) {
if(!CustomItem(iItem)) return HAM_IGNORED;
static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, 4);
if(get_pdata_int(iItem, m_fInReload, 4) == 1) {
static iClip; iClip = get_pdata_int(iItem, m_iClip, 4);
static iAmmoType; iAmmoType = m_rgAmmo + get_pdata_int(iItem, m_iPrimaryAmmoType, 4);
static iAmmo; iAmmo = get_pdata_int(iPlayer, iAmmoType, 5);
static j; j = min(WEAPON_MAX_CLIP - iClip, iAmmo);
set_pdata_int(iItem, m_iClip, iClip+j, 4);
set_pdata_int(iPlayer, iAmmoType, iAmmo-j, 5);
set_pdata_int(iItem, m_fInReload, 0, 4);
}
else switch(get_pdata_int(iItem, m_iWeaponState, 4)) {
case 0: {
if(get_pdata_float(iItem, m_flNextSecondaryAttack, 4) <= 0.0)
if(pev(iPlayer, pev_button) & IN_ATTACK2) {
set_pdata_int(iPlayer, m_iFOV, get_pdata_int(iPlayer, m_iFOV, 5) != 90 ? 90 : 85);
set_pdata_float(iItem, m_flNextSecondaryAttack, 0.3, 4);
}
}
}
return HAM_IGNORED;
}
public fw_Item_AddToPlayer_Post(iItem, iPlayer) {
switch(pev(iItem, pev_impulse)) {
case WEAPON_SPECIAL_CODE: s_weaponlist(iPlayer, true);
case 0: s_weaponlist(iPlayer, false);
}
}
public fw_Weapon_Reload(iItem) {
if(!CustomItem(iItem)) return HAM_IGNORED;
static iClip; iClip = get_pdata_int(iItem, m_iClip, 4);
if(iClip >= WEAPON_MAX_CLIP) return HAM_SUPERCEDE;
static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, 4);
static iAmmoType; iAmmoType = m_rgAmmo + get_pdata_int(iItem, m_iPrimaryAmmoType, 4);
if(get_pdata_int(iPlayer, iAmmoType, 5) <= 0) return HAM_SUPERCEDE
if(get_pdata_int(iPlayer, m_iFOV, 5) != 90) set_pdata_int(iPlayer, m_iFOV, 90, 5);
set_pdata_int(iItem, m_iClip, 0, 4);
ExecuteHam(Ham_Weapon_Reload, iItem);
set_pdata_int(iItem, m_iClip, iClip, 4);
set_pdata_float(iItem, m_flNextPrimaryAttack, ANIM_RELOAD_TIME, 4);
set_pdata_float(iItem, m_flNextSecondaryAttack, ANIM_RELOAD_TIME, 4);
set_pdata_float(iItem, m_flTimeWeaponIdle, ANIM_RELOAD_TIME, 4);
set_pdata_float(iPlayer, m_flNextAttack, ANIM_RELOAD_TIME, 5);
UTIL_SendWeaponAnim(iPlayer, ANIM_RELOAD);
return HAM_SUPERCEDE;
}
public fw_Weapon_WeaponIdle(iItem) {
if(!CustomItem(iItem) || get_pdata_float(iItem, m_flTimeWeaponIdle, 4) > 0.0) return HAM_IGNORED;
UTIL_SendWeaponAnim(get_pdata_cbase(iItem, m_pPlayer, 4), ANIM_IDLE);
set_pdata_float(iItem, m_flTimeWeaponIdle, ANIM_IDLE_TIME, 4);
return HAM_SUPERCEDE;
}
public fw_Weapon_PrimaryAttack(iItem) {
if(!CustomItem(iItem)) return HAM_IGNORED;
static iPlayer; iPlayer = get_pdata_cbase(iItem, m_pPlayer, 4);
static iFOV; iFOV = (get_pdata_int(iPlayer, m_iFOV, 5) != 90);
if(get_pdata_int(iItem, m_iClip, 4) == 0) {
ExecuteHam(Ham_Weapon_PlayEmptySound, iItem);
set_pdata_float(iItem, m_flNextPrimaryAttack, 0.2, 4);
return HAM_SUPERCEDE;
}
static fw_TraceLine; fw_TraceLine = register_forward(FM_TraceLine, "fw_TraceLine_Post", 1);
fm_ham_hook(true);
state FireBullets: Enabled;
ExecuteHam(Ham_Weapon_PrimaryAttack, iItem);
state FireBullets: Disabled;
unregister_forward(FM_TraceLine, fw_TraceLine, 1);
fm_ham_hook(false);
static Float:vecPunchangle[3];
static Float:vecOrigin[3]; fm_get_aim_origin(iPlayer, vecOrigin);
pev(iPlayer, pev_punchangle, vecPunchangle);
vecPunchangle[0] *= iFOV ? WEAPON_PUNCHAGNLE_EX : WEAPON_PUNCHAGNLE;
vecPunchangle[1] *= iFOV ? WEAPON_PUNCHAGNLE_EX : WEAPON_PUNCHAGNLE;
vecPunchangle[2] *= iFOV ? WEAPON_PUNCHAGNLE_EX : WEAPON_PUNCHAGNLE;
set_pev(iPlayer, pev_punchangle, vecPunchangle);
emit_sound(iPlayer, CHAN_WEAPON, iFOV ? WEAPON_SOUND_SHOOTE : WEAPON_SOUND_SHOOT, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
UTIL_SendWeaponAnim(iPlayer, iFOV ? ANIM_ATTACK_SE : ANIM_ATTACK);
if(iFOV) {
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BEAMENTPOINT);
write_short(iPlayer | 0x1000);
engfunc(EngFunc_WriteCoord, g_flvecEndPos[0]);
engfunc(EngFunc_WriteCoord, g_flvecEndPos[1]);
engfunc(EngFunc_WriteCoord, g_flvecEndPos[2]);
write_short(iSpriteIndexTrail);
write_byte(0); // framestart
write_byte(1); // framerate
write_byte(2); // life
write_byte(5); // width
write_byte(0); // noise
write_byte(255); // red
write_byte(255); // green
write_byte(255); // blue
write_byte(50); // brightness
write_byte(10); // speed
message_end();
}
set_pdata_float(iItem, m_flNextPrimaryAttack, iFOV ? WEAPON_RATE_EX : WEAPON_RATE, 4);
set_pdata_float(iItem, m_flTimeWeaponIdle, 0.5, 4);
return HAM_SUPERCEDE;
}
public fw_PlaybackEvent() <FireBullets: Enabled> { return FMRES_SUPERCEDE; }
public fw_PlaybackEvent() <FireBullets: Disabled> { return FMRES_IGNORED; }
public fw_PlaybackEvent() <> { return FMRES_IGNORED; }
public fw_TraceAttack(iVictim, iAttacker, Float:flDamage) {
if(!is_user_connected(iAttacker)) return;
static iItem; iItem = get_pdata_cbase(iAttacker, m_pActiveItem, 5);
static iFOV; iFOV = (get_pdata_int(iAttacker, m_iFOV, 5) != 90);
static Float: flWeaponDamage; flWeaponDamage = (iFOV ? WEAPON_DAMAGE_EX : WEAPON_DAMAGE);
if(iItem <= 0 || !CustomItem(iItem)) return;
SetHamParamFloat(3, flDamage * flWeaponDamage);
}
public fw_UpdateClientData_Post(iPlayer, SendWeapons, CD_Handle) {
if(get_cd(CD_Handle, CD_DeadFlag) != DEAD_NO) return;
static iItem; iItem = get_pdata_cbase(iPlayer, m_pActiveItem, 5);
if(iItem <= 0 || !CustomItem(iItem)) return;
set_cd(CD_Handle, CD_flNextAttack, 999999.0);
}
public fw_SetModel(iEnt) {
static i, szClassname[32], iItem;
pev(iEnt, pev_classname, szClassname, 31);
if(!equal(szClassname, "weaponbox")) return FMRES_IGNORED;
for(i = 0; i < 6; i++) {
iItem = get_pdata_cbase(iEnt, m_rgpPlayerItems_CWeaponBox + i, 4);
if(iItem > 0 && CustomItem(iItem)) {
engfunc(EngFunc_SetModel, iEnt, WEAPON_MODEL_WORLD);
set_pev(iEnt, pev_body, WEAPON_BODY);
return FMRES_SUPERCEDE;
}
}
return FMRES_IGNORED;
}
public fw_TraceLine_Post(const Float:flOrigin1[3], const Float:flOrigin2[3], iFrag, iIgnore, tr) {
if(iFrag & IGNORE_MONSTERS) return FMRES_IGNORED;
static pHit; pHit = get_tr2(tr, TR_pHit);
static Float:flvecEndPos[3]; get_tr2(tr, TR_vecEndPos, flvecEndPos);
if(pHit > 0) {
if(pev(pHit, pev_solid) != SOLID_BSP) return FMRES_IGNORED;
}
g_flvecEndPos = flvecEndPos;
engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, flvecEndPos, 0);
write_byte(TE_GUNSHOTDECAL);
engfunc(EngFunc_WriteCoord, flvecEndPos[0]);
engfunc(EngFunc_WriteCoord, flvecEndPos[1]);
engfunc(EngFunc_WriteCoord, flvecEndPos[2]);
write_short(pHit > 0 ? pHit : 0);
write_byte(random_num(41, 45));
message_end();
return FMRES_IGNORED;
}
public fm_ham_hook(bool:on) {
if(on) {
EnableHamForward(g_fw_TraceAttack[0]);
EnableHamForward(g_fw_TraceAttack[1]);
EnableHamForward(g_fw_TraceAttack[2]);
EnableHamForward(g_fw_TraceAttack[3]);
}
else {
DisableHamForward(g_fw_TraceAttack[0]);
DisableHamForward(g_fw_TraceAttack[1]);
DisableHamForward(g_fw_TraceAttack[2]);
DisableHamForward(g_fw_TraceAttack[3]);
}
}
stock UTIL_SendWeaponAnim(iPlayer, iSequence) {
set_pev(iPlayer, pev_weaponanim, iSequence);
message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, iPlayer);
write_byte(iSequence);
write_byte(0);
message_end();
}
stock UTIL_DropWeapon(iPlayer, iSlot) {
static iEntity, iNext, szWeaponName[32];
iEntity = get_pdata_cbase(iPlayer, m_rpgPlayerItems + iSlot, 5);
if(iEntity > 0) {
do {
iNext = get_pdata_cbase(iEntity, m_pNext, 4)
if(get_weaponname(get_pdata_int(iEntity, m_iId, 4), szWeaponName, 31)) {
engclient_cmd(iPlayer, "drop", szWeaponName);
}
} while(( iEntity = iNext) > 0);
}
}
stock s_weaponlist(iPlayer, bool:on) {
message_begin(MSG_ONE, g_iMsgID_Weaponlist, _, iPlayer);
write_string(on ? WEAPON_NEW_NAME : WEAPON_REFERENCE);
write_byte(iWeaponList[0]);
write_byte(on ? WEAPON_DEFAULT_AMMO : iWeaponList[1]);
write_byte(iWeaponList[2]);
write_byte(iWeaponList[3]);
write_byte(iWeaponList[4]);
write_byte(iWeaponList[5]);
write_byte(iWeaponList[6]);
write_byte(iWeaponList[7]);
message_end();
}