#6

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(playeridparams[])
{
    new 
idbetguessname[25], string[100];
    
GetPlayerName(playeridname25);
    if(
sscanf(params"ui"idbetguess)) 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 || guess 6) return SendClientMessage(playerid, -1"Invalid guess. [1-6]");
    
format(string100"Dice Bet invitation from %s Price $%d. His guess %d. /DICEACCEPT YOUR_GUESS to accept it."namebetguess);
    
SendClientMessage(id, -1string);
    
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"15000false"i"playerid);
    
Dicetimer[id] = SetTimerEx("CancelBet"15000false"i"id);
    return 
1;
}

CMD:diceaccept(playeridparams[])
{
    new 
guessname[25], iname[25], string[100];
    
GetPlayerName(playeridname25);
    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 || guess 6) return SendClientMessage(playerid, -1"Invalid guess. [1-6]");
    
GetPlayerName(Invited[playerid], iname25);
    
KillTimer(Dicetimer[playerid]);
    
KillTimer(Dicetimer[Invited[playerid]]);
    new 
rand random(5);
    if(
rand == Guess[playerid]-1)
    {
        
format(string100"%s have won the Dicebet against %s and won %d"nameinameBet[playerid]);
        
SendClientMessageToAll(-1string);
        
GivePlayerMoney(playeridBet[playerid]);
        
GivePlayerMoney(Invited[playerid], -Bet[playerid]);
    }
    else if(
rand == Guess[Invited[playerid]]-1)
    {
        
format(string100"%s have won the Dicebet against %s and won %d"inamenameBet[playerid]);
        
SendClientMessageToAll(-1string);
        
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;

Reply


Messages In This Thread
Dice - by Rix70 - 04.08.2016, 11:10
Re: Dice - by Rix70 - 04.08.2016, 11:13
Re: Dice - by Shinja - 04.08.2016, 11:34
Re: Dice - by Rix70 - 04.08.2016, 11:56
Re: Dice - by SickAttack - 04.08.2016, 12:05
Re: Dice - by Shinja - 04.08.2016, 12:35
Re: Dice - by Rix70 - 04.08.2016, 13:20
Re: Dice - by Shinja - 04.08.2016, 13:52
Re: Dice - by Rix70 - 04.08.2016, 13:59
Re: Dice - by Shinja - 04.08.2016, 14:19

Forum Jump:


Users browsing this thread: 2 Guest(s)