duel system help
#1

How can I make duel system like this:

/duel [playerid] [bet], choose weapon1 on dialog, choose weapon2 on dialog, and next choose the map...
and shows player2 the duel invitation dialog

Tell me the structure how can I make it, please. Then I'll come back here if I need help with that
Reply
#2

PHP код:
#define dueldialog 242
#define DuelPlace1 -1401.5426,1267.2721,1039.8672
#define DuelPlace2 -1388.0773,1225.5911,1039.8672 
PHP код:
new DuelAllowed[MAX_PLAYERS];
new 
DVeh[MAX_PLAYERS];
new 
DuelOffer[MAX_PLAYERS];
new 
counttime[MAX_PLAYERS] = -1;
new 
DuelWeaponName[128];
new 
DuelTypeBetInDuel[MAX_PLAYERS], declinedueltimerDuelPlayer1DuelPlayer2ProgressDUEL_TIMER
PHP код:
#define PATH "/Users/%s.ini"
enum pEnum
{
    
pDuelsWon,
    
pDuelsLost,

PHP код:
//stats saving 1
forward LoadUser_data(playerid,name[],value[]);
public 
LoadUser_data(playerid,name[],value[])
{
    
INI_Int("DuelsWon",PlayerInfo[playerid][pDuelsWon]);
    
INI_Int("DuelsLost",PlayerInfo[playerid][pDuelsLost]);
    return 
1;

PHP код:
public OnGameModeInit()
{
        
DuelPlayer1 0;
        
DuelPlayer2 0;
        
Progress 0;
        
DuelType 0;
        
Bet 0;
        
CD 0;
        
CreateObject(136573541.7075,1721.0681,280.96640.0000000,0.0000000,0.00000001000);

PHP код:
public OnGameModeExit()
{
    
KillTimer(CDTimer);
    
KillTimer(DUEL_TIMER);

PHP код:
public OnPlayerConnect(playerid)
{
    
InDuel[playerid] = 0;
    
DuelOffer[playerid] = 0;
    
DuelAllowed[playerid] = 1;
    

PHP код:
OnPlayerDisconect
    
if(InDuel[playerid] == 1)
    {
        new 
msg[128];
        
format(msgsizeof(msg), "Duel Between %s (%d) and %s (%d) Has Ended. Reason: {ff0000}Disconnected!"PlayerInfo[DuelPlayer1][pName], DuelPlayer1PlayerInfo[DuelPlayer2][pName], DuelPlayer2);
        
SendClientMessageToAll(COLOR_SERVER_HELP_MSGmsg);
        
Progress 0;
        
InDuel[DuelPlayer1] = 0;
        
InDuel[DuelPlayer2] = 0;
        
KillTimer(DUEL_TIMER);
        
PlayerDualWatching[playerid] = 0;
        
SpawnPlayer(DuelPlayer1);
        
SetPlayerVirtualWorld(DuelPlayer10);
        
SetPlayerVirtualWorld(DuelPlayer10);
        
SpawnPlayer(DuelPlayer2);
        
SetPlayerVirtualWorld(DuelPlayer20);
        
SetPlayerVirtualWorld(DuelPlayer20);
     } 
PHP код:
OnPlayerDeath
    
if(InDuel[playerid] == 1)
    {
        new 
msg[128];
        
format(msgsizeof(msg), "Duel Between %s (%d) and %s (%d) Has Ended. Reason: {ff0000}Player Died!"PlayerInfo[DuelPlayer1][pName], DuelPlayer1PlayerInfo[DuelPlayer2][pName], DuelPlayer2);
        
SendClientMessageToAll(COLOR_SERVER_HELP_MSGmsg);
        
Progress 0;
        
InDuel[DuelPlayer1] = 0;
        
InDuel[DuelPlayer2] = 0;
        
KillTimer(DUEL_TIMER);
        
SpawnPlayer(DuelPlayer1);
        
SetPlayerVirtualWorld(DuelPlayer10);
        
SpawnPlayer(DuelPlayer2);
        
SetPlayerVirtualWorld(DuelPlayer20);
     }
    if(
InDuel[playerid] == && InDuel[killerid] == 1)
    {
        
GiveCash(killerid2*Bet);
        new 
Float:HealthFloat:Armour1string1[128];
        
GetPlayerArmour(killeridArmour1);
        
GetPlayerHealth(killeridHealth);
        
format(string1sizeof(string1), "[DUEL] %s (%d) Has Won The Duel From %s (%d) And Still Has %.2f {ff0000}Health Left."PlayerInfo[killerid][pName], killeridPlayerInfo[playerid][pName], playeridHealth);
        
SendClientMessageToOthers(killerid,COLOR_SERVER_HELP_MSGstring1);
        new 
str[128];
        
format(strsizeof(str), "[DUEL]: You Have Won The Duel Against %s (%d) And Gained {ff0000}$%d."PlayerInfo[playerid][pName], playeridBet);
        
SendClientMessage(killeridCOLOR_SERVER_HELP_MSGstr);
        
PlayerInfo[killerid][pDuelsWon] ++;
        
PlayerInfo[playerid][pDuelsLost] ++;
        
SpawnPlayer(killerid);
        
SetPlayerVirtualWorld(playerid0);
        
SetPlayerVirtualWorld(killerid0);
        
Progress 0;
        
InDuel[playerid] = 0;
        
InDuel[killerid] = 0;
        
SetPlayerVirtualWorld(playerid0);
        
SetPlayerVirtualWorld(killerid0);
        
KillTimer(DUEL_TIMER);
        return 
1;
    } 
PHP код:
COMMAND:aduel(playerid,params[])
{
        new 
idx;
         new 
tmp[256];  tmp  strtok(params,idx);
        new 
tmp2[256]; tmp2 strtok(params,idx);
        if(
PlayerInfo[playerid][pAdminlevel] > 0)
        {
        if(!
strlen(tmp) || !strlen(tmp2))
        {
        
SendClientMessage(playeridCOLOR_ERROR"USAGE: /aduel [playerid 1] [playerid 2]");
        return 
1;
        }
        new 
TargetID strval(tmp);
        new 
TargetID2 strval(tmp2);
        new 
string[256];
        if(
TargetID == TargetID2)
        {
        
SendClientMessage(playeridCOLOR_ERROR"You Need to Write 2 Different ID.");
        return 
1;
        }
         if(!
IsPlayerConnected(TargetID2))
        {
        
SendClientMessage(playeridCOLOR_ERROR"ERROR: Player Two is Not Connected");
        return 
1;
        }
        
SetPlayerInterior(playerid1);
        
SetPlayerPos(playerid1374.0948,5.5511,1008.1563);
        
SetPlayerInterior(TargetID1);
        
SetPlayerPos(TargetID,1413.1495,-15.9198,1000.9246);
        
SetPlayerInterior(TargetID21);
        
SetPlayerPos(TargetID2,1367.6084,-17.7317,1000.9219);
        
SetPlayerVirtualWorld(playerid0);
        
SetPlayerVirtualWorld(TargetID0);
        
SetPlayerVirtualWorld(TargetID20);
        
format(stringsizeof(string), "In Duel Challenge");
        
strmid(PlayerInfo[TargetID][pInteriorName], string0strlen(string), 256);
        
strmid(PlayerInfo[TargetID][pLocation], string0strlen(string), 256);
        
format(stringsizeof(string), "In Duel Challenge");
        
strmid(PlayerInfo[TargetID2][pInteriorName], string0strlen(string), 256);
        
strmid(PlayerInfo[TargetID2][pLocation], string0strlen(string), 256);
        
counttime[TargetID] = 5;
        
SetTimerEx("Duel",1000,0,"dd"TargetIDTargetID2);
        
format(stringsizeof(string), "***An Admin Has Started a 1v1 Private Duel Between %s (%d) and %s (%d).",PlayerInfo[TargetID][pName],TargetID,PlayerInfo[TargetID2][pName],TargetID2);
        
SendClientMessageToOthers(playeridCOLOR_ADMINstring);
        
format(stringsizeof(string), "***An Admin Has Started a 1v1 Duel Between You and %s (%d).",PlayerInfo[TargetID2][pName],TargetID2);
        
SendClientMessage(TargetIDCOLOR_ADMINstring);
        
format(stringsizeof(string), "***An Admin Has Started a 1v1 Duel Between You and %s (%d).",PlayerInfo[TargetID][pName],TargetID);
        
SendClientMessage(TargetID2COLOR_ADMINstring);
        }else{
        
SendClientMessage(playerid,COLOR_ERROR,""ERROR_MSG"");
        }
        return 
1;
}
COMMAND:duel(playeridparams[])
{
    new 
TargetIDDuelBet;
    if(
sscanf(params"ui"TargetIDDuelBet))
    {
    
SendClientMessage(playeridCOLOR_ERROR,"USAGE: /duel [PlayerID] [Bet]");
    return 
1;
    }
    if(!
IsPlayerConnected(TargetID) || TargetID == INVALID_PLAYER_ID)
    {
    
SendClientMessage(playeridCOLOR_ERROR"That Player Is Not Connected.");
    return 
1;
    }
    if(
InSniper[playerid] == 1)
    {
    
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Use This Command In Sniper DM.");
    return 
1;
    }
    if(
DuelAllowed[playerid] == 0)
    {
    
SendClientMessage(playeridCOLOR_ERROR"You Must Have to Allow Duels In Order To Invite Some 1 For Duel.");
    return 
1;
    }
    if(
DuelAllowed[TargetID] == 0)
    {
    
SendClientMessage(playeridCOLOR_ERROR"That Player Has His Duel Invitations OFF.");
    return 
1;
    }
    if(
Progress == 2)
    {
    
SendClientMessage(playeridCOLOR_ERROR"Duel Is In Progress");
    return 
1;
    }
    if(
Progress == 1)
    {
    
SendClientMessage(playeridCOLOR_ERROR,"Someone Is Inviting Someone else To A Duel, Please Wait..");
    return 
1;
    }
    if(
GetPlayerCash(playerid) < DuelBet && DuelBet != 0)
    {
    
SendClientMessage(playeridCOLOR_ERROR"You Don't Have That Much Money.");
    return 
1;
    }
    if(
GetPlayerCash(TargetID) < DuelBet && DuelBet != 0)
    {
    
SendClientMessage(playeridCOLOR_ERROR"That Player Doesn't Have That Much Amount of Money!");
    return 
1;
    }
    if(
DuelBet 1000 || DuelBet 250000)
    {
    
SendClientMessage(playeridCOLOR_ERROR"Bet Range: $1000 - 250000.");
    return 
1;
    }
    if(
TargetID == playerid)
    {
    
SendClientMessage(playeridCOLOR_ERROR"You Cannot Duel Yourself.");
    return 
1;
    }
    
DuelPlayer2 TargetID;
    
DuelPlayer1 playerid;
    
Bet DuelBet;
    
Progress 1;
    
ShowPlayerDialog(playeriddueldialog DIALOG_STYLE_LIST"{00ff2a}Duel Weapons:""{FFFFFF}Sawn-off Shotgun\nDesert Eagle\nTEC-9\nM4\nAk47\nColt-45 / 9mm\nSawn-off Shotgun + TEC-9 + Deagle\nM4 + Deagle\nSniper + M4""Choose""Cancel");
    return 
1;
}
COMMAND:acduel(playeridparams[])
{
    return 
cmd_acceptduel(playeridparams);
}
COMMAND:acceptduel(playeridparams[])
{
    new 
string[256];
    if(
PlayerInfo[playerid][pSpawned] == 1)
    {
    if(
InDuel[playerid] == 1)
    {
    
SendClientMessage(playerid,COLOR_ERROR,"You Are Already in Duel Challenge.");
    return 
1;
    }
    if(
DuelOffer[playerid] == 1)
    {
    
format(stringsizeof(string), "[DUEL] The Duel Between %s (%d) and %s (%d) Has Started. (Bet: $%d)"PlayerInfo[DuelPlayer1][pName], DuelPlayer1PlayerInfo[DuelPlayer2][pName], DuelPlayer2Bet);
    
SendClientMessageToAll(COLOR_SERVER_HELP_MSGstring);
    
SetPlayerPosEx(DuelPlayer1,DuelPlace1,199.2980,16,0);
    
SetPlayerPosEx(DuelPlayer2,DuelPlace2,23.539716,0);
    
SetPlayerHealth(DuelPlayer1100);
    
SetPlayerHealth(DuelPlayer2100);
    
SetPlayerArmour(DuelPlayer1100);
    
SetPlayerArmour(DuelPlayer2100);
    
format(stringsizeof(string), "In Duel Challenge");
    
strmid(PlayerInfo[DuelPlayer1][pInteriorName], string0strlen(string), 256);
    
strmid(PlayerInfo[DuelPlayer1][pLocation], string0strlen(string), 256);
    
format(stringsizeof(string), "In Duel Challenge");
    
strmid(PlayerInfo[DuelPlayer2][pInteriorName], string0strlen(string), 256);
    
strmid(PlayerInfo[DuelPlayer2][pLocation], string0strlen(string), 256);
    
GiveCash(DuelPlayer1, -Bet);
    
GiveCash(DuelPlayer2, -Bet);
    
SetPlayerVirtualWorld(DuelPlayer12);
    
SetPlayerVirtualWorld(DuelPlayer22);
    
TogglePlayerControllable(DuelPlayer1false);
    
TogglePlayerControllable(DuelPlayer2false);
    
SetCameraBehindPlayer(DuelPlayer1);
    
SetCameraBehindPlayer(DuelPlayer2);
    
InDuel[DuelPlayer1] = 1;
    
InDuel[DuelPlayer2] = 1;
    
Progress 2;
    
GiveDuelWeapons(DuelType);
    
PlayerInfo[DuelPlayer1][pDrugsTime] = 0;
    
PlayerInfo[DuelPlayer2][pDrugsTime] = 0;
    
ON_DRUGS[DuelPlayer1] = 0;
    
ON_DRUGS[DuelPlayer2] = 0;
    
DrugsTaken[DuelPlayer1] = 0;
    
DrugsTaken[DuelPlayer2] = 0;
    
CD 6;
    
CDTimer SetTimer("CountDown"10001);
    
KillTimer(declinedueltimer);
    
DUEL_TIMER SetTimer("TIMEUP"60000*30);
    }else{
    
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Accept Duel, No One Sent You Duel Challenge.");
    }
    }else{
    
SendClientMessage(playeridCOLOR_ERROR"You Cannot Use This Command While You're Dead.");
    }
    return 
1;
}
COMMAND:refuseduel(playeridparams[])
{
    if(
PlayerInfo[playerid][pSpawned] == 1)
    {
    if(
DuelOffer[playerid] == 1)
    {
    
DuelDeclined();
    }else{
    
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Refuse Duel, No One Sent You Duel Challenge.");
    }
    }else{
    
SendClientMessage(playeridCOLOR_ERROR"You Cannot Use This Command While You're Dead.");
    }
    return 
1;
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)