Random Number Generator
#1

Can I make a random number generator, and if yes, how?
Reply
#2

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;
}
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)