the random() function: HELP PLEASE? - 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: the random() function: HELP PLEASE? (
/showthread.php?tid=286079)
the random() function: HELP PLEASE? -
BigAl - 26.09.2011
Hey, erm... this code doesn't work properly
pawn Код:
CMD:football(playerid, params[])
{
new rand = random(3);
if( rand == 1)
{
SCM(playerid, -1, "You got beat 1-0");
GivePlayerMoney(playerid, 50000);
}
if( rand == 2)
{
SCM(playerid, -1, "You won 3-2");
GivePlayerMoney(playerid, 50000);
}
if( rand == 3)
{
SCM(playerid, -1, "You drew 3-3");
GivePlayerMoney(playerid, 1000);
}
return 1;
}
Re : the random() function: HELP PLEASE? -
Naruto_Emilio - 26.09.2011
pawn Код:
if( rand == 1)
{
SCM(playerid, 0xFFFFFFAA , "You got beat 1-0");
GivePlayerMoney(playerid, 50000);
}
if( rand == 2)
{
SCM(playerid, 0xFFFFFFAA ,"You won 3-2");
GivePlayerMoney(playerid, 50000);
}
if( rand == 3)
{
SCM(playerid, 0xFFFFFFAA , "You drew 3-3");
GivePlayerMoney(playerid, 1000);
}
oh and i think the script is bad look , if you want to give a player - money just add this - sign near your GivePlayerMoney,
Example: GivePlayerMoney(playerid, -5000); and it will give him -5000$
Re: the random() function: HELP PLEASE? -
IceCube! - 26.09.2011
Above -.-
Re: the random() function: HELP PLEASE? -
BigAl - 26.09.2011
I used switch(random(3)) instead... but thanks anyways
Re: the random() function: HELP PLEASE? -
Andrejs - 26.09.2011
Quote:
A random number ranging from 0 to max-1.
|
but in your code there is no if(rand == 0)
Re: the random() function: HELP PLEASE? -
Elorreli - 26.09.2011
pawn Код:
CMD:football(playerid, params[])
{
new rand = random(3);
if( rand == 0)
{
SCM(playerid, -1, "You got beat 1-0");
GivePlayerMoney(playerid, 50000);
}
if( rand == 1)
{
SCM(playerid, -1, "You won 3-2");
GivePlayerMoney(playerid, 50000);
}
if( rand == 2)
{
SCM(playerid, -1, "You drew 3-3");
GivePlayerMoney(playerid, 1000);
}
return 1;
}
Re: the random() function: HELP PLEASE? -
ivanVU - 26.09.2011
Try like this
Код:
CMD:football(playerid,params[])
{
new
ball = random(3);
switch(ball)
{
case 0: // CASE 1
{
}
case 1: // CASE 1
{
}
case 2: // CASE 3
{
}
}
return 1;
}