Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new dinviter[MAX_PLAYERS];
- new dinvitee[MAX_PLAYERS][8];
- CMD:duel(playerid)
- {
- if(isinDuel[playerid]) return SendClientMessage(playerid, 0xFF0000AA, "You are already in a duel.");
- ShowPlayerDialog(playerid, DIALOG_DUEL1, DIALOG_STYLE_LIST, "Choose a mode", "1 v 1\n2 v 2\n3 v 3\n4 v 4", "Select", "Cancel");
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_DUEL1:
- {
- if(response)
- {
- new did;
- for(new i=0;i<MAX_DUELS;i++)
- {
- if(DuelInfo[i][Mode] == 0)
- {
- did = i;
- break;
- }
- }
- duelid[playerid] = did;
- switch(listitem)
- {
- case 0:
- {
- DuelInfo[did][Mode] = 1; //1v1
- }
- case 1:
- {
- DuelInfo[did][Mode] = 2;//2v2
- }
- case 2:
- {
- DuelInfo[did][Mode] = 3;//3v3
- }
- case 3:
- {
- DuelInfo[did][Mode] = 4;//4v4
- }
- default:
- {
- DuelInfo[did][Mode] = 0;
- }
- }
- ShowPlayerDialog(playerid, DIALOG_DUEL2, DIALOG_STYLE_INPUT, "Choose Players", "Enter player's ID", "Select", "Cancel");
- }
- }
- case DIALOG_DUEL2:
- {
- if(response)
- {
- new pid = strval(inputtext);
- if(!IsPlayerConnected(pid)) return ShowPlayerDialog(playerid, DIALOG_DUEL2, DIALOG_STYLE_INPUT, "Choose Players", "PLAYER IS NOT CONNECTED\n\nEnter player's ID", "Select", "Cancel");
- new did = duelid[playerid];
- if(DuelInfo[did][Occupants][0] == INVALID_PLAYER_ID)
- {
- DuelInfo[did][Occupants][0] = pid;
- dinvitee[playerid][0] = pid;
- dinviter[pid] = playerid;
- duelid[pid] = did;
- }
- else if(DuelInfo[did][Occupants][1] == INVALID_PLAYER_ID)
- {
- DuelInfo[did][Occupants][1] = pid;
- dinvitee[playerid][1] = pid;
- dinviter[pid] = playerid;
- duelid[pid] = did;
- }
- else if(DuelInfo[did][Occupants][2] == INVALID_PLAYER_ID)
- {
- DuelInfo[did][Occupants][2] = pid;
- dinvitee[playerid][2] = pid;
- dinviter[pid] = playerid;
- duelid[pid] = did;
- }
- else if(DuelInfo[did][Occupants][3] == INVALID_PLAYER_ID)
- {
- DuelInfo[did][Occupants][3] = pid;
- dinvitee[playerid][3] = pid;
- dinviter[pid] = playerid;
- duelid[pid] = did;
- }
- else if(DuelInfo[did][Occupants][4] == INVALID_PLAYER_ID)
- {
- DuelInfo[did][Occupants][4] = pid;
- dinvitee[playerid][4] = pid;
- dinviter[pid] = playerid;
- duelid[pid] = did;
- }
- else if(DuelInfo[did][Occupants][5] == INVALID_PLAYER_ID)
- {
- DuelInfo[did][Occupants][5] = pid;
- dinvitee[playerid][5] = pid;
- dinviter[pid] = playerid;
- duelid[pid] = did;
- }
- else if(DuelInfo[did][Occupants][6] == INVALID_PLAYER_ID)
- {
- DuelInfo[did][Occupants][6] = pid;
- dinvitee[playerid][6] = pid;
- dinviter[pid] = playerid;
- duelid[pid] = did;
- }
- else if(DuelInfo[did][Occupants][7] == INVALID_PLAYER_ID)
- {
- DuelInfo[did][Occupants][7] = pid;
- dinvitee[playerid][7] = pid;
- dinviter[pid] = playerid;
- duelid[pid] = did;
- }
- if((DuelInfo[did][Mode] == 1 && DuelInfo[did][Occupants][0] != INVALID_PLAYER_ID) || (DuelInfo[did][Mode] == 2 && DuelInfo[did][Occupants][2] != INVALID_PLAYER_ID) || (DuelInfo[did][Mode] == 3 && DuelInfo[did][Occupants][4] != INVALID_PLAYER_ID) || (DuelInfo[did][Mode] == 4 && DuelInfo[did][Occupants][7] != INVALID_PLAYER_ID))
- {
- new info[500];
- format(info, 500, "ID\tWeapon\tAmmo\n\
- (22)\tColt 45\t100\n\
- (23)\tSilenced Pistol\t100\n\
- (24)\tDesert Eagle\t100\n\
- (25)\tShotgun\t70\n\
- (26)\tSawed-off Shotgun\t70\n\
- (27)\tSpas-12\t70\n\
- (28)\tMicro SMG(UZI)\t250\n\
- (29)\tMP5\t250\n\
- (30)\tAk-47\t500\n\
- (31)\tM4A1\t500\n\
- (32)\tTec 9\t250\n\
- (33)\tCountry Rifle\t50\n\
- (34)\tSniper Rifle\t50\n\"");
- ShowPlayerDialog(playerid, DIALOG_DUEL3, DIALOG_STYLE_TABLIST_HEADERS, "Choose weapons", info, "Select", "Cancel");
- }
- else
- {
- new info[1000];
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- new string[128];
- format(string, sizeof string, "[%d.] %s\n", i, GetName(i));
- strcat(info, string);
- }
- }
- ShowPlayerDialog(playerid, DIALOG_DUEL2, DIALOG_STYLE_INPUT, "Choose Players", "Enter player's ID", "Select", "Cancel");
- }
- }
- }
- case DIALOG_DUEL3:
- {
- if(response)
- {
- new did = duelid[playerid];
- if(DuelInfo[did][Weapons][0] == 0)
- {
- DuelInfo[did][Weapons][0] = listitem+22;
- }
- else if(DuelInfo[did][Weapons][1] == 0)
- {
- DuelInfo[did][Weapons][1] = listitem+22;
- }
- if(DuelInfo[did][Weapons][0] != 0 && DuelInfo[did][Weapons][1] != 0)
- {
- new str11[750],string[200];
- for(new i=0;i<sizeof(MapDArenas);i++)
- {
- format(string, sizeof(string), "%d\t%s\n",MapDArenas[i][dMapID],MapDArenas[i][dMapName]);
- strcat(str11, string);
- }
- format(string, sizeof(string), "Map ID\tMap Name\n%s", str11);
- ShowPlayerDialog(playerid, DIALOG_DUEL4, DIALOG_STYLE_TABLIST_HEADERS, "Duel Maps",
- string, "Enter", "Cancel");
- }
- else
- {
- new info[500];
- format(info, 500, "ID\tWeapon\tAmmo\n\
- (22)\tColt 45\t100\n\
- (23)\tSilenced Pistol\t100\n\
- (24)\tDesert Eagle\t100\n\
- (25)\tShotgun\t70\n\
- (26)\tSawed-off Shotgun\t70\n\
- (27)\tSpas-12\t70\n\
- (28)\tMicro SMG(UZI)\t250\n\
- (29)\tMP5\t250\n\
- (30)\tAk-47\t500\n\
- (31)\tM4A1\t500\n\
- (32)\tTec 9\t250\n\
- (33)\tCountry Rifle\t50\n\
- (34)\tSniper Rifle\t50\n\"");
- ShowPlayerDialog(playerid, DIALOG_DUEL3, DIALOG_STYLE_TABLIST_HEADERS, "Choose weapons", info, "Select", "Cancel");
- }
- }
- }
- case DIALOG_DUEL4:
- {
- if(response)
- {
- isinDuel[playerid] = true;
- new did = duelid[playerid];
- new rand = random(4);
- if(rand == 1)
- {
- SetPlayerPos(playerid, MapDArenas[listitem][dMapPosition][0], MapDArenas[listitem][dMapPosition][1], MapDArenas[listitem][dMapPosition][2]);
- SetPlayerFacingAngle(playerid, MapDArenas[listitem][dMapPosition][3]);
- }
- if(rand == 2)
- {
- SetPlayerPos(playerid, MapDArenas[listitem][dMapPosition1][0], MapDArenas[listitem][dMapPosition1][1], MapDArenas[listitem][dMapPosition1][2]);
- SetPlayerFacingAngle(playerid, MapDArenas[listitem][dMapPosition1][3]);
- }
- if(rand == 3)
- {
- SetPlayerPos(playerid, MapDArenas[listitem][dMapPosition2][0], MapDArenas[listitem][dMapPosition2][1], MapDArenas[listitem][dMapPosition2][2]);
- SetPlayerFacingAngle(playerid, MapDArenas[listitem][dMapPosition2][3]);
- }
- if(rand == 4)
- {
- SetPlayerPos(playerid, MapDArenas[listitem][dMapPosition3][0], MapDArenas[listitem][dMapPosition3][1], MapDArenas[listitem][dMapPosition3][2]);
- SetPlayerFacingAngle(playerid, MapDArenas[listitem][dMapPosition1][3]);
- }
- GivePlayerWeapon(playerid, DuelInfo[did][Weapons][0], 9999);
- GivePlayerWeapon(playerid, DuelInfo[did][Weapons][1], 9999);
- new string[70];
- format(string, sizeof(string), "You have joined the %s duel room", MapDArenas[listitem][dMapName]);
- SendClientMessage(playerid, 0x00FF00FF, string);
- SetTimerEx("Freeze",3000, false, "i", playerid);
- SetPlayerInterior(playerid, MapDArenas[listitem][MapInterior]);
- SetPlayerVirtualWorld(playerid, DUEL_VW);
- SetPlayerHealth(playerid, 100);
- SetPlayerArmour(playerid, 100);
- dmapchosen[playerid]=listitem;
- DuelInfo[did][Host] = playerid;
- for(new i=0; i<8; i++)
- {
- if(!IsPlayerConnected(i)) return 1;
- new mode[50];
- if(DuelInfo[did][Mode] == 1) format(mode, 50, "1 v 1");
- if(DuelInfo[did][Mode] == 2) format(mode, 50, "2 v 2");
- if(DuelInfo[did][Mode] == 3) format(mode, 50, "3 v 3");
- if(DuelInfo[did][Mode] == 4) format(mode, 50, "4 v 4");
- format(string, sizeof(string), "You have been invited to a %s duel by %s. /ad to accept or /dd to deny", mode, DuelInfo[did][Host]);
- SendClientMessage(dinvitee[playerid][i], 0x0000FFFF, string);
- printf("%i", dinvitee[playerid][i]);
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment