Random number wont display
#4

Quote:
Originally Posted by ExtendedCarbon
Посмотреть сообщение
I'm trying to make a random thing
Код:
CMD:gamble(playerid, params[])
{
    new rand = random(1-5);
	new string[64];
	format(string,sizeof(string),"Your number is %i",rand);
    GivePlayerMoney(playerid, -10);
    if(rand == 3)
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Your number landed on 3, and you won 50 dollars!");
    }
    else
    {
		SendClientMessage(playerid, COLOR_RED, string);
    }
    return 1;
}
But it shows up in game as "Your number is123124313412"
Try this:
Код:
CMD:gamble(playerid, params[])
{
    new rand = random(1-5);
	new string[64];
	format(string,sizeof(string),"Your number is %i",rand);
    GivePlayerMoney(playerid, -10);
    if(rand == 3)
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Your number landed on 3, and you won 50 dollars!");
    }
    else
    {
		SendClientMessage(playerid, COLOR_RED, string);
                return 1;
    }
    return 1;
}
or other method like this:

Код:
CMD:gamble(playerid, params[])
{
    switch(random(5))
    {
        case 0:
        {
		SendClientMessage(playerid, COLOR_RED, "Your number is 1");
	}
        case 1:
        {
		SendClientMessage(playerid, COLOR_RED, "Your number is 2");
        }
	case 2:
	{
             SendClientMessage(playerid, COLOR_YELLOW, "Your number landed on 3, and you won 50 dollars!");
	}
	case 3:
	{
		SendClientMessage(playerid, COLOR_RED, "Your number is 4");
	}
	case 4:
	{
		SendClientMessage(playerid, COLOR_RED, "Your number is 5");
	}
    }
    return 1;
}
Reply


Messages In This Thread
Random number wont display - by ExtendedCarbon - 14.09.2013, 20:32
Re: Random number wont display - by DanishHaq - 14.09.2013, 20:35
Re: Random number wont display - by Scenario - 14.09.2013, 20:40
Re: Random number wont display - by Gilbonzo - 14.09.2013, 20:45

Forum Jump:


Users browsing this thread: 1 Guest(s)