Random Number Generator - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Random Number Generator (
/showthread.php?tid=131362)
Random Number Generator -
master000 - 02.03.2010
Can I make a random number generator, and if yes, how?
Re: Random Number Generator -
Miguel - 02.03.2010
Yes, using
random(value):
pawn Code:
random(5); // this will return a number from 0 to 4
Example:
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
new
rand = random(10);
if(strval(cmdtext) == rand)
{
SendClientMessage(playerid, COLOR, "You got it!");
GivePlayerCash(playerid, 1000000);
return 0;
}
return 1;
}
Re: Random Number Generator -
master000 - 03.03.2010
Quote:
Originally Posted by SAWC™
Yes, using random(value):
pawn Code:
random(5); // this will return a number from 0 to 4
Example:
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[]) { new rand = random(10);
if(strval(cmdtext) == rand) { SendClientMessage(playerid, COLOR, "You got it!"); GivePlayerCash(playerid, 1000000); return 0; } return 1; }
|
Thanks