How do I make a random number, on my /gamble command
#1

I want to make a gamble command that chooses a number between 1 and 3 and if it lands on 2 it will give the player 50 dollars, if it it lands on something else it will tell him he lost.

I have this code but it doesn't work.
Code:
CMD:gamble(playerid, params[])
{
    new rand = random(1 - 3);
	new string[64];
    GivePlayerMoney(playerid, -10);
    if(rand == 2)
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Your number landed on 3, and you won 50 dollars!");
    }
    else
    {
		format(string,sizeof(string),"Your number is %d",rand);
		SendClientMessage(playerid, COLOR_RED, string);
    }
    return 1;
}
Reply
#2

It should work:
PHP Code:
CMD:gamble(playeridparams[])
{
    new 
rand random(3);//It's 3 no 1 - 3
    
new string[64];
    
    if(
rand == 2)
    {
        
SendClientMessage(playeridCOLOR_YELLOW"Your number landed on 3, and you won 50 dollars!");
        
GivePlayerMoney(playerid50);
    }
    else
    {
        
format(string,sizeof(string),"Your number is %d",rand);
        
SendClientMessage(playeridCOLOR_REDstring);
        
GivePlayerMoney(playerid, -10);
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)