04.08.2016, 12:35
Ok i did it for you this time, np
PHP код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
new Bet[MAX_PLAYERS], Invited[MAX_PLAYERS], Dicetimer[MAX_PLAYERS], Guess[MAX_PLAYERS];
forward CancelBet(playerid);
public CancelBet(playerid)
{
Bet[playerid] = 0;
Invited[playerid] = 0;
Guess[playerid] = 0;
SendClientMessage(playerid, -1, "Dice bet invitation canceled. [15 Seconds passed]");
}
CMD:diceinvite(playerid, params[])
{
new id, bet, guess, name[25], string[100];
GetPlayerName(playerid, name, 25);
if(sscanf(params, "ui", id, bet, guess)) return SendClientMessage(playerid, -1, "{0008F7}USAGE: {FFFFFF}/DICEBET ID BET YOUR_GUESS[1-6]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Player is not connected");
if(GetPlayerMoney(playerid) < bet) return SendClientMessage(playerid, -1, "You cannot affrod this ammount");
if(GetPlayerMoney(id) < bet) return SendClientMessage(playerid, -1, "Player cannot affrod this ammount");
if(guess < 1 || guess > 6) return SendClientMessage(playerid, -1, "Invalid guess. [1-6]");
format(string, 100, "Dice Bet invitation from %s Price $%d. His guess %d. /DICEACCEPT YOUR_GUESS to accept it.", name, bet, guess);
SendClientMessage(id, -1, string);
SendClientMessage(playerid, -1, "Dice bet invitation Sent!");
Bet[playerid] = bet;
Bet[id] = bet;
Invited[playerid] = id;
Invited[id] = playerid;
Guess[playerid] = guess;
Dicetimer[playerid] = SetTimerEx("CancelBet", 15000, false, "i", playerid);
Dicetimer[id] = SetTimerEx("CancelBet", 15000, false, "i", id);
return 1;
}
CMD:diceaccept(playerid, params[])
{
new guess, name[25], iname[25], string[100];
GetPlayerName(playerid, name, 25);
if(sscanf(params, "i", guess)) return SendClientMessage(playerid, -1, "{0008F7}USAGE: {FFFFFF}/DICEACCEPT YOUR_GUESS[1-6]");
if(Invited[playerid] == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player disconnected or your not invited to any Dicebet");
if(guess < 1 || guess > 6) return SendClientMessage(playerid, -1, "Invalid guess. [1-6]");
GetPlayerName(Invited[playerid], iname, 25);
KillTimer(Dicetimer[playerid]);
KillTimer(Dicetimer[Invited[playerid]]);
new rand = random(5);
if(rand == Guess[playerid]-1)
{
format(string, 100, "%s have won the Dicebet against %s and won %d", name, iname, Bet[playerid]);
SendClientMessageToAll(-1, string);
GivePlayerMoney(playerid, Bet[playerid]);
GivePlayerMoney(Invited[playerid], -Bet[playerid]);
}
else if(rand == Guess[Invited[playerid]]-1)
{
format(string, 100, "%s have won the Dicebet against %s and won %d", iname, name, Bet[playerid]);
SendClientMessageToAll(-1, string);
GivePlayerMoney(playerid, -Bet[playerid]);
GivePlayerMoney(Invited[playerid], Bet[playerid]);
}
else SendClientMessage(playerid, -1, "No one won!"), SendClientMessage(Invited[playerid], -1, "No one won!");
Bet[playerid] = 0;
Invited[playerid] = 0;
Guess[playerid] = 0;
Bet[Invited[playerid]] = 0;
Invited[Invited[playerid]] = 0;
Guess[Invited[playerid]] = 0;
return 1;
}