Original code from WaterPistol.
try this:
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#define PLUGIN "M429 Brust Fire"
#define VERSION "1.0"
#define AUTHOR "Suntox"
#define BURST_NUM 5
#define BURST_DELAY 0.025
#define wp_baseon_classname "weapon_m249"
#define TASK_BURST 123123
new g_iBurstNum[33], g_iBurst[33], Float:g_last_shoot[33], Float:g_last_fire[33]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward(FM_CmdStart, "fw_CmdStart")
}
public fw_CmdStart(id, uc_handle, seed)
{
if(!is_user_alive(id) || !is_user_connected(id))
return FMRES_HANDLED
if(get_user_weapon(id) != CSW_M249)
return FMRES_HANDLED
static CurButton
CurButton = get_uc(uc_handle, UC_Buttons)
if(CurButton & IN_ATTACK)
{
CurButton &= ~IN_ATTACK
set_uc(uc_handle, UC_Buttons, CurButton)
static Float:CurTime
CurTime = get_gametime()
new Float:flNextAttack ; flNextAttack = get_pdata_float(id, 83, 5)
if (flNextAttack > 0.0)
return FMRES_IGNORED
if(CurTime - 0.5 > g_last_fire[id])
{
static ent
ent = find_ent_by_owner(-1, wp_baseon_classname, id)
if(cs_get_weapon_ammo(ent) <= 0)
return FMRES_IGNORED
g_iBurst[id] = 1
g_iBurstNum[id] = BURST_NUM
g_last_fire[id] = CurTime
}
}
return FMRES_HANDLED
}
public client_PostThink(id)
{
if(!is_user_alive(id) || !is_user_connected(id))
return
if(get_user_weapon(id) != CSW_M249)
return
if(!g_iBurst[id] || !g_iBurstNum[id])
return
static Float:CurTime
CurTime = get_gametime()
if(CurTime - BURST_DELAY > g_last_shoot[id])
{
do_burst(id)
g_last_shoot[id] = CurTime
}
}
public do_burst(id)
{
static ent
ent = find_ent_by_owner(-1, wp_baseon_classname, id)
if(!pev_valid(ent))
return
if(g_iBurstNum[id] > 0 && g_iBurst[id] && cs_get_weapon_ammo(ent) > 0)
{
ExecuteHamB(Ham_Weapon_PrimaryAttack, ent)
set_weapon_anim(id, 1)
g_iBurstNum[id]--
} else {
g_iBurst[id] = 0
remove_task(id+TASK_BURST)
}
}
stock set_weapon_anim(id, anim)
{
set_pev(id, pev_weaponanim, anim)
message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id)
write_byte(anim)
write_byte(pev(id,pev_body))
message_end()
}