Help with break; - 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: Help with break; (
/showthread.php?tid=553606)
Help with break; -
Minatoo - 30.12.2014
Код:
forward song();
public song()
{
new rand = random(3);
for(new i = 0; i < MAX_PLAYERS; i++)
if(radiop[i] == 1)
{
StopAudioStreamForPlayer(i);
switch(rand)
{
case 0:
{
PlayAudioStreamForPlayer(i, "http://iusmix.altervista.org/Radio/Skrillex_First_of_the_year.mp3");
SendClientMessage(i, COLOR_YELLOW, "*** Brano corrente: Skrillex - First Of The Year.");
varxkill = SetTimer("song", 263000, false);
break;
}
case 1:
{
PlayAudioStreamForPlayer(i, "http://iusmix.altervista.org/Radio/Skrillex_-_Rock_n_Roll__Will_Take_You_to_the_Mountain_.mp3");
SendClientMessage(i, COLOR_YELLOW, "*** Brano corrente: Skrillex - Rock n' Roll.");
varxkill = SetTimer("song", 270000, false);
break;
}
case 2:
{
PlayAudioStreamForPlayer(i, "http://iusmix.altervista.org/Radio/Skrillex_-_Right_In.mp3");
SendClientMessage(i, COLOR_YELLOW, "*** Brano corrente: Skrillex - Right In.");
varxkill = SetTimer("song", 183000, false);
break;
}
}
SendClientMessage(i, COLOR_YELLOW, "*** Per fermare questo brano digita/stop!");
}
}
Hello, this script should start a randomized playlist (i put only 3 cases), logically is correct, but the song start only for the ID 0 player, because "break;" does is function for switch and for...
Why break quit the switch and for, and how can i resolve it?
Sorry for my bad english.
Re: Help with break; -
Schneider - 30.12.2014
You are using the break-function, that will stop the loop, that's why it only works for ID 0
Just remove all break-functions.
Re: Help with break; -
Minatoo - 30.12.2014
If i remove break; all the song start consecutively
The first song work, but when start second song do all other cases
Re: Help with break; -
Minatoo - 31.12.2014
Yes, i noticed, but if i remove break; all the song start consecutively.
Anywhere i fixed putting SetTimerEx instead SetTimer...
Thanks the same
Re: Help with break; -
LivingLikeYouDo - 31.12.2014
I don't know why break; is used to here when you are using timers (Correct me if I am wrong)
Removing them would do the thing; as the timer would start and after it finishes, another case will be started