View Single Post
lexzor
Veteran Member
Join Date: Nov 2020
Old 06-12-2022 , 13:10   Re: Emit_sound but different sound on every client
Reply With Quote #7

so, let's say you want a command that will emit a sound for all connected players that selected a sound

you can do something like this

PHP Code:
public emit_for_all_players(id)
{
    new 
iPlayers[MAX_PLAYERS], iNum;
    
get_players(iPlayersiNum"ch");

    for(new 
iiPlayeriSongIDiNumi++)
    {
        
iPlayer iPlayers[i];

        if(
is_user_connected(iPlayer))
        {
            
iSongID g_iUserSongID[iPlayer];

            if(
iSongID != NOT_SELECTED_SONG)
            {
                
emit_sound(iPlayerCHAN_AUTOg_szSongs[iSongID][szPath], VOL_NORMATTN_NORM0PITCH_NORM); 
            }
        }
    }

    
client_print(0print_chat"[SONGS] Admin emit your selected sound");

    return 
PLUGIN_HANDLED;

in that loop we get song id from every player, check if user is connected and he has selected a song then we emit the song he selected

Last edited by lexzor; 06-12-2022 at 13:23.
lexzor is offline