SA-MP Forums Archive
PlayAudioStream for all? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: PlayAudioStream for all? (/showthread.php?tid=303602)



PlayAudioStream for all? - JackT - 14.12.2011

Hey, im currently making an rcon admin command that when you enter it it plays music for everyone.

But my question is, is there any other way than looping?


Re: PlayAudioStream for all? - Psymetrix - 14.12.2011

No, you will have to use a loop.


Re: PlayAudioStream for all? - Rob_Maate - 14.12.2011

Sorry mate, only way unfortunately
pawn Код:
new CurrentStream[256] = "null" //At the top of your script, with the other "new's"

stock PlayAudioStreamForAll(StreamURL[]) //Wherever, just so long as it's not inside another function
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            PlayAudioStreamForPlayer(i, StreamURL, 0.0, 0.0, 0.0, 0);
        }
    }
    CurrentStream = StreamURL;
}

stock StopAudioStreamForAll() //Below the above stock
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            StopAudioStreamForPlayer(i);
        }
    }
    CurrentStream = "null";
}

public OnPlayerConnect(playerid)
{
    if(strcmp(CurrentStream, "null", true) != 0)
    {
        PlayAudioStreamForPlayer(i, StreamURL, 0.0, 0.0, 0.0, 0);
    }
}