Raised This Month: $46 Target: $400
 11% 

EmitSoundtoClient sound origin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bayshades
Junior Member
Join Date: Sep 2019
Old 03-24-2020 , 07:31   EmitSoundtoClient sound origin
Reply With Quote #1

Hello Modders
Here is my code:
Thank you for your attention.
PHP Code:
public player_hurt(Handle:event, const String:name[], bool:silent)
{
    static 
UA;
    
GetEventInt(event"attacker");
    
GetEventInt(event"victim");
    
GetClientOfUserId(E);
    
GetClientOfUserId(U);
    if(
&& != GetClientOfUserId(GetEventInt(event"userid")) && g_IsHitEnabled[A])
    {
    new 
random GetRandomInt(1,2);
    switch(
random)
    {
         case 
1:
         {
             
EmitSoundToClient(ACSGO "play *shades/zmhit.mp3" "play shades/zmhit.mp3");
         }
         case 
2:
         {
             
EmitSoundToClient(ACSGO "play *shades/zmhit2.mp3" "play shades/zmhit2.mp3");
         }         
    }     
    }

As u can see we got attackers userid and emitted a song but i ve added victims userid so i wanna emit sound to attacker but sound origin should be victim. My question is how can i do that?
Just tell me the logic Please. If you wanna try you can post your code i can compile and try it in few minutes. Thank you again.

Last edited by bayshades; 03-24-2020 at 07:41.
bayshades is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine
Old 03-28-2020 , 05:46   Re: EmitSoundtoClient sound origin
Reply With Quote #2

I'm not clearly sure what do you want.

If you need all players can hear sound from some direction (or don't hear if they are too far):

PHP Code:
    int victim GetClientOfUserId(GetEventInt(event"userid"));
    
    if( 
victim && IsClientInGame(victim) )
    {
        
float vec[3];
        
GetEntPropVector(clientProp_Send"m_vecOrigin"vec);

        
EmitAmbientSound("shades/zmhit.mp3"vecSOUND_FROM_WORLD255);
    } 
BTW. There is no such member "victim" in player_hurt event.
See: https://wiki.alliedmods.net/Generic_...ts#player_hurt
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D1 fun (Bloody Witch)
[My plugins] [My tools] [GitHub] [Articles]

Last edited by Dragokas; 03-28-2020 at 05:48.
Dragokas is offline
bayshades
Junior Member
Join Date: Sep 2019
Old Yesterday , 19:28   Re: EmitSoundtoClient sound origin
Reply With Quote #3

Thanks that helps lot
bayshades is offline
Reply


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 23:09.


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