Random numbers - 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: Random numbers (
/showthread.php?tid=567718)
deleted -
RedCode - 15.03.2015
Deleted
Respuesta: Random numbers -
JuanStone - 15.03.2015
PHP код:
CMD:numbers(playerid,params[])
{
if(PlayerData[playerid][proplayer] >= 1)
{
new string[18];
format(string, sizeof(string), "random number: %d", random(11));
SendClientMessage(playerid, -1, string);
}
return 1;
}
Using the "random" function could return " 0" i hope it will not be a problem, if there is a problem you can use:
PHP код:
CMD:numbers(playerid,params[])
{
if(PlayerData[playerid][proplayer] >= 1)
{
new string[18];
format(string, sizeof(string), "random number: %d", random(10)+1);
SendClientMessage(playerid, -1, string);
}
return 1;
}
Re: Random numbers -
RedCode - 15.03.2015
but if he use that command can be and 0 of them ? i need only from 1 to 11
Respuesta: Random numbers -
JuanStone - 15.03.2015
try this.
Quote:
Originally Posted by JuanStone
PHP код:
CMD:numbers(playerid,params[]) { if(PlayerData[playerid][proplayer] >= 1) { new string[18]; format(string, sizeof(string), "random number: %d", random(10)+1); SendClientMessage(playerid, -1, string); } return 1; }
|
Re: Random numbers -
Jefff - 15.03.2015
(random(11) + 1) will be 1-11
Re: Random numbers -
RedCode - 15.03.2015
Jefff if i use that randrom 11+1 when he use command can be and number 12
Respuesta: Random numbers -
JuanStone - 15.03.2015
The function random starts in 0, if you use 11+1 would be 0+1 to 11 (limit 11 +1-1), Jeff did it well.
PHP код:
CMD:numbers(playerid,params[])
{
if(PlayerData[playerid][proplayer] >= 1)
{
new string[18];
format(string, sizeof(string), "random number: %d", random(11)+1); // 0+1 - 10+1 limit 11.
SendClientMessage(playerid, -1, string);
}
return 1;
}
random(11) = "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10"+1 = random 1-11. start in 0.
Re: Random numbers -
RedCode - 15.03.2015
Thanks guys ! +REP