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;
}
format(string,sizeof(string),"Your number is %d",rand); // %d instead of %i
random(1-5)
random(5)
|
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;
}
|
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;
}
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;
}