yes i know the psots are very weird when you try to edit it ends up a very weird code . lol . np .
but if the cvars are both integers why try them as flaots ? here let me show my whole code LOL
Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
// global shot varaible
new g_iShots[33];
new g_iRatio;
new weapon;
new ammo;
new g_iRandom;
public plugin_init()
{
register_plugin("Weapon Jam","0.5","The Specialist");
register_cvar("amx_weapon_jam","1");
g_iRatio = register_cvar("amx_jam_ratio","200");
g_iRandom = register_cvar("amx_random_jam","0");
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);
}
// current weapon event
public weapon_event(id)
{
// if plugin is off end function
if(get_cvar_num("amx_weapon_jam")== 0)
{
return PLUGIN_HANDLED;
}else{
// if shots < ratio cvar increment varaible
if(g_iShots [id]<= get_pcvar_num(g_iRatio))
{
++g_iShots[id];
random_jam_gen();
jam_sounds(id);
client_print(id,print_chat,"THe shots fired is %i",g_iShots[id]);
}
}
return PLUGIN_CONTINUE;
}
// pre-think
public weapon_jam(id )
{
// if shots == cvar execute functions
if( g_iShots[id] >= get_pcvar_num(g_iRatio))
{
// get the currently held weapon and jam that weapon only
if(get_user_weapon(id,weapon ,ammo)== weapon)
{
// show messages
set_hudmessage(255, 255, 255, -1.0, 0.33, 0, 6.0, 12.0)
show_hudmessage(id, "Weapon Jam Press Use To Clear")
// block attack button
set_pev( id, pev_button, pev(id,pev_button) & ~IN_ATTACK );
// execute clear chamber and sounds
clear_chamber(id);
}else{
return PLUGIN_HANDLED;
}
}
return FMRES_HANDLED;
}
// client update data
public weapon_jam_update(id,sendweapons,cd_handle )
{
// if shots are = cvar execute functions
if( g_iShots[id] >= get_pcvar_num(g_iRatio))
{
// get the currently held weapon and jam that weapon only
if(get_user_weapon(id,weapon ,ammo)== weapon)
{
// show messages
set_hudmessage(255, 255, 255, -1.0, 0.33, 0, 6.0, 12.0)
show_hudmessage(id, "Weapon Jam Press Use To Clear")
// block weapon cd id
set_cd(cd_handle, CD_ID, 0);
// clear chamber and play sounds
clear_chamber(id);
return FMRES_HANDLED;
}else{
return PLUGIN_HANDLED;
}
}
return FMRES_HANDLED;
}
public jam_sounds(id)
{
// if shots is = cvar execute function
if( g_iShots [id]>= get_pcvar_num(g_iRatio))
{
// play sounds
emit_sound(id,CHAN_AUTO, "weapons/dryfire_rifle.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
}
}
public clear_chamber(id)
{
// if user presses use button or user is bot end functions
if(pev(id,pev_button) & IN_USE || is_user_bot(id)==1)
{
//re-set varaible to 0
g_iShots[id] = 0;
// play sounds
emit_sound(id,CHAN_AUTO,"weapons/m4a1_boltpull.wav",1.0,ATTN_NORM,0,PITCH_NORM);
// show messages
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 12.0);
show_hudmessage(id, "Chamber Clear");
// and stop functions
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
// Random number generator
public random_jam_gen()
{
// if random cvars is 0 (off) end function
if(get_pcvar_num(g_iRandom)==0)
{
return PLUGIN_HANDLED;
}else{
// else ratio == a random number between random cvar and ratio cvar
g_iRatio == random_num(get_pcvar_num(g_iRandom),get_pcvar_num(g_iRatio));
}
return PLUGIN_HANDLED;
}