Ok . let me explaine this script, using a weapon event to count bullets , when the bullet count goes over the jam_ratio cvar , it executes the event weapon jam blocking client side and server side firre and animation on the player that shot bullet number 1000 (if thats what the cvar is set too) . then the player has to press USE to clear the chamber and it plays a sound and messages. it works almost perfectly the way i want but it will execute my whole plugin only a few times then its like it shuts off. and also im having a prolem only passig one id from fucntion to function. it will execute on everyone and i dont know why.
Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
new g_iShots;
public plugin_init()
{
register_plugin("Weapon Jam's","2.0","Nostrodamous");
register_cvar("amx_weapon_jam","1");
register_cvar("amx_jam_ratio","100");
register_event("CurWeapon", "weapon_event", "be", "1=1", "3>0", "2!4", "2!6", "2!9", "2!25", "2!29");
register_forward(FM_PlayerPreThink, "weapon_jam");
register_forward(FM_UpdateClientData, "weapon_jam_update", 1);
}
public weapon_event(id)
{
if(get_cvar_num("amx_weapon_jam")== 0)
{
return PLUGIN_HANDLED;
}else{
if(g_iShots <= get_cvar_num("amx_jam_ratio"))
{
++g_iShots;
client_print(id,print_chat ," %i Bullets Fired",g_iShots);
jam_sounds(id);
}
}
return PLUGIN_CONTINUE;
}
public weapon_jam(id )
{
if(g_iShots == get_cvar_num("amx_jam_ratio"))
{
set_hudmessage(255, 255, 255, 0.15, 0.34, 0, 6.0, 12.0);
show_hudmessage(id, "Weapon Jam Press Use To Clear");
set_pev( id, pev_button, pev(id,pev_button) & ~IN_ATTACK );
clear_chamber(id);
}
return FMRES_HANDLED;
}
public weapon_jam_update(id,sendweapons,cd_handle )
{
if(g_iShots == get_cvar_num("amx_jam_ratio"))
{
set_hudmessage(255, 255, 255, 0.15, 0.34, 0, 6.0, 12.0);
show_hudmessage(id, "Weapon Jam Press Use To Clear");
set_cd(cd_handle, CD_ID, 0);
clear_chamber(id);
return FMRES_HANDLED;
}
return FMRES_HANDLED;
}
public jam_sounds(id)
{
if(g_iShots == get_cvar_num("amx_jam_ratio"))
{
emit_sound(id,CHAN_AUTO, "weapons/dryfire_rifle.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
}
}
public clear_chamber(id)
{
if(pev(id,pev_button) & IN_USE )
{
g_iShots = 0;
emit_sound(id,CHAN_AUTO,"weapons/m4a1_boltpull.wav",1.0,ATTN_NORM,0,PITCH_NORM);
set_hudmessage(255, 255, 255, 0.32, 0.35, 0, 6.0, 12.0)
show_hudmessage(id, "Chamber Clear ")
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}