AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Play sound only for killer & victim (https://forums.alliedmods.net/showthread.php?t=183701)

simple_user 04-25-2012 12:50

Play sound only for killer & victim
 
So I want to play random sound on knife kill, but only killer and victim should hear it. I don't know how to point out that rule... emit_sound(..?..., CHAN_AUTO, soundlist[random(sizeof soundlist)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);

Here's the sketch:

Code:

new soundlist[][] =
{
    "custom_sounds/knife1",
    "custom_sounds/knife2",
    "custom_sounds/knife3",
    "custom_sounds/knife4",
    "custom_sounds/knife5",

};

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)

}

public client_death(killer,victim,weapon)
{
    if(!killer || !victim)
        return;
   
    if(weapon == CSW_KNIFE )
    {
        client_cmd(killer ,"spk %s",soundlist[random(sizeof soundlist)]);
    }
   
       
}   

public plugin_precache()
{
    precache_sound("custom_sounds/knife1.wav");
    precache_sound("custom_sounds/knife2.wav");
    precache_sound("custom_sounds/knife3.wav");
    precache_sound("custom_sounds/knife4.wav");
    precache_sound("custom_sounds/knife5.wav");

}

thanks :stupid:

<VeCo> 04-25-2012 13:13

Re: Play sound only for killer & victim
 
Replace 0 with killer or victim. Index 0 means it will be heard by all players.
Emit_sound is used to play a sound around an entity (specific radius), so you don't need it here.


All times are GMT -4. The time now is 07:48.

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