NealPeteros

Duel

Jan 2nd, 2018
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.22 KB | None | 0 0
  1. new dinviter[MAX_PLAYERS];
  2. new dinvitee[MAX_PLAYERS][8];
  3.  
  4. CMD:duel(playerid)
  5. {
  6.     if(isinDuel[playerid]) return SendClientMessage(playerid, 0xFF0000AA, "You are already in a duel.");
  7.     ShowPlayerDialog(playerid, DIALOG_DUEL1, DIALOG_STYLE_LIST, "Choose a mode", "1 v 1\n2 v 2\n3 v 3\n4 v 4", "Select", "Cancel");
  8.     return 1;
  9. }
  10.  
  11. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  12. {
  13.     switch(dialogid)
  14.     {
  15.         case DIALOG_DUEL1:
  16.         {
  17.             if(response)
  18.             {
  19.                 new did;
  20.                 for(new i=0;i<MAX_DUELS;i++)
  21.                 {
  22.                     if(DuelInfo[i][Mode] == 0)
  23.                     {
  24.                         did = i;
  25.                         break;
  26.                     }
  27.                 }
  28.                 duelid[playerid] = did;
  29.                 switch(listitem)
  30.                 {
  31.                     case 0:
  32.                     {
  33.                         DuelInfo[did][Mode] = 1; //1v1
  34.                     }
  35.                     case 1:
  36.                     {
  37.                         DuelInfo[did][Mode] = 2;//2v2
  38.                     }
  39.                     case 2:
  40.                     {
  41.                         DuelInfo[did][Mode] = 3;//3v3
  42.                     }
  43.                     case 3:
  44.                     {
  45.                         DuelInfo[did][Mode] = 4;//4v4
  46.                     }
  47.                     default:
  48.                     {
  49.                         DuelInfo[did][Mode] = 0;
  50.                     }
  51.                 }
  52.                 ShowPlayerDialog(playerid, DIALOG_DUEL2, DIALOG_STYLE_INPUT, "Choose Players", "Enter player's ID", "Select", "Cancel");
  53.             }
  54.         }
  55.         case DIALOG_DUEL2:
  56.         {
  57.             if(response)
  58.             {
  59.                 new pid = strval(inputtext);
  60.                 if(!IsPlayerConnected(pid)) return ShowPlayerDialog(playerid, DIALOG_DUEL2, DIALOG_STYLE_INPUT, "Choose Players", "PLAYER IS NOT CONNECTED\n\nEnter player's ID", "Select", "Cancel");
  61.                 new did = duelid[playerid];
  62.                 if(DuelInfo[did][Occupants][0] == INVALID_PLAYER_ID)
  63.                 {
  64.                     DuelInfo[did][Occupants][0] = pid;
  65.                     dinvitee[playerid][0] = pid;
  66.                     dinviter[pid] = playerid;
  67.                     duelid[pid] = did;
  68.                 }
  69.                 else if(DuelInfo[did][Occupants][1] == INVALID_PLAYER_ID)
  70.                 {
  71.                     DuelInfo[did][Occupants][1] = pid;
  72.                     dinvitee[playerid][1] = pid;
  73.                     dinviter[pid] = playerid;
  74.                     duelid[pid] = did;
  75.                 }
  76.                 else if(DuelInfo[did][Occupants][2] == INVALID_PLAYER_ID)
  77.                 {
  78.                     DuelInfo[did][Occupants][2] = pid;
  79.                     dinvitee[playerid][2] = pid;
  80.                     dinviter[pid] = playerid;
  81.                     duelid[pid] = did;
  82.                 }
  83.                 else if(DuelInfo[did][Occupants][3] == INVALID_PLAYER_ID)
  84.                 {
  85.                     DuelInfo[did][Occupants][3] = pid;
  86.                     dinvitee[playerid][3] = pid;
  87.                     dinviter[pid] = playerid;
  88.                     duelid[pid] = did;
  89.                 }
  90.                 else if(DuelInfo[did][Occupants][4] == INVALID_PLAYER_ID)
  91.                 {
  92.                     DuelInfo[did][Occupants][4] = pid;
  93.                     dinvitee[playerid][4] = pid;
  94.                     dinviter[pid] = playerid;
  95.                     duelid[pid] = did;
  96.                 }
  97.                 else if(DuelInfo[did][Occupants][5] == INVALID_PLAYER_ID)
  98.                 {
  99.                     DuelInfo[did][Occupants][5] = pid;
  100.                     dinvitee[playerid][5] = pid;
  101.                     dinviter[pid] = playerid;
  102.                     duelid[pid] = did;
  103.                 }
  104.                 else if(DuelInfo[did][Occupants][6] == INVALID_PLAYER_ID)
  105.                 {
  106.                     DuelInfo[did][Occupants][6] = pid;
  107.                     dinvitee[playerid][6] = pid;
  108.                     dinviter[pid] = playerid;
  109.                     duelid[pid] = did;
  110.                 }
  111.                 else if(DuelInfo[did][Occupants][7] == INVALID_PLAYER_ID)
  112.                 {
  113.                     DuelInfo[did][Occupants][7] = pid;
  114.                     dinvitee[playerid][7] = pid;
  115.                     dinviter[pid] = playerid;
  116.                     duelid[pid] = did;
  117.                 }
  118.                 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))
  119.                 {
  120.                     new info[500];
  121.                     format(info, 500, "ID\tWeapon\tAmmo\n\
  122.                         (22)\tColt 45\t100\n\
  123.                         (23)\tSilenced Pistol\t100\n\
  124.                         (24)\tDesert Eagle\t100\n\
  125.                         (25)\tShotgun\t70\n\
  126.                         (26)\tSawed-off Shotgun\t70\n\
  127.                         (27)\tSpas-12\t70\n\
  128.                         (28)\tMicro SMG(UZI)\t250\n\
  129.                         (29)\tMP5\t250\n\
  130.                         (30)\tAk-47\t500\n\
  131.                         (31)\tM4A1\t500\n\
  132.                         (32)\tTec 9\t250\n\
  133.                         (33)\tCountry Rifle\t50\n\
  134.                         (34)\tSniper Rifle\t50\n\"");
  135.                     ShowPlayerDialog(playerid, DIALOG_DUEL3, DIALOG_STYLE_TABLIST_HEADERS, "Choose weapons", info, "Select", "Cancel");
  136.                 }
  137.                 else
  138.                 {
  139.                     new info[1000];
  140.                     for(new i; i < MAX_PLAYERS; i++)
  141.                     {
  142.                         if(IsPlayerConnected(i))
  143.                         {
  144.                             new string[128];
  145.                             format(string, sizeof string, "[%d.] %s\n", i, GetName(i));
  146.                             strcat(info, string);
  147.                         }
  148.                     }
  149.                     ShowPlayerDialog(playerid, DIALOG_DUEL2, DIALOG_STYLE_INPUT, "Choose Players", "Enter player's ID", "Select", "Cancel");
  150.                 }
  151.             }
  152.         }
  153.         case DIALOG_DUEL3:
  154.         {
  155.             if(response)
  156.             {
  157.                 new did = duelid[playerid];
  158.                 if(DuelInfo[did][Weapons][0] == 0)
  159.                 {
  160.                     DuelInfo[did][Weapons][0] = listitem+22;
  161.                 }
  162.                 else if(DuelInfo[did][Weapons][1] == 0)
  163.                 {
  164.                     DuelInfo[did][Weapons][1] = listitem+22;
  165.                 }
  166.                 if(DuelInfo[did][Weapons][0] != 0 && DuelInfo[did][Weapons][1] != 0)
  167.                 {
  168.                     new str11[750],string[200];
  169.                     for(new i=0;i<sizeof(MapDArenas);i++)
  170.                     {
  171.                         format(string, sizeof(string), "%d\t%s\n",MapDArenas[i][dMapID],MapDArenas[i][dMapName]);
  172.                         strcat(str11, string);
  173.                     }
  174.                     format(string, sizeof(string), "Map ID\tMap Name\n%s", str11);
  175.  
  176.                     ShowPlayerDialog(playerid, DIALOG_DUEL4, DIALOG_STYLE_TABLIST_HEADERS, "Duel Maps",
  177.                         string, "Enter", "Cancel");
  178.                 }
  179.                 else
  180.                 {
  181.                     new info[500];
  182.                     format(info, 500, "ID\tWeapon\tAmmo\n\
  183.                         (22)\tColt 45\t100\n\
  184.                         (23)\tSilenced Pistol\t100\n\
  185.                         (24)\tDesert Eagle\t100\n\
  186.                         (25)\tShotgun\t70\n\
  187.                         (26)\tSawed-off Shotgun\t70\n\
  188.                         (27)\tSpas-12\t70\n\
  189.                         (28)\tMicro SMG(UZI)\t250\n\
  190.                         (29)\tMP5\t250\n\
  191.                         (30)\tAk-47\t500\n\
  192.                         (31)\tM4A1\t500\n\
  193.                         (32)\tTec 9\t250\n\
  194.                         (33)\tCountry Rifle\t50\n\
  195.                         (34)\tSniper Rifle\t50\n\"");
  196.                     ShowPlayerDialog(playerid, DIALOG_DUEL3, DIALOG_STYLE_TABLIST_HEADERS, "Choose weapons", info, "Select", "Cancel");
  197.                 }
  198.             }
  199.         }
  200.         case DIALOG_DUEL4:
  201.         {
  202.             if(response)
  203.             {
  204.                 isinDuel[playerid] = true;
  205.                 new did = duelid[playerid];
  206.                 new rand = random(4);
  207.                 if(rand == 1)
  208.                 {
  209.                     SetPlayerPos(playerid, MapDArenas[listitem][dMapPosition][0], MapDArenas[listitem][dMapPosition][1], MapDArenas[listitem][dMapPosition][2]);
  210.                     SetPlayerFacingAngle(playerid, MapDArenas[listitem][dMapPosition][3]);
  211.                 }
  212.                 if(rand == 2)
  213.                 {
  214.                     SetPlayerPos(playerid, MapDArenas[listitem][dMapPosition1][0], MapDArenas[listitem][dMapPosition1][1], MapDArenas[listitem][dMapPosition1][2]);
  215.                     SetPlayerFacingAngle(playerid, MapDArenas[listitem][dMapPosition1][3]);
  216.                 }
  217.                 if(rand == 3)
  218.                 {
  219.                     SetPlayerPos(playerid, MapDArenas[listitem][dMapPosition2][0], MapDArenas[listitem][dMapPosition2][1], MapDArenas[listitem][dMapPosition2][2]);
  220.                     SetPlayerFacingAngle(playerid, MapDArenas[listitem][dMapPosition2][3]);
  221.                 }
  222.                 if(rand == 4)
  223.                 {
  224.                     SetPlayerPos(playerid, MapDArenas[listitem][dMapPosition3][0], MapDArenas[listitem][dMapPosition3][1], MapDArenas[listitem][dMapPosition3][2]);
  225.                     SetPlayerFacingAngle(playerid, MapDArenas[listitem][dMapPosition1][3]);
  226.                 }
  227.  
  228.                 GivePlayerWeapon(playerid, DuelInfo[did][Weapons][0], 9999);
  229.                 GivePlayerWeapon(playerid, DuelInfo[did][Weapons][1], 9999);
  230.                 new string[70];
  231.                 format(string, sizeof(string), "You have joined the %s duel room", MapDArenas[listitem][dMapName]);
  232.                 SendClientMessage(playerid, 0x00FF00FF, string);
  233.                 SetTimerEx("Freeze",3000, false, "i", playerid);
  234.                 SetPlayerInterior(playerid, MapDArenas[listitem][MapInterior]);
  235.                 SetPlayerVirtualWorld(playerid, DUEL_VW);
  236.                 SetPlayerHealth(playerid, 100);
  237.                 SetPlayerArmour(playerid, 100);
  238.                 dmapchosen[playerid]=listitem;
  239.                 DuelInfo[did][Host] = playerid;
  240.                 for(new i=0; i<8; i++)
  241.                 {
  242.                     if(!IsPlayerConnected(i)) return 1;
  243.                     new mode[50];
  244.                     if(DuelInfo[did][Mode] == 1) format(mode, 50, "1 v 1");
  245.                     if(DuelInfo[did][Mode] == 2) format(mode, 50, "2 v 2");
  246.                     if(DuelInfo[did][Mode] == 3) format(mode, 50, "3 v 3");
  247.                     if(DuelInfo[did][Mode] == 4) format(mode, 50, "4 v 4");
  248.                     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]);
  249.                     SendClientMessage(dinvitee[playerid][i], 0x0000FFFF, string);
  250.                     printf("%i", dinvitee[playerid][i]);
  251.                 }
  252.             }
  253.         }
  254.     }
  255.     return 0;
  256. }
Advertisement
Add Comment
Please, Sign In to add comment