SA-MP Forums Archive
[HELP] Playing random audiostreams - 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] Playing random audiostreams (/showthread.php?tid=343954)



[HELP] Playing random audiostreams - Jimbo01 - 19.05.2012

How can i make that it playes random audiostreams like link1 link2 etc ?

EDIT:

Is this right ?

Код:
				new success = random(2);
				if(success == 1)
				{
				PlayAudioStreamForPlayer(i, "http");
				}
				if(success == 2)
				{
				PlayAudioStreamForPlayer(i, "http");
				}



Re: [HELP] Playing random audiostreams - Admigo - 19.05.2012

Quote:
Originally Posted by Jimbo01
Посмотреть сообщение
How can i make that it playes random audiostreams like link1 link2 etc ?

EDIT:

Is this right ?

Код:
				new success = random(2);
				if(success == 1)
				{
				PlayAudioStreamForPlayer(i, "http");
				}
				if(success == 2)
				{
				PlayAudioStreamForPlayer(i, "http");
				}
You can test it by yourself. I thinks its right


Re: [HELP] Playing random audiostreams - Pizzy - 19.05.2012

yep, that is right, but I would do this (more organized)

pawn Код:
new rid = random(5);
switch(rid)
{
    case 1: { PlayAudioStreamForPlayer(i, "url here"); }
    case 2: { PlayAudioStreamForPlayer(i, "url here"); }
    case 3: { PlayAudioStreamForPlayer(i, "url here"); }
    case 4: { PlayAudioStreamForPlayer(i, "url here"); }
    case 5: { PlayAudioStreamForPlayer(i, "url here"); }
}



Re: [HELP] Playing random audiostreams - Basssiiie - 19.05.2012

Код:
switch(random(2))
{
	case 0:
	{
		PlayAudioStreamForPlayer(i, "http url here");
	}
	case 1:
	{
		PlayAudioStreamForPlayer(i, "http url here");
	}
}



Re: [HELP] Playing random audiostreams - KingHual - 19.05.2012

Quote:
Originally Posted by admigo
Посмотреть сообщение
You can test it by yourself. I thinks its right
Quote:
Originally Posted by Pizzy
Посмотреть сообщение
yep, that is right, but I would do this (more organized)

pawn Код:
new rid = random(5);
switch(rid)
{
    case 1: { PlayAudioStreamForPlayer(i, "url here"); }
    case 2: { PlayAudioStreamForPlayer(i, "url here"); }
    case 3: { PlayAudioStreamForPlayer(i, "url here"); }
    case 4: { PlayAudioStreamForPlayer(i, "url here"); }
    case 5: { PlayAudioStreamForPlayer(i, "url here"); }
}
No, it's NOT right. Let me quickly explain. random(5) (for example) runs a random number from 0 to 4. It doesn't count 5 in. So, it should be
Код:
switch(random(5))
{
	case 0: { PlayAudioStreamForPlayer(i, "url here"); }
	case 1: { PlayAudioStreamForPlayer(i, "url here"); }
	case 2: { PlayAudioStreamForPlayer(i, "url here"); }
	case 3: { PlayAudioStreamForPlayer(i, "url here"); }
	case 4: { PlayAudioStreamForPlayer(i, "url here"); }
}
I mean seriously, don't you know the basics of computer languages? That cells start at 0 and not 1?


AW: [HELP] Playing random audiostreams - Jimbo01 - 19.05.2012

Thanks all