SA-MP Forums Archive
one qeustion with random - 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: one qeustion with random (/showthread.php?tid=322990)



one qeustion with random - mineralo - 04.03.2012

well, how I can use random? I need it, I show what exactly I need
pawn Код:
if(ShitInfo[playerid][pLol] == random) // I need to be random between 25 and 40
{
ShitInfo[playerid][pLol] =0;
SendClientMessage(playerid,COLOR_WHITE,"( ! ) yes !");
}
help me plz !


Re: one qeustion with random - T0pAz - 04.03.2012

pawn Код:
new rnd = random((40 - 25)) + 25;
if(ShitInfo[playerid][pLol] == rnd)
{
ShitInfo[playerid][pLol] =0;
SendClientMessage(playerid,COLOR_WHITE,"( ! ) yes !");
}



Re: one qeustion with random - R0FLC0PTER - 04.03.2012

T0pAz is correct, and if you're going to use random more.
You could add a definition at the top of your script

pawn Код:
#define random(%1,%2) random(%2-%1)+%1
And then you can just use
pawn Код:
new value = random(2, 7); // Value will contain a random number ranging from 2 to 6.



Re: one qeustion with random - mineralo - 04.03.2012

thanks, I'll try