Code ? - 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: Code ? (
/showthread.php?tid=542416)
Code ? -
rockhopper - 19.10.2014
See I wanted to make a Pinfo Variable that saves When Typed a CMD I want that variable to be 3 Random Numbers So how can I do it ? Turn it to 3 Random Numbers ?
Re: Code ? -
NeverGetAlone - 19.10.2014
pawn Code:
CMD:random(playerid, params[])
{
new rand = randomEx(1, 3);
if(rand == 1)
{
SendClientMessage(playerid, -1, "random 1");
}
else if(rand == 2)
{
endClientMessage(playerid, -1, "random 2");
}
else if(rand == 3)
{
endClientMessage(playerid, -1, "random 3");
}
return 1;
}
stock randomEx(min, max)
{
new rand = random(max-min) +min;
return rand;
}
Re: Code ? -
rockhopper - 20.10.2014
I will try this But I can change the min and max ? To whatever ? Or only works for 1 2 and 3 ?
Re: Code ? -
zaibaslr2 - 20.10.2014
Use
CMD:random(playerid,params[])
{
variable = 100*random(10) + 10*random(10) + random(10); //random 3 digit number will be stored into your variable
}
Re: Code ? -
rockhopper - 20.10.2014
Dont you think it should be random(9) Or else if random(10) Then 10 can also be a number right ?
Re: Code ? -
zaibaslr2 - 20.10.2014
Quote:
Originally Posted by rockhopper
Dont you think it should be random(9) Or else if random(10) Then 10 can also be a number right ?
|
No, random(10) generates a number from 0 to 9