The plugin is making the M249/Para fire faster. (No problems here)
The trouble is trying to change to M249 to my own custom model.
I'm using CurWeapon event at the moment but I'm also using it to detect a gun shot. Right now, I made it so it changes the model when the player FIRES the M249. Not when he actually has first when he switched to it.
Just wondering if theres another way around this besides event CurWeapon?
Also, my emit_sound line has an error on it. I have no idea whats wrong with it. Maybe you guys can take a look at it.
Code:
\my local folder\mini_gun.sma(147) : error 035: argument type mismatch (argument 3)
PHP Code:
#include <amxmodx>
#include <fakemeta>
#define PLUGIN "Mini-Gun"
#define VERSION "1.1"
#define AUTHOR "Mini_Midget"
new VIEW_MODEL[] = "models/mini_gun/v_minigun.mdl"
new PLAYER_MODEL[] = "models/mini_gun/p_minigun.mdl"
new WORLD_MODEL[] = "models/mini_gun/w_minigun.mdl"
new OLDWORLD_MODEL[] = "models/w_m249.mdl"
#define M249_SHOT 2
new const g_M249SHOT[M249_SHOT][] =
{
"weapons/m249-1.wav",
"weapons/m249-2.wav"
}
#define MINIGUN_SHOT 2
new const g_MINIGUN_SHOT[] =
{
"mini_gun/mini_gun1.wav",
"mini_gun/mini_gun2.wav"
}
new cvar_rof, cvar_speed
new g_CurWeap[33][2]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event( "CurWeapon", "Event_WeaponFire", "b" )
register_event( "CurWeapon", "Event_ChangeWeapon", "be", "1=1" )
register_forward(FM_SetModel, "fw_SetModel" )
register_forward( FM_EmitSound, "fw_EmitSound" )
cvar_rof = register_cvar( "mg_rof", "0.02" )
cvar_speed = register_cvar( "mg_speed", "165" )
}
public plugin_precache()
{
precache_model(VIEW_MODEL)
precache_model(PLAYER_MODEL)
precache_model(WORLD_MODEL)
for (new i = 0 ; i < M249_SHOT ; i++ )
{
precache_sound(g_M249SHOT[i])
precache_sound(g_MINIGUN_SHOT[i])
}
}
public Event_WeaponFire( id )
{
new weapon = read_data( 2 )
new ammo = read_data( 3 )
if( g_CurWeap[id][0] != weapon ) // User Changed Weapons..
{
g_CurWeap[id][0] = weapon
g_CurWeap[id][1] = ammo
return PLUGIN_CONTINUE
}
if( g_CurWeap[id][1] < ammo ) // User Reloaded..
{
g_CurWeap[id][1] = ammo
return PLUGIN_CONTINUE
}
if( g_CurWeap[id][1] == ammo ) // User did something else, but didn't shoot..
return PLUGIN_CONTINUE
g_CurWeap[id][1] = ammo
g_CurWeap[id][0] = weapon
if(weapon == CSW_M249)
{
new weap[32]
get_weaponname(weapon,weap,31)
new ent = fm_find_ent_by_owner(-1,weap,id)
if(ent)
{
new Float:nextattack = get_pdata_float(ent,46,4)
if (nextattack > 0.0)
{
new Float:changednextattack = nextattack - get_pcvar_float( cvar_rof )
if (changednextattack > 0.0)
set_pdata_float(ent,46,changednextattack,4)
}
}
}
return PLUGIN_CONTINUE
}
public Event_ChangeWeapon ( id )
{
new weapon = read_data ( 2 )
if ( weapon != CSW_M249 )
return PLUGIN_HANDLED
fm_set_user_maxspeed ( id , get_pcvar_float ( cvar_speed ) )
set_pev ( id, pev_viewmodel2, VIEW_MODEL )
set_pev ( id, pev_weaponmodel2, PLAYER_MODEL )
return PLUGIN_CONTINUE
}
public fw_SetModel ( entity, model[] )
{
if (!pev_valid(entity))
return FMRES_IGNORED
if (!equali(model, OLDWORLD_MODEL))
return FMRES_IGNORED
new className[33]
pev (entity, pev_classname, className, 32)
if (equal(className, "weaponbox") || equal(className, "armoury_entity"))
{
engfunc(EngFunc_SetModel, entity, WORLD_MODEL)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
public fw_EmitSound(id, channel, sample[])
{
if ( !is_user_alive ( id ) )
return FMRES_IGNORED
for ( new iCount = 0 ; iCount < MINIGUN_SHOT ; iCount++ )
if ( equali ( sample, g_MINIGUN_SHOT[iCount] ) )
{
engfunc ( EngFunc_EmitSound, id, CHAN_WEAPON, g_MINIGUN_SHOT[random_num(0, MINIGUN_SHOT - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
stock fm_find_ent_by_owner (index, const classname[], owner, jghgtype = 0)
{
new strtype[11] = "classname", ent = index
switch (jghgtype)
{
case 1: strtype = "target"
case 2: strtype = "targetname"
}
while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
return ent
}
stock fm_set_user_maxspeed(index, Float:speed = -1.0)
{
engfunc(EngFunc_SetClientMaxspeed, index, speed)
set_pev(index, pev_maxspeed, speed)
return 1
}
EDIT:
I just edited the plugin a bit and decided to use EngFunc_EmitSound.
It compiles now but when I test it. It is still the default sounds in CS.
I've got the changing model thingy to work now. I'm just gonna use 2 curweapon events.
This emit sound thingy is really pissing me off because it just won't work. I've tried many methods and non work at all.
__________________