AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Weapon shoot sound problem (https://forums.alliedmods.net/showthread.php?t=252328)

Krtola 11-30-2014 12:53

Weapon shoot sound problem
 
What I need: only player who shoots from certain guns hear the sound of a gunshot.

PHP Code:

public fw_TraceAttack(iEntiAttackerFloat:flDamageFloat:fDir[3], ptriDamageTypeFloat:fVec1[3], Float:fVec2[3])
{
    if(!
is_user_alive(iAttacker))
        return

    new 
g_currentweapon get_user_weapon(iAttacker)

    if(
g_currentweapon != CSW_AUG
        return
    
    if(!
g_has_ethereal[iAttacker]) 
        return

    static 
Float:flEnd[3]
    
get_tr2(ptrTR_vecEndPosflEnd)
    
    if(!
is_user_alive(iEnt))
    {
        if(
eth_mode[iAttacker]==1)
        {
            
Make_BulletHole(iAttackerflEnd,flDamage)
            
Make_BulletSmoke(iAttackerptr)
            
emit_sound(iAttackerCHAN_WEAPONLaser_Sounds[0], VOL_NORMATTN_NORM0PITCH_NORM)
            
LaserBeam(iAttackerflEnd,12,l_ethereal_l_r,l_ethereal_l_g,l_ethereal_l_b,1,1)
        }
        else
        {
            
#if defined electro_fire_hole
                
Make_BulletHole(iAttackerflEnd,flDamage)
            
#endif
            
            #if defined electro_fire_smoke
                
Make_BulletSmoke(iAttackerptr)
            
#endif
            
LaserBeam(iAttacker,flEnd12,e_ethereal_l_r,e_ethereal_l_g,e_ethereal_l_b,e_ethereal_ls_min,e_ethereal_ls_max)
            
emit_sound(iAttackerCHAN_WEAPONElectro_Sounds[0], VOL_NORMATTN_NORM0PITCH_NORM)
        }
    }


I tried something like:

PHP Code:

emit_sound(iAttackerCHAN_WEAPONLaser_Sounds[0], VOL_NORMATTN_NORM0PITCH_NORM

:arrow:
PHP Code:

client_cmd(iAttacker"spk %s"Laser_Sounds[0]) 

I'm interested in is this the correct way to do something like this?

RateX 11-30-2014 13:30

Re: Weapon shoot sound problem
 
Yes it's is, as client_cmd only executes the command to a specific player, which in this case is playing the shooting sound.
Btw, for such questions you should really test it yourself instead of making thread.

Krtola 11-30-2014 13:34

Re: Weapon shoot sound problem
 
Quote:

Originally Posted by RateX (Post 2229816)
Yes it's is, as client_cmd only executes the command to a specific player, which in this case is playing the shooting sound.
Btw, for such questions you should really test it yourself instead of making thread.

I alredy test,and work.
I was only interested in the opinion of experienced people from this forum:is this the correct way.

NiHiLaNTh 11-30-2014 16:12

Re: Weapon shoot sound problem
 
You can hook FM_Playback event, and modify first argument (event flags), by doing
Code:

eventFlags |= FEV_HOSTONLY;
and this will send all events to the shooter. But you need to filter events, otherwise you'll block this way smoke grenade explosion effec for exmaple.

Krtola 11-30-2014 20:54

Re: Weapon shoot sound problem
 
Quote:

Originally Posted by NiHiLaNTh (Post 2229879)
You can hook FM_Playback event, and modify first argument (event flags), by doing
Code:

eventFlags |= FEV_HOSTONLY;
and this will send all events to the shooter. But you need to filter events, otherwise you'll block this way smoke grenade explosion effec for exmaple.

I do not use smokegrenade.
Anyway thank you,I'll try this and see if I can make in that way.


All times are GMT -4. The time now is 15:28.

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