[Tutorial] Making the most out of audio streaming! - Tips and tricks
#2

You don't have to use format to copy a string, use strcat or strcpy instead. Secondly, there's no need to check if player is connected when you're using foreach. It adds in players to it's array when player connects.

Quote:
Originally Posted by Abagail
View Post
For this example, we'll make a function to stream a URL for online rcon administrators.

pawn Code:
stock PlayStreamForRCONAdmins(url[])
{
    foreach(Player, i)
    {

         if(IsPlayerConnected(i)) continue;
         if(IsPlayerAdmin(i)) continue;
         PlayAudioStreamForPlayer(i, url);
          return 1;
     }
}
Your loop is incorrect, it checks if player is connected and then skips if player is connected. Also in case if the player is logged in as RCON, it will also skip that player since they're logged in. Mistakes do happen though. Also, I don't see the variable "i" declared under foreach. I'm not sure how the latest foreach works, so please correct me if I'm wrong. Oh and returning 1 inside a loop will not get your function work the way you want, it will return 1 as soon after one single index is done.

EDIT : I just noted this:
Quote:
Originally Posted by Abagail
View Post
Basically, - this runs a loop. Then, it checks if the player is connected. If so, - the loop continues. Same thing with checking if the player is logged into RCON.
It's not how continue statement work. It skips and continues to the next loop if that's used. You can take a look at this topic, it has explained looping structures very well and I suggest you to read that.

https://sampforum.blast.hk/showthread.php?tid=305770
Reply


Messages In This Thread
Making the most out of audio streaming! - Tips and tricks - by Abagail - 19.10.2014, 14:56
Re: Making the most out of audio streaming! - Tips and tricks - by Lordzy - 19.10.2014, 15:59
Re: Making the most out of audio streaming! - Tips and tricks - by Abagail - 19.10.2014, 17:09

Forum Jump:


Users browsing this thread: 1 Guest(s)