11.04.2017, 22:55
PHP код:
CMD:bet(playerid,params[])
{
new option[64],string[128], amount;
new idx = GetPlayerVirtualWorld(playerid)-100;
if(BizInfo[idx][bType] == 7)
{
if(!IsAtRLTable(playerid))
{
SendClientMessage(playerid, error, "You are not near a Roulette table!");
return 1;
}
new ball = random(4);
if(sscanf(params, "s[8]i", option,amount)) return SendClientMessage(playerid, error, "Usage: /bet [Red/Black][$Amount]");
if(amount < 1 || amount > 50000) return SendClientMessage(playerid, error, "Bet can't be below $1 or above $50,000!");
if(!strcmp(option, "red", true))
{
if(ball == 1)
{
format(string, sizeof(string), "* %s bets on red and won.", GetName(playerid));
ProxDetector(5.0, playerid, string, -1);
format(string, sizeof(string), "* You won $%d.", amount);
SendClientMessage(playerid, -1, string);
pInfo[playerid][Cash] += amount;
GivePlayerCash(playerid, amount);
BizInfo[idx][bMoney] -= amount;
}
else
{
format(string, sizeof(string), "* %s bets on red and lost.", GetName(playerid));
ProxDetector(5.0, playerid, string,-1);
format(string, sizeof(string), "* You lost $%d.", amount);
SendClientMessage(playerid, -1, string);
pInfo[playerid][Cash] -= amount;
GivePlayerCash(playerid, -amount);
BizInfo[idx][bMoney] += amount;
}
if(!strcmp(option, "black", true))
{
if(mblack < 1 || mblack > 50000) return SendClientMessage(playerid, error, "Bet can't be below $1 or above $50,000!");
if(ball == 1)
{
format(string, sizeof(string), "* %s bets on black and won.", GetName(playerid));
ProxDetector(5.0, playerid, string, -1);
format(string, sizeof(string), "* You won $%d.", amount);
SendClientMessage(playerid, -1, string);
pInfo[playerid][Cash] += amount;
GivePlayerCash(playerid, amount);
BizInfo[idx][bMoney] -= amount;
}
else
{
format(string, sizeof(string), "* %s bets on black and lost.", GetName(playerid));
ProxDetector(5.0, playerid, string, -1);
format(string, sizeof(string), "* You lost $%d.", amount);
SendClientMessage(playerid, -1, string);
pInfo[playerid][Cash] -= amount;
GivePlayerMoney(playerid, -amount);
BizInfo[idx][bMoney] += amount;
}
}
}
}
return 1;
}
EDIT: I've edited the code a bit. Try this