Код:
new bool:dicecheck[MAX_PLAYERS];
//top <>
CMD:dice(playerid, params[])
{
if(!dicecheck[playerid])
{
new targetid, str2[180], bet;
if(sscanf(params, "ui", targetid, bet)) return SCM(playerid, -1, "/dice [playerid] [money]");
if(targetid == INVALID_PLAYER_ID) return SCM(playerid, -1, "Player Isnt Connected.");
new mymoney = (GetPlayerMoney(playerid));
new targetmoney = (GetPlayerMoney(targetid));
if(bet>mymoney) return SCM(playerid, -1, "You Dont Have That Amount Of Money.");
if(bet>targetmoney) return SCM(playerid, -1, "He Dont Have Enough Money.");
if(bet >= mymoney, targetmoney)
{
new pname[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
GetPlayerName(targetid, tname, MAX_PLAYER_NAME);
format(str2, sizeof(str2), "[%i] %s Sent You Dice with %i .", playerid, pname, bet);
SCM(playerid, -1, "Dice Sent.");
SCM(targetid, -1, str2);
dicecheck[playerid]=true;
}
}else
{
SCM(playerid, -1, "You Already sent dice to this player.");
}
return 1;
}
CMD:acceptdice(playerid, params[])
{
new bet, targetid;
if(sscanf(params, "ui", targetid, bet)) return SCM(playerid, -1, "/acceptdice[id][money]");
if(dicecheck[targetid] == false) return SCM(playerid, -1, "Player did not send a dice request.");
dicecheck[targetid] =false;
if(dicecheck[targetid] == true)
{
new player1;
player1 = random(2);
if(player1 == 1)
{
new string[128];
new string2[128];
format(string, sizeof(string), "You win %i", bet);
format(string2, sizeof(string2), "You lose %i", bet);
SCM(targetid, Green, string2);
SCM(playerid, Green, string);
GivePlayerMoney(playerid, bet);
GivePlayerMoney(targetid, -bet);
dicecheck[targetid] =false;
}
if(player1 == 2)
{
new string[128];
new string2[128];
format(string, sizeof(string), "You lose %i", bet);
format(string2, sizeof(string2), "You win %i", bet);
SCM(playerid,0xCC0000 , string);
SCM(targetid,0xCC0000 , string2);
GivePlayerMoney(targetid, bet);
GivePlayerMoney(playerid, -bet);
dicecheck[targetid] =false;
}
}
return 1;
}
////////////////////////////////////////////