Raised This Month: $ Target: $400
 0% 

emit_sound and model changing


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 10-06-2007 , 07:47   emit_sound and model changing
Reply With Quote #1

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_rofcvar_speed
new g_CurWeap[33][2]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event"CurWeapon""Event_WeaponFire",  "b" )
    
register_event"CurWeapon""Event_ChangeWeapon",  "be""1=1" )
    
    
register_forward(FM_SetModel"fw_SetModel" )
    
register_forwardFM_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 
M249_SHOT i++ )
    {
        
precache_sound(g_M249SHOT[i])
        
precache_sound(g_MINIGUN_SHOT[i])
    }


public 
Event_WeaponFireid 

    new 
weapon read_data
    new 
ammo read_data
    
    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_floatcvar_rof 
                if (
changednextattack 0.0)
                    
set_pdata_float(ent,46,changednextattack,4)
            }
        }
        
    }  
    return 
PLUGIN_CONTINUE
}

public 
Event_ChangeWeapon id )
{
    new 
weapon read_data )
    
    if ( 
weapon != CSW_M249 )
        return 
PLUGIN_HANDLED
    
    fm_set_user_maxspeed 
id get_pcvar_float cvar_speed ) )
    
set_pev idpev_viewmodel2VIEW_MODEL )        
    
set_pev idpev_weaponmodel2PLAYER_MODEL )
    
    
    return 
PLUGIN_CONTINUE
}

public 
fw_SetModel entitymodel[] )
{
    if (!
pev_valid(entity)) 
        return 
FMRES_IGNORED
    
    
if (!equali(modelOLDWORLD_MODEL)) 
        return 
FMRES_IGNORED
    
    
new className[33]
    
pev (entitypev_classnameclassName32)
    
    if (
equal(className"weaponbox") || equal(className"armoury_entity"))
    {
        
engfunc(EngFunc_SetModelentityWORLD_MODEL)
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED
}

public 
fw_EmitSound(idchannelsample[])
{    
    if ( !
is_user_alive id ) )
        return 
FMRES_IGNORED
    
    
for ( new iCount iCount MINIGUN_SHOT iCount++ )
        if ( 
equali sampleg_MINIGUN_SHOT[iCount] ) )
        {
            
engfunc EngFunc_EmitSoundidCHAN_WEAPONg_MINIGUN_SHOT[random_num(0MINIGUN_SHOT 1)], VOL_NORMATTN_NORM0PITCH_NORM )
            return 
FMRES_SUPERCEDE
        
}
    
    return 
FMRES_IGNORED
}

stock fm_find_ent_by_owner (index, const classname[], ownerjghgtype 0
{
    new 
strtype[11] = "classname"ent index
    
switch (jghgtype
    {
        case 
1strtype "target"
            
case 2strtype "targetname"
        
}
    
    while ((
ent engfunc(EngFunc_FindEntityByStringentstrtypeclassname)) && pev(entpev_owner) != owner) {}
    
    return 
ent
}

stock fm_set_user_maxspeed(indexFloat:speed = -1.0
{
    
engfunc(EngFunc_SetClientMaxspeedindexspeed)
    
set_pev(indexpev_maxspeedspeed)

    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.
__________________
It's a mystery.

Last edited by Mini_Midget; 10-07-2007 at 03:32.
Mini_Midget is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode