View Single Post
Suntox
Member
Join Date: Nov 2016
Old 07-05-2018 , 20:50   Re: Adding Burst-Fire Mode to a weapon
Reply With Quote #23

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(PLUGINVERSIONAUTHOR)
    
    
register_forward(FM_CmdStart"fw_CmdStart")
}

public 
fw_CmdStart(iduc_handleseed)
{
    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_handleUC_Buttons)
    
    if(
CurButton IN_ATTACK)
    {
        
CurButton &= ~IN_ATTACK
        set_uc
(uc_handleUC_ButtonsCurButton)
        
        static 
Float:CurTime
        CurTime 
get_gametime()
        
        new 
Float:flNextAttack flNextAttack get_pdata_float(id835)
        
        if (
flNextAttack 0.0)
            return 
FMRES_IGNORED        
        
        
if(CurTime 0.5 g_last_fire[id])
        {
            static 
ent
            ent 
find_ent_by_owner(-1wp_baseon_classnameid)
            
            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(-1wp_baseon_classnameid)
    
    if(!
pev_valid(ent))
        return
            
    if(
g_iBurstNum[id] > && g_iBurst[id] && cs_get_weapon_ammo(ent) > 0)
    {
        
ExecuteHamB(Ham_Weapon_PrimaryAttackent)
        
        
set_weapon_anim(id1)
        
        
g_iBurstNum[id]--
    } else {
        
g_iBurst[id] = 0
        remove_task
(id+TASK_BURST)
    }
}

stock set_weapon_anim(idanim)
{
    
set_pev(idpev_weaponanimanim)

    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM_id)
    
write_byte(anim)
    
write_byte(pev(id,pev_body))
    
message_end()


Last edited by Suntox; 07-05-2018 at 20:51.
Suntox is offline