AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Sound effect only for 1 player (https://forums.alliedmods.net/showthread.php?t=224555)

GhostMan 08-25-2013 15:47

Sound effect only for 1 player
 
I'm using this code so that connected.wav would play globaly when VIP player connects.
PHP Code:

public client_putinserver(id)
{
    if(
get_user_flags(id) & VIP_ACCESS_NOBUY && g_iRoundCount 1)
    {
        new 
szName[32]
        
get_user_name(idszNamecharsmax(szName))
        
        
set_hudmessage(01702550.040.6110.05.00.10.14)
        
ShowSyncHudMsg(0g_HudSync"%s connected!"szName)
        
        
emit_sound(0CHAN_AUTO"nvip/connected.wav"1.0ATTN_NORM0PITCH_NORM)
    }


Also i use this code (below) to play give_item.wav sound when something from vip menu is selected. However i would like that sound would play only for player who made that selection. How do i do that?

PHP Code:

public VipCTMenu_handler(idmenuitem)
{
    if(
item == MENU_EXIT || !is_user_alive(id))
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], iName[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessdata,5iName63callback)
    
    new 
key str_to_num(data)
    
    switch(
key)
    {
        case 
1:
        {
            
set_user_health(idget_user_health(id) + 50)
            
set_user_armor(idget_user_armor(id) + 100)
            
            
VipUsed[id] = true
            
            client_print_color
(idid"%s You got ^3+50 HP ^1and ^3+100 Armor^1!"PREFIX)
            
emit_sound(idCHAN_AUTO"nvip/give_item.wav"1.0ATTN_NORM0PITCH_NORM)
        }
        case 
2:
        {
            new 
p_randomnum random_num(0255)
            
            
set_user_rendering(idkRenderFxGlowShellp_randomnump_randomnump_randomnumkRenderNormal25)
            
            
VipUsed[id] = true
            
            client_print_color
(idid"%s Now you're ^3glowing^1!"PREFIX)
            
emit_sound(idCHAN_AUTO"nvip/give_item.wav"1.0ATTN_NORM0PITCH_NORM)
        }
        
        
// etc..
    
}
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED



Napoleon_be 08-25-2013 16:10

Re: Sound effect only for 1 player
 
the give_item.wav is already playing for the player who selects it only.


PHP Code:

emit_sound(0CHAN_AUTO"nvip/connected.wav"1.0ATTN_NORM0PITCH_NORM

-->
PHP Code:


emit_sound
(idCHAN_AUTO"nvip/connected.wav"1.0ATTN_NORM0PITCH_NORM

https://secure-content-delivery.com/...=1377461458495

ConnorMcLeod 08-25-2013 17:14

Re: Sound effect only for 1 player
 
Wrong, depending on range, nearby players gonna hear it.

Use client_cmd and spk command.


All times are GMT -4. The time now is 19:13.

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