Guest User

[PAWNO] [PAWN] Squad System ( V4.5 )

a guest
Apr 20th, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 47.51 KB | None | 0 0
  1. /*
  2. - Originally created by '[HiC]TheKiller' under the request of 'Weponz'
  3. - Re-made by Kyance
  4.  
  5. ------------ CHANGELOG --------------
  6.  
  7. Date format: day/month/year || dd/mm/yyyy
  8.  
  9. Version 1                       15/04/2014
  10. - Re-named the 'Group' stuff to 'Squad'
  11. - Made the /squads a dialog instead of a message
  12. - Changed Squad-Chat to the '!' key
  13.  
  14.  
  15. Version 2                       16/04/2014
  16. - Added /sreward ( /squadreward )
  17. - Changed and improved /sinvite ( /squadinvite )
  18. - Added a /shelp ( /squadhelp ) command
  19. - Fixed Squad-Chat
  20.  
  21.  
  22. Version 2.5                     16/04/2014
  23. - Added another Squad Leaving message ( when a player switches his team )
  24. - Added /squadspawn ( Spawn on either the Leader or a Member ( RANDOM ) )
  25. - Fixed a small /sreward bug
  26.  
  27.  
  28. Version 3                       18/04/2014
  29. - Fixed squad-spawn 'compatability' bug with Gamemodes which have Random Spawns etc.
  30. - Added /squaddisband
  31. - Added /squadedit
  32. - Fixed a small bug with /squadinvie
  33. - Added /squadannounce ( Announce a message to all squad-members )
  34. - Fixed a small bug with /squadedit
  35.  
  36.  
  37. Version 3.5                     18/04/2014                     
  38. - Made /squadedit some-what easier to notice
  39. - Changed the way how 'MAX_SQUAD_MEMBERS' works, now it's a enum/variable or w.e, updated the /squadedit due to this too
  40. - Changed from the regular samp loop to foreach
  41. - Fixed some small loop bugs ( squad messages, they were sending 2x to the leader )
  42. - Fixed a bug with /squadspawn ( Leader spawning on himself.. )
  43.  
  44. Version 4.0                     18/04/2014              
  45. - Fixed some bugs with /squadedit ( Mostly bracket fails.. )
  46. - Fixed a bug with renaming the squad
  47.  
  48. Version 4.5                     20/04/2014      CURRENT VERSION
  49. - Fixed a bug with /squaddisband
  50.  
  51.  
  52. ------------ KNOWN BUGS / POSSIBLE BUGS / FIXED BUGS --------------
  53.  
  54. +++ = Known bug(s)
  55. --- = Possible bug(s)
  56. /// = FIXED ... SOLVED ... FALSE BUG(S)
  57.  
  58. ---/// The 'member spawn' could be possibly bugged, although it might be a NPC test problem, dunno /// Eh, i tested it with me and a NPC, so it shouldn't be bugged.. Script looks fine!
  59. +++ Message saying "You have been auto-removed from the squad due to changing the team" on the FIRST spawn
  60. /// Fixed a Squad Limit bug
  61. /// Fixed a Squad renaming bug
  62. /// Fixed a bug with /squaddisband
  63. */
  64.  
  65.  
  66. #include <a_samp>
  67. #include <zcmd>
  68. #include <foreach>
  69.    
  70. #define MAX_SQUADS 20
  71. //#define MAX_SQUAD_MEMBERS 5
  72.  
  73. #define DIALOG_SQUAD_LIST 1
  74. #define DIALOG_SQUAD_HELP_PAGE1 2
  75. #define DIALOG_SQUAD_HELP_PAGE2 3
  76. #define DIALOG_SQUAD_HELP_PAGE3 4
  77.  
  78. #define DIALOG_SQUAD_EDIT 5
  79. #define DIALOG_SQUAD_EDIT_NAME 6
  80. #define DIALOG_SQUAD_DISBAND 7
  81. #define DIALOG_SQUAD_EDIT_INVITE 8
  82. #define DIALOG_SQUAD_EDIT_LIMIT 9
  83.  
  84. enum sinfo
  85. {
  86.     sqname[70],
  87.     sqteam,
  88.     sqmembers,
  89.     sqmaxmembers,
  90.     leader,
  91.     invitemode,
  92.     active
  93. };
  94. enum psinfo
  95. {
  96.     sid,
  97.     order,
  98.     memberspawn,
  99.     leaderspawn,
  100.     invited,
  101.     pteam,
  102.     rewardtype,
  103.     attemptjoin
  104. };
  105. new squad[MAX_PLAYERS][psinfo];
  106. new squadinfo[MAX_SQUADS][sinfo];
  107.  
  108. forward SquadSpawn(playerid);
  109.  
  110. public OnFilterScriptInit()
  111. {
  112.     print("Squads System 4.0 has been successfully initialized\nOriginal creator: [HiC]TheKiller\nRemade by Kyance");
  113.     foreach(Player, x)
  114.     {
  115.         squad[x][sid] = -1;
  116.         squad[x][order] = -1;
  117.         squad[x][invited] = -1;
  118.         squad[x][attemptjoin] = -1;
  119.     }
  120.     print("Successfully reset all squad-data");
  121.     return 1;
  122. }
  123.  
  124. public OnPlayerConnect(playerid)
  125. {
  126.     squad[playerid][sid] = -1;
  127.     squad[playerid][invited] = -1;
  128.     squad[playerid][attemptjoin] = -1;
  129.     return 1;
  130. }
  131.  
  132. public OnPlayerDisconnect(playerid, reason)
  133. {
  134.     LeaveSquad(playerid, 3);
  135.     return 1;
  136. }
  137.  
  138. public OnPlayerSpawn(playerid)
  139. {
  140.     if(squad[playerid][sid] != -1)
  141.     {
  142.         if(GetPlayerTeam(playerid) != squadinfo[sid][sqteam])
  143.         {
  144.             LeaveSquad(playerid, 2);
  145.         }
  146.         SetTimerEx("SquadSpawn", 200, false, "i", playerid);
  147.     }
  148.     return 1;
  149. }
  150. public OnPlayerDeath(playerid, killerid, reason)
  151. {
  152.     new
  153.         /*Float:armour = GetPlayerArmour(killerid, armour),
  154.         Float:health = GetPlayerHealth(killerid, health),
  155.         money = GetPlayerMoney(killerid),
  156.         score = GetPlayerScore(killerid),
  157.         ammo = GetPlayerAmmo(killerid),*/
  158.         string[122],
  159.         name[MAX_PLAYER_NAME]
  160.     ;
  161.        
  162.     GetPlayerName(killerid, name, sizeof(name));
  163.    
  164.     if(squad[killerid][rewardtype] == 1)
  165.     {
  166.         /*foreach(Player, x)
  167.         {
  168.             if(squad[x][sid] == squad[killerid][sid] && x != killerid)
  169.             {
  170.                 new moneyreward = 1000+random(2001);
  171.                 format(string, sizeof(string), "SQUAD: You've been rewarded %i$ from %s's kill!", moneyreward, name);
  172.                 SendClientMessage(i, 0x00FF7FAA, string);
  173.             }
  174.         }*/
  175.         foreach(Player, x)
  176.         {
  177.             if(squad[x][sid] == squad[killerid][sid] && x != killerid)
  178.             {
  179.                 new
  180.                     armourreward = 5+random(20),
  181.                     Float:armour = GetPlayerArmour(x, armour)
  182.                 ;
  183.                 format(string, sizeof(string), "SQUAD: You've been rewarded %0.1f ARMOUR from %s's kill!", armourreward, name);
  184.                 SendClientMessage(x, 0x00FF7FAA, string);
  185.                 SetPlayerArmour(x, armour+armourreward);
  186.                 if(armour >= 100)
  187.                 {
  188.                     SetPlayerArmour(x, 99);
  189.                 }
  190.             }
  191.         }
  192.     }
  193.     else if(squad[killerid][rewardtype] == 2)
  194.     {
  195.         foreach(Player, x)
  196.         {
  197.             if(squad[x][sid] == squad[killerid][sid] && x != killerid)
  198.             {
  199.                 new
  200.                     healthreward = 5+random(15),
  201.                     Float:health = GetPlayerHealth(x, health)
  202.                 ;
  203.                 format(string, sizeof(string), "SQUAD: You've been rewarded %0.1f HEALTH from %s's kill!", healthreward, name);
  204.                 SendClientMessage(x, 0x00FF7FAA, string);
  205.                 SetPlayerHealth(x, health+healthreward);
  206.                 if(health >= 100)
  207.                 {
  208.                     SetPlayerHealth(x, 99);
  209.                 }
  210.             }
  211.         }
  212.     }
  213.     else if(squad[killerid][rewardtype] == 3)
  214.     {
  215.         foreach(Player, x)
  216.         {
  217.             if(squad[x][sid] == squad[killerid][sid] && x != killerid)
  218.             {
  219.                 new
  220.                     scorereward = 1+random(2),
  221.                     score = GetPlayerScore(x)
  222.                 ;
  223.                 format(string, sizeof(string), "SQUAD: You've been rewarded %d SCORE from %s's kill!", scorereward, name);
  224.                 SendClientMessage(x, 0x00FF7FAA, string);
  225.                 SetPlayerScore(x, score+scorereward);
  226.                
  227.                 if(score >= 200)
  228.                 {
  229.                     squad[killerid][rewardtype] = 1;
  230.                     SendClientMessage(x, 0x00FF7FAA, "SQUAD: Since you have 200 ( or more ), your Reward type has been set to ARMOUR");
  231.                 }
  232.             }
  233.         }
  234.     }
  235.     else if(squad[killerid][rewardtype] == 4)
  236.     {
  237.         foreach(Player, x)
  238.         {
  239.             if(squad[x][sid] == squad[killerid][sid] && x != killerid)
  240.             {
  241.                 new
  242.                     ammo = GetPlayerAmmo(x),
  243.                     weapon = GetPlayerWeapon(x),
  244.                     ammoreward = ammo+random(100)
  245.                 ;
  246.                 if(GetPlayerWeapon(x) != 16 || GetPlayerWeapon(x) != 18 || GetPlayerWeapon(x) != 35 || GetPlayerWeapon(x) != 36)
  247.                 {
  248.                     format(string, sizeof(string), "SQUAD: You've been rewarded %d AMMO from %s's kill!", ammoreward, name);
  249.                     SendClientMessage(x, 0x00FF7FAA, string);
  250.                     //GetPlayerAmmo(x, ammo);
  251.                     SetPlayerAmmo(x, weapon, ammoreward);
  252.                 }
  253.             }
  254.         }
  255.     }
  256.     return 1;
  257. }
  258. public OnPlayerText(playerid, text[])
  259. {
  260.     if(squad[playerid][sid] != -1 && text[0] == '!')
  261.     {
  262.         new
  263.             pname[MAX_PLAYER_NAME],
  264.             string[132]
  265.         ;
  266.         GetPlayerName(playerid, pname, sizeof(pname));
  267.        
  268.         foreach(Player, x)
  269.         {
  270.             if(squad[x][sid] == squad[playerid][sid])
  271.             {
  272.                 format(string, sizeof(string), "{FFCC66}SQUAD CHAT: %s[%d]: %s", pname, playerid, text[1]);
  273.                 SendClientMessage(x, -1, string);
  274.                 return 0;
  275.             }
  276.         }
  277.         //SendMessageToAllsquadMembers(squad[playerid][sid], string);
  278.     }
  279.     return 1;
  280. }
  281. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  282. {
  283.     switch(dialogid)
  284.     {
  285.         case DIALOG_SQUAD_HELP_PAGE1:
  286.         {
  287.             if(!response)
  288.             {
  289.                 ShowPlayerDialog(playerid, DIALOG_SQUAD_HELP_PAGE2, DIALOG_STYLE_LIST, "Squad information - Squad commands (Page 2/3)", "Controlling and creating your squad\n ---------- \n /screate ( Creates a squad )\n /sinvite ( Invite someone to your squad )\n /sjoin ( Join a squad )\n /sleave ( Leave a squad )\n /sdisband ( Disband your squad )\n /skick ( Kick someone from your squad )\n /spromote ( Set a new leader in your squad )\n /sreward ( Set a squad kill reward )", "<<", ">>");
  290.             }
  291.         }
  292.         case DIALOG_SQUAD_HELP_PAGE2:
  293.         {
  294.             if(response)
  295.             {
  296.                 ShowPlayerDialog(playerid, DIALOG_SQUAD_HELP_PAGE1, DIALOG_STYLE_LIST, "Squad information - Squad status (Page 1/3)", "Checking for squad information\n ---------- \n /squads ( Shows all squads, it's name and ID )\n /sinfo ( Shows more information about a specific squad, the members, leader.. )", "Close", ">>");
  297.             }
  298.             else
  299.             {
  300.                 ShowPlayerDialog(playerid, DIALOG_SQUAD_HELP_PAGE3, DIALOG_STYLE_LIST, "Squad information - Squad commands, Talking with your squad ( Page 3/3 )", "Communicating with your squad members\n ---------- \n Squad chat ( Type '!' infront of your text )\n /sannounce ( Announce a message )", "<<", "Close");
  301.             }
  302.         }
  303.         case DIALOG_SQUAD_HELP_PAGE3:
  304.         {
  305.             if(response)
  306.             {
  307.                 ShowPlayerDialog(playerid, DIALOG_SQUAD_HELP_PAGE2, DIALOG_STYLE_LIST, "Squad information - Squad commands (Page 2/3)", "Controlling and creating your squad\n ---------- \n /screate ( Creates a squad )\n /sinvite ( Invite someone to your squad )\n /sjoin ( Join a squad )\n /sleave ( Leave a squad )\n /sdisband ( Disband your squad )\n /skick ( Kick someone from your squad )\n /spromote ( Set a new leader in your squad )\n /sreward ( Set a squad kill reward )", "<<", ">>");
  308.             }
  309.         }
  310.         case DIALOG_SQUAD_EDIT:
  311.         {
  312.             if(response)
  313.             {
  314.                 switch(listitem)
  315.                 {
  316.                     case 0:
  317.                     {
  318.                         ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_NAME, DIALOG_STYLE_INPUT, "Editing your Squad", "Type the new Squad-Name you want your squad to have below", "Accept", "Back");
  319.                     }
  320.                     case 1:
  321.                     {
  322.                         ShowPlayerDialog(playerid, DIALOG_SQUAD_DISBAND, DIALOG_STYLE_MSGBOX, "Editing your Squad", "Are you sure you want to delete this squad?", "Yes", "No");
  323.                     }
  324.                     case 2:
  325.                     {
  326.                         new sqid;
  327.                         sqid = squad[playerid][sid];
  328.                         if(!squadinfo[sqid][invitemode])
  329.                         {
  330.                             //squadinfo[sqid][invitemode] = 0;
  331.                             ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_INVITE, DIALOG_STYLE_MSGBOX, "Editing your Squad", "This squad doesn't needs invitation to join( PUBLIC )", "Change", "Back");
  332.                         }
  333.                         else
  334.                         {
  335.                             //squadinfo[sqid][invitemode] = 1;
  336.                             ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_INVITE, DIALOG_STYLE_MSGBOX, "Editing your Squad", "This squad needs invitation to join( PRIVATE )", "Change", "Back");
  337.                         }
  338.                     }
  339.                     case 3:
  340.                     {
  341.                         ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_LIMIT, DIALOG_STYLE_INPUT, "Editing your Squad", "Enter the new Squad-Member limit below\nMust be between 3 and 5", "Accept", "Back");
  342.                     }
  343.                 }
  344.             }
  345.             else SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You can use /squadedit to edit the squad settings when-ever you want to.");
  346.         }
  347.         case DIALOG_SQUAD_EDIT_NAME:
  348.         {
  349.             if(response)
  350.             {
  351.                 new
  352.                     sqid,
  353.                     //newname,
  354.                     string[120],
  355.                     pname[MAX_PLAYER_NAME]
  356.                 ;
  357.                 sqid = squad[playerid][sid];
  358.                 //newname = strval(inputtext);
  359.                
  360.                 GetPlayerName(playerid, pname, sizeof(pname));
  361.                
  362.                 if(squadinfo[sqid][active] && squad[playerid][order])
  363.                 {
  364.                     if(strlen(inputtext) > 49 || strlen(inputtext) < 3)
  365.                     {
  366.                         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad name must be between 3 to 50 characters.");
  367.                         ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_NAME, DIALOG_STYLE_INPUT, "Editing your Squad", "Type the new Squad-Name you want your squad to have below", "Accept", "Back");
  368.                     }
  369.                        
  370.                     else if(IsSquadTaken(inputtext))
  371.                     {
  372.                         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: That Squad's name is already in use!");
  373.                         ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_NAME, DIALOG_STYLE_INPUT, "Editing your Squad", "Type the new Squad-Name you want your squad to have below", "Accept", "Back");
  374.                     }
  375.                     else
  376.                     {
  377.                         format(squadinfo[sqid][sqname], 70, "%s", inputtext);
  378.                         //format(string, 70, "%s", inputtext);
  379.                         //squadinfo[sqid][sqname] = string[70];
  380.                        
  381.                         format(string, sizeof(string), "{FFCC66}SQUAD: Leader %s[%d] has renamed the Squad to %s!", pname, playerid, inputtext);
  382.                         SendMessageToAllsquadMembers(sqid, string);
  383.                         foreach(Player, x)
  384.                         {
  385.                             if(GetPlayerTeam(x) == GetPlayerTeam(playerid) && squad[x][sid] != squad[playerid][sid])
  386.                             {
  387.                                 SendClientMessage(x, -1, string);
  388.                             }
  389.                         }
  390.                         format(string, sizeof(string), "{FFCC66}SQUAD: You've successfully re-named your squad to %s", inputtext);
  391.                         SendClientMessage(playerid, -1, string);
  392.                     }
  393.                 }
  394.             }
  395.             else
  396.             {
  397.                 ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT, DIALOG_STYLE_LIST, "Editing your Squad", "Edit Squad Name(Change the name)\nDelete Squad\nEdit Join Mode(Invite needed, or not needed)\nEdit max. squad member ammount( 3 - 5 )", "Select", "Close");
  398.             }
  399.         }
  400.         case DIALOG_SQUAD_DISBAND:
  401.         {
  402.             if(response)
  403.             {
  404.                //return cmd_squaddisband(playerid, inputtext);
  405.                 new
  406.                     string[102],
  407.                     string2[113],
  408.                     pname[MAX_PLAYER_NAME],
  409.                     team[MAX_PLAYERS],
  410.                     squadid
  411.                 ;
  412.  
  413.                 GetPlayerName(playerid, pname, sizeof(pname));
  414.  
  415.                 team[playerid] = GetPlayerTeam(playerid);
  416.                 squadid = squad[playerid][sid];
  417.  
  418.                 format(string, sizeof(string), "{FFCC66}SQUAD: Squad leader %s[%d] has disbanded this squad.", pname, playerid);
  419.                 format(string2, sizeof(string2), "{FFCC66}SQUAD: Squad leader %s[%d] has disbanded the squad %s.", pname, playerid, squadinfo[squadid][sqname]);
  420.  
  421.                 foreach(Player, x)
  422.                 {
  423.                     if(squad[x][sid] == squad[playerid][sid])
  424.                     {
  425.                         SendClientMessage(x, -1, string);
  426.                         LeaveSquad(x, 4);
  427.                     }
  428.                     team[x] = GetPlayerTeam(x);
  429.                     if(team[x] == team[playerid] && x != playerid)
  430.                     {
  431.                         SendClientMessage(x, -1, string2);
  432.                     }
  433.                 }
  434.             }
  435.             else
  436.             {
  437.                 ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT, DIALOG_STYLE_LIST, "Editing your Squad", "Edit Squad Name(Change the name)\nDelete Squad\nEdit Join Mode(Invite needed, or not needed)\nEdit max. squad member ammount( 3 - 5 )", "Select", "Close");
  438.             }
  439.         }
  440.         case DIALOG_SQUAD_EDIT_INVITE:
  441.         {
  442.             if(response)
  443.             {
  444.                 new
  445.                     sqid,
  446.                     string[113],
  447.                     pname[MAX_PLAYER_NAME]
  448.                 ;
  449.                
  450.                 GetPlayerName(playerid, pname, sizeof(pname));
  451.                 sqid = squad[playerid][sid];
  452.                
  453.                 if(squadinfo[sqid][invitemode])
  454.                 {
  455.                     squadinfo[sqid][invitemode] = 0;
  456.                     //ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_INVITE, DIALOG_STYLE_MSGBOX, "Editing your Squad", "This squad doesn't needs invitation to join( PUBLIC )", "Back", "");
  457.                     format(string, sizeof(string), "{FFCC66}SQUAD: Leader %s[%d] made the squad %s a PUBLIC squad!", pname, playerid, squadinfo[sqid][sqname]);
  458.                     SendMessageToAllsquadMembers(sqid, string);
  459.                     foreach(Player, x)
  460.                     {
  461.                         if(GetPlayerTeam(x) == GetPlayerTeam(playerid) && squad[x][sid] != squad[playerid][sid])
  462.                         {
  463.                             SendClientMessage(x, -1, string);
  464.                         }
  465.                     }
  466.                     SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You've successfully made the squad PUBLIC");
  467.                 }
  468.                 else
  469.                 {
  470.                     squadinfo[sqid][invitemode] = 1;
  471.                     //ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_INVITE, DIALOG_STYLE_MSGBOX, "Editing your Squad", "This squad needs invitation to join( PRIVATE )", "Back", "");
  472.                     format(string, sizeof(string), "{FFCC66}SQUAD: Leader %s[%d] made the squad %s a PRIVATE squad!", pname, playerid, squadinfo[sqid][sqname]);
  473.                     SendMessageToAllsquadMembers(sqid, string);
  474.                     foreach(Player, x)
  475.                     {
  476.                         if(GetPlayerTeam(x) == GetPlayerTeam(playerid) && squad[x][sid] != squad[playerid][sid])
  477.                         {
  478.                             SendClientMessage(x, -1, string);
  479.                         }
  480.                     }
  481.                     SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You've successfully made the squad PRIVATE");
  482.                 }
  483.             }
  484.             else
  485.             {
  486.                 ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT, DIALOG_STYLE_LIST, "Editing your Squad", "Edit Squad Name(Change the name)\nDelete Squad\nEdit Join Mode(Invite needed, or not needed)\nEdit max. squad member ammount( 3 - 5 )", "Select", "Close");
  487.             }
  488.         }
  489.         case DIALOG_SQUAD_EDIT_LIMIT:
  490.         {
  491.             if(response)
  492.             {
  493.                 new
  494.                     sqid,
  495.                     newlimit,
  496.                     string[113],
  497.                     pname[MAX_PLAYER_NAME]
  498.                 ;
  499.                
  500.                 GetPlayerName(playerid, pname, sizeof(pname));
  501.                 sqid = squad[playerid][sid];
  502.                 newlimit = strval(inputtext);
  503.                
  504.                 if(newlimit > 5 || newlimit < 3)
  505.                 {
  506.                     SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Choose a valid Squad Member limit( 3 - 5 )");
  507.                     ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_LIMIT, DIALOG_STYLE_INPUT, "Editing your Squad", "Enter the new Squad-Member limit below\nMust be between 3 and 5", "Accept", "Back");
  508.                 }
  509.                 else if(squadinfo[sqid][sqmaxmembers] == newlimit)
  510.                 {
  511.                     SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The Squad-Member limit is already the one you selected.");
  512.                     ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_LIMIT, DIALOG_STYLE_INPUT, "Editing your Squad", "Enter the new Squad-Member limit below\nMust be between 3 and 5", "Accept", "Back");
  513.                 }
  514.                 else
  515.                 {
  516.                     squadinfo[sqid][sqmaxmembers] = newlimit;
  517.                     format(string, sizeof(string), "{FFCC66}SQUAD: Leader %s[%d] has set the Squad-Member limit to %d.", pname, playerid, newlimit);
  518.                     SendMessageToAllsquadMembers(sqid, string);
  519.                     foreach(Player, x)
  520.                     {
  521.                         if(GetPlayerTeam(x) == GetPlayerTeam(playerid) && squad[x][sid] != squad[playerid][sid])
  522.                         {
  523.                             SendClientMessage(x, -1, string);
  524.                         }
  525.                     }
  526.                     format(string, sizeof(string), "{FFCC66}SQUAD: You've successfully set the member limit to %d", newlimit);
  527.                     SendClientMessage(playerid, -1, string);
  528.                 }
  529.             }
  530.             else
  531.             {
  532.                 ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT, DIALOG_STYLE_LIST, "Editing your Squad", "Edit Squad Name(Change the name)\nDelete Squad\nEdit Join Mode(Invite needed, or not needed)\nEdit max. squad member ammount( 3 - 5 )", "Select", "Close");
  533.             }
  534.         }
  535.        
  536.     }
  537.     /*#define DIALOG_SQUAD_EDIT 5
  538.     #define DIALOG_SQUAD_EDIT_NAME 6
  539.     #define DIALOG_SQUAD_DISBAND 7
  540.     #define DIALOG_SQUAD_EDIT_INVITE 8
  541.     #define DIALOG_SQUAD_EDIT_LIMIT 9*/
  542.     return 1;
  543. }
  544. CMD:squadhelp(playerid, params[])
  545. {
  546.     //"Squad info and commands", "Checking squad information\n \n /squads ( Shows all squads )\n /sinfo ( Shows squad information )\nCreating, controlling squads \n \n \nTalking with your squad ( Type '!' infront of your text )", "Close", "");
  547.  
  548.     ShowPlayerDialog(playerid, DIALOG_SQUAD_HELP_PAGE1, DIALOG_STYLE_LIST, "Squad information, commands etc. (Page 1/3)", "Checking for squad information\n ---------- \n /squads ( Shows all squads, it's name and ID )\n /sinfo ( Shows more information about a specific squad, the members, leader.. )", "Close", ">>");
  549.     return 1;
  550. }
  551. CMD:squadedit(playerid, params[])
  552. {
  553.     if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You're not in a Squad!");
  554.     if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not the leader of the squad, you can't edit it!");
  555.    
  556.     ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT, DIALOG_STYLE_LIST, "Editing your Squad", "Edit Squad Name(Change the name)\nDelete Squad\nEdit Join Mode(Invite needed, or not needed)\nEdit max. squad member ammount( 3 - 5 )", "Select", "Close");
  557.     return 1;
  558. }
  559. CMD:squadannounce(playerid, params[])
  560. {
  561.     if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You're not in a Squad!");
  562.     if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not the leader of the squad, you can't announce messages!");
  563.    
  564.     if(strlen(params) > 36 || strlen(params) < 3) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: /squadannounce (Announcement, 3 - 35 characters)!");
  565.    
  566.     new
  567.         string[92],
  568.         pname[MAX_PLAYER_NAME]
  569.     ;
  570.     format(string, sizeof(string), "%s", params);
  571.     GetPlayerName(playerid, pname, sizeof(pname));
  572.     foreach(Player, x)
  573.     {
  574.         if(squad[x][sid] == squad[playerid][sid])
  575.         {
  576.             GameTextForPlayer(x, string, 4500, 3);
  577.             format(string, sizeof(string), "{FFCC66}SQUAD: Announcement from Squad leader %s[%d]: %s", pname, playerid, params);
  578.             SendClientMessage(x, -1, string);
  579.         }
  580.     }
  581.     return 1;
  582. }
  583. CMD:squadcreate(playerid, params[])
  584. {
  585.     if(squad[playerid][sid] != -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Leave your squad with /squadleave before creating a new one!");
  586.     if(strlen(params) > 49 || strlen(params) < 3) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: /squadcreate (Squad name, 3-50 characters)!");
  587.     if(IsSquadTaken(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: That Squad's name is already in use!");
  588.    
  589.     CreateSquad(params, playerid);
  590.     return 1;
  591. }
  592. CMD:squadleave(playerid, params[])
  593. {
  594.     if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You're not in a squad to leave one!");
  595.     LeaveSquad(playerid, 0);
  596.     return 1;
  597. }
  598. CMD:squaddisband(playerid, params[]) {
  599.     if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You need to be in a Squad to disband it!");
  600.     if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not the leader of the squad, you can't disband it!");
  601.    
  602.     new
  603.         string[102],
  604.         string2[113],
  605.         pname[MAX_PLAYER_NAME],
  606.         team[MAX_PLAYERS],
  607.         squadid
  608.     ;
  609.    
  610.     GetPlayerName(playerid, pname, sizeof(pname));
  611.    
  612.     team[playerid] = GetPlayerTeam(playerid);
  613.     squadid = squad[playerid][sid];
  614.    
  615.     format(string, sizeof(string), "{FFCC66}SQUAD: Squad leader %s[%d] has disbanded this squad.", pname, playerid);
  616.     format(string2, sizeof(string2), "{FFCC66}SQUAD: Squad leader %s[%d] has disbanded the squad %s.", pname, playerid, squadinfo[squadid][sqname]);
  617.    
  618.     foreach(Player, x)
  619.     {
  620.         if(squad[x][sid] == squad[playerid][sid])
  621.         {
  622.             SendClientMessage(x, -1, string);
  623.             LeaveSquad(x, 4);
  624.         }
  625.         team[x] = GetPlayerTeam(x);
  626.         if(team[x] == team[playerid] && x != playerid)
  627.         {
  628.             SendClientMessage(x, -1, string2);
  629.         }
  630.     }
  631.    
  632.     //squadinfo[squadid][active] = 0;*/
  633.     return 1;
  634. }
  635. CMD:squadspawn(playerid, params[])
  636. {
  637.     if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You're not in a Squad!");
  638.     //if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: These settings are not available for Squad leaders.");
  639.  
  640.     if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: /squadspawn [leader/member/default]");
  641.  
  642.     if(strcmp(params, "leader", true, 6) == 0)
  643.     {
  644.         if(squad[playerid][order] != 1)
  645.         {
  646.             squad[playerid][leaderspawn] = 1;
  647.             squad[playerid][memberspawn] = 0;
  648.             SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will now spawn on the squad leader.");
  649.         }
  650.         else SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are the leader, you can't spawn on yourself..");
  651.     }
  652.     else if(strcmp(params, "member", true, 6) == 0)
  653.     {
  654.         squad[playerid][leaderspawn] = 0;
  655.         squad[playerid][memberspawn] = 1;
  656.         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will now spawn on your squad members( RANDOM ).");
  657.     }
  658.     else if(strcmp(params, "default", true, 6) == 0)
  659.     {
  660.         squad[playerid][leaderspawn] = 0;
  661.         squad[playerid][memberspawn] = 0;
  662.         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will now spawn at the default spawn points.");
  663.     }
  664.     else
  665.     {
  666.         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Invalid spawn type, use either LEADER, MEMBER or DEFAULT");
  667.     }
  668.     return 1;
  669. }
  670. CMD:squadreward(playerid, params[])
  671. {
  672.     if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You need to be in a squad to use {FFFFFF}/squadreward{FF0000}");
  673.     if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: /squadreward [armour/health/score/ammo]");
  674.    
  675.     if(strcmp(params, "armour", true, 6) == 0)
  676.     {
  677.         squad[playerid][rewardtype] = 1;
  678.         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will receive ARMOUR on your squad-member kills!");
  679.     }
  680.     else if(strcmp(params, "health", true, 6) == 0)
  681.     {
  682.         squad[playerid][rewardtype] = 2;
  683.         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will receive HEALTH on your squad-member kills!");
  684.     }
  685.     /*else if(strcmp(reward, "money", true, 5) == 0)
  686.     {
  687.         squad[playerid][rewardtype] = 3;
  688.         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will receive MONEY on your squad-member kills!");
  689.     }*/
  690.     else if(strcmp(params, "score", true, 5) == 0)
  691.     {
  692.         if(GetPlayerScore(playerid) > 200) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You need less than 200 score to use the SCORE reward..");
  693.  
  694.         squad[playerid][rewardtype] = 3;
  695.         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will receive SCORE on your squad-member kills!");
  696.     }
  697.     else if(strcmp(params, "ammo", true, 4) == 0)
  698.     {
  699.         squad[playerid][rewardtype] = 4;
  700.         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will receive AMMO on your squad-member kills!");
  701.     }
  702.     else
  703.     {
  704.         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Invalid reward type, use either ARMOUR, HEALTH, MONEY, SCORE or AMMO");
  705.     }
  706.     return 1;
  707. }
  708. /*CMD:squadinvite(playerid, params[])
  709. {
  710.     if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not the leader of the squad, you cannot invite people!");
  711.     new cid;
  712.     if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/squadinvite{FF0000} (playerid)");
  713.     cid = strval(params);
  714.     if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player not found!");
  715.     if(GetPlayerTeam(cid) != squadinfo[sid][sqteam]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Target is not in your team!");
  716.     if(squad[cid][sid] == squad[playerid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player is already in your squad!");
  717.     if(squad[cid][invited] == squad[playerid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player has already been invited to your squad!");
  718.     if(squadinfo[sid][sqmembers] == MAX_SQUAD_MEMBERS) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad already has 5 members..");
  719.     if(squad[cid][attemptjoin] == squad[playerid][sid]) return squadJoin(cid, squad[playerid][sid]);
  720.     squad[cid][invited] = squad[playerid][sid];
  721.     new string[125], pname[24];
  722.     GetPlayerName(playerid, pname, 24);
  723.     format(string, sizeof(string), "* You have been invited to join squad {FFFFFF}%s[%d]{FFCC66} by {FFFFFF}%s[%d]. /squadjoin %d", squadinfo[squad[playerid][sid]][sqname], squad[playerid][sid], pname, playerid, squad[playerid][sid]);
  724.     SendClientMessage(cid, 0xFFCC66, string);
  725.     GetPlayerName(cid, pname, 24);
  726.     format(string, sizeof(string), "* You have invited {FFFFFF}%s[%d]{FFCC66} to join your squad!", pname, cid);
  727.     SendClientMessage(playerid, 0xFFCC66, string);
  728.     return 1;
  729. }*/
  730. CMD:squadinvite(playerid, params[])
  731. {
  732.     new
  733.         cid,
  734.         sqid,
  735.         string[125],
  736.         pname[24],
  737.         tname[24]
  738.     ;
  739.     GetPlayerName(playerid, pname, 24);
  740.     GetPlayerName(cid, tname, 24);
  741.     sqid = squad[playerid][sid];
  742.     if(squad[playerid][order] != 1)
  743.     {
  744.         if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: /squadinvite{FF0000} (playerid)");
  745.        
  746.         cid = strval(params);
  747.        
  748.        
  749.         if(!IsPlayerConnected(cid) || cid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player not found!");
  750.         if(GetPlayerTeam(cid) != squadinfo[sid][sqteam]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Target is not in your team!");
  751.         if(squad[cid][sid] == squad[playerid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player is already in your squad!");
  752.         if(squad[cid][invited] == squad[playerid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player has already been invited to your squad!");
  753.         if(squadinfo[sqid][sqmembers] == squadinfo[sqid][sqmaxmembers]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad already has 5 members..");
  754.        
  755.         format(string, sizeof(string), "* Your invitation request of %s[%d] has been sent to the Squad Leader", tname, cid);
  756.         SendClientMessage(playerid, 0x00FF7FAA, string);
  757.  
  758.         foreach(Player, x)
  759.         {
  760.             if(squad[x][sid] == squad[playerid][sid])
  761.             {
  762.                 if(squad[x][order])
  763.                 {
  764.                     format(string, sizeof(string), "* Your squad-member %s wants you to invite %s[%d]", pname, tname, cid);
  765.                     SendClientMessage(x, 0x00FF7FAA, string);
  766.                 }
  767.             }
  768.         }
  769.     }
  770.     else
  771.     {
  772.         if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/squadinvite{FF0000} (playerid)");
  773.         cid = strval(params);
  774.  
  775.         if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player not found!");
  776.         if(GetPlayerTeam(cid) != squadinfo[sid][sqteam]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Target is not in your team!");
  777.         if(squad[cid][sid] == squad[playerid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player is already in your squad!");
  778.         if(squad[cid][invited] == squad[playerid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player has already been invited to your squad!");
  779.         if(squadinfo[sqid][sqmembers] == squadinfo[sqid][sqmaxmembers]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad already has 5 members..");
  780.         if(squad[cid][attemptjoin] == squad[playerid][sid]) return squadJoin(cid, squad[playerid][sid]);
  781.  
  782.         squad[cid][invited] = squad[playerid][sid];
  783.         format(string, sizeof(string), "* You have been invited to join squad {FFFFFF}%s[%d]{FFCC66} by {FFFFFF}%s[%d]. /squadjoin %d", squadinfo[squad[playerid][sid]][sqname], squad[playerid][sid], pname, playerid, squad[playerid][sid]);
  784.         SendClientMessage(cid, 0xFFCC66, string);
  785.         GetPlayerName(cid, pname, 24);
  786.         format(string, sizeof(string), "{FFCC66}SQUAD: You have invited %s[%d] to join your squad!", pname, cid);
  787.         SendClientMessage(playerid, -1, string);
  788.     }
  789.     return 1;
  790. }
  791. CMD:squadleader(playerid, params[])
  792. {
  793.     if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not the leader of the squad, you cannot change the leader!");
  794.     new cid;
  795.     if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/squadleader{FF0000} (playerid)");
  796.     cid = strval(params);
  797.     if(!IsPlayerConnected(cid) || cid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player Is not connected!");
  798.     if(cid == playerid)  return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are already squad leader.");
  799.     if(squad[playerid][sid] != squad[cid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player is not in your squad!");
  800.     ChangeMemberOrder(squad[playerid][sid], 1);
  801.     squad[playerid][order] = squadMembers(squad[playerid][sid]);
  802.     return 1;
  803. }
  804.  
  805. CMD:squadjoin(playerid, params[])
  806. {
  807.     if(squad[playerid][sid] != -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are already in a squad! Leave your current one before joining another one!");
  808.     new sqid;
  809.     sqid = strval(params);
  810.     if((isnull(params) && squad[playerid][invited] != -1 && squadinfo[sqid][invitemode] == 0 ) || ( strval(params) == squad[playerid][invited] && squad[playerid][invited] != -1 && squadinfo[sqid][invitemode] == 0 ) ) return squadJoin(playerid, squad[playerid][invited]);
  811.     if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/squadjoin{FF0000} (squadid)");
  812.  
  813.     if(!squadinfo[sqid][active]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad you tried to join doesn't exist!");
  814.     if(GetPlayerTeam(playerid) != squadinfo[sqid][sqteam]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad you tried to join is not available for your team.");
  815.     if(squadinfo[sqid][sqmembers] == squadinfo[sqid][sqmaxmembers]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad already has 5 members..");
  816.     if(!squadinfo[sqid][invitemode])
  817.     {
  818.         squad[playerid][attemptjoin] = sqid;
  819.         new string[125], pname[24];
  820.         GetPlayerName(playerid, pname, 24);
  821.         format(string, sizeof(string), "* You have requested to join squad %s(ID:%d)", squadinfo[sqid][sqname], sqid);
  822.         SendClientMessage(playerid, 0xFFCC66, string);
  823.         format(string, sizeof(string), "* {FFFFFF}%s[%d] {FFCC66}has attempted to join your squad. Type /squadinvite %d to accept", pname, playerid, playerid);
  824.         SendMessageToLeader(sqid, string);
  825.     }
  826.     else return squadJoin(playerid, sqid/*squad[playerid][invited]*/);
  827.     return 1;
  828. }
  829.  
  830. CMD:squadkick(playerid, params[])
  831. {
  832.     if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not the leader of a squad, you cannot kick!");
  833.     new cid;
  834.     if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/squadkick{FF0000} (playerid)");
  835.     cid = strval(params);
  836.     if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player Is not connected!");
  837.     if(cid == playerid)  return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You can't kick yourself.");
  838.     if(squad[playerid][sid] != squad[cid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player is not in your squad!");
  839.     LeaveSquad(cid, 1);
  840.     return 1;
  841. }
  842.  
  843. /*CMD:squadmessage(playerid, params[])
  844. {
  845.     if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not in a squad, you cannot squad message!");
  846.     if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/gm{FF0000} (message)");
  847.     new pname[24], string[140+24];
  848.     GetPlayerName(playerid, pname, 24);
  849.     format(string, sizeof(string), "%s[%d]: %s", pname, playerid, params);
  850.     SendMessageToAllsquadMembers(squad[playerid][sid], string);
  851.     return 1;
  852. }*/
  853.  
  854. CMD:squadinfo(playerid, params[])
  855. {
  856.     if(isnull(params) && squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/squadinfo{FF0000} (squad)");
  857.     if(isnull(params))
  858.     {
  859.         DisplaysquadMembers(squad[playerid][sid], playerid);
  860.         return 1;
  861.     }
  862.     new sqid = strval(params);
  863.     if(!squadinfo[sqid][active]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad ID you have entered is not active!");
  864.     DisplaysquadMembers(sqid, playerid);
  865.     return 1;
  866. }
  867.  
  868. CMD:squads(playerid, params[])
  869. {
  870.     //Listsquads(playerid);
  871.     new
  872.         amount[2],
  873.         string[400],
  874.         shortstr[90],
  875.         team = GetPlayerTeam(playerid)
  876.     ;
  877.     for(new x=0; x<MAX_SQUADS; x++)
  878.     {
  879.         if(squadinfo[x][active])
  880.         {
  881.             amount[0] ++;
  882.             amount[1] ++;
  883.             format(shortstr, sizeof(shortstr), "%s (ID:%d, Members:%d/%d) \n", squadinfo[x][sqname], x, squadinfo[x][sqmembers], squadinfo[x][sqmaxmembers]);
  884.             if(squadinfo[x][sqteam] == team)
  885.             {
  886.                 if(amount[1] == 1)
  887.                 {
  888.                     format(string, sizeof(string), "{33AA33}%s\n", shortstr);
  889.                     strcat(string, "\n\n{33AA33}Friendly squads are colored green\n{AA3333}Enemy squads are colored red", sizeof(string));
  890.                 }
  891.                 if(amount[1] != 1)
  892.                 {
  893.                     format(string, sizeof(string), "{33AA33}%s %s\n", string, shortstr);
  894.                     strcat(string, "\n\n{33AA33}Friendly squads are colored green\n{AA3333}Enemy squads are colored red", sizeof(string));
  895.                 }
  896.             }
  897.             else
  898.             {
  899.                 if(amount[1] == 1)
  900.                 {
  901.                     format(string, sizeof(string), "{AA3333}%s\n", shortstr);
  902.                     strcat(string, "\n\n\n{33AA33}Friendly squads are colored green\n{AA3333}Enemy squads are colored red", sizeof(string));
  903.                 }
  904.                 if(amount[1] != 1)
  905.                 {
  906.                    format(string, sizeof(string), "{AA3333}%s %s\n", string, shortstr);
  907.                    strcat(string, "\n\n{33AA33}Friendly squads are colored green\n{AA3333}Enemy squads are colored red", sizeof(string));
  908.                 }
  909.             }
  910.             if(amount[0] == 4)
  911.             {
  912.                 ShowPlayerDialog(playerid, DIALOG_SQUAD_LIST, DIALOG_STYLE_LIST, "Squads", string, "Close", "");
  913.                 string = "";
  914.                 amount[0] = 0;
  915.             }
  916.         }
  917.     }
  918.     if(amount[1] == 0) ShowPlayerDialog(playerid, DIALOG_SQUAD_LIST, DIALOG_STYLE_LIST, "Squads", "No squads available\nUse /squadcreate to create one!", "Close", "");
  919.     if(amount[1] != 0) ShowPlayerDialog(playerid, DIALOG_SQUAD_LIST, DIALOG_STYLE_LIST, "Squads", string, "Close", "");
  920.  
  921.     //ShowPlayerDialog(playerid, DIALOG_SQUAD_LIST, DIALOG_STYLE_LIST, "Squads"
  922.     return 1;
  923. }
  924.  
  925.  
  926. CMD:squit(playerid, params[])
  927.     return cmd_squadleave(playerid, params);
  928. CMD:sleave(playerid, params[])
  929.     return cmd_squadleave(playerid, params);
  930.  
  931. CMD:scr(playerid, params[])
  932.     return cmd_squadcreate(playerid, params);
  933. CMD:screate(playerid, params[])
  934.     return cmd_squadcreate(playerid, params);
  935.  
  936. CMD:sdisband(playerid, params[])
  937.     return cmd_squaddisband(playerid, params);
  938. CMD:sdelete(playerid, params[])
  939.     return cmd_squaddisband(playerid, params);
  940. CMD:squaddelete(playerid, params[])
  941.     return cmd_squaddisband(playerid, params);
  942.    
  943. CMD:shelp(playerid, params[])
  944.     return cmd_squadhelp(playerid, params);
  945.    
  946. CMD:sedit(playerid, params[])
  947.     return cmd_squadedit(playerid, params);
  948.    
  949. CMD:sann(playerid, params[])
  950.     return cmd_squadannounce(playerid, params);
  951. CMD:sannounce(playerid, params[])
  952.     return cmd_squadannounce(playerid, params);
  953.    
  954. CMD:sinv(playerid, params[])
  955.     return cmd_squadinvite(playerid, params);
  956. CMD:sinvite(playerid, params[])
  957.     return cmd_squadinvite(playerid, params);
  958.    
  959. CMD:spromote(playerid, params[])
  960.     return cmd_squadleader(playerid, params);
  961. CMD:sleader(playerid, params[])
  962.     return cmd_squadleader(playerid, params);
  963.  
  964. CMD:sj(playerid, params[])
  965.     return cmd_squadjoin(playerid, params);
  966. CMD:sjoin(playerid, params[])
  967.     return cmd_squadjoin(playerid, params);
  968.    
  969. CMD:sk(playerid, params[])
  970.     return cmd_squadkick(playerid, params);
  971. CMD:skick(playerid, params[])
  972.     return cmd_squadkick(playerid, params);
  973.  
  974. /*CMD:smsg(playerid, params[])
  975.     return cmd_squadmessage(playerid, params);*/
  976.  
  977. CMD:slist(playerid, params[])
  978.     return cmd_squadinfo(playerid, params);
  979. CMD:sinfo(playerid, params[])
  980.     return cmd_squadinfo(playerid, params);
  981.    
  982. CMD:sreward(playerid, params[])
  983.     return cmd_squadreward(playerid, params);
  984.  
  985.    
  986. stock DisplaysquadMembers(squadid, playerid)
  987. {
  988.     new amount[2], string[200], shortstr[55], pname[24];
  989.     format(string, sizeof(string), "Squad members for %s(ID:%d)", squadinfo[squadid][sqname], squadid);
  990.     SendClientMessage(playerid, -1, string);
  991.     string = "";
  992.     foreach(Player, x)
  993.     {
  994.         if(squad[x][sid] == squadid)
  995.         {
  996.             amount[0] ++;
  997.             amount[1] ++;
  998.             GetPlayerName(x, pname, 24);
  999.             if(squadinfo[squadid][leader] != x) format(shortstr, sizeof(shortstr), "%s[%d],", pname, x);
  1000.             if(squadinfo[squadid][leader] == x) format(shortstr, sizeof(shortstr), "[LEADER]%s[%d],", pname, x);
  1001.             if(amount[1] == 1) format(string, sizeof(string), "%s", shortstr);
  1002.             if(amount[1] != 1) format(string, sizeof(string), "%s %s", string, shortstr);
  1003.             if(amount[0] == 6)
  1004.             {
  1005.                 strdel(string, strlen(string)-1, strlen(string));
  1006.                 SendClientMessage(playerid, 0xFFCC66, string);
  1007.                 string = "";
  1008.                 amount[0] = 0;
  1009.             }
  1010.         }
  1011.     }
  1012.     strdel(string, strlen(string)-1, strlen(string));
  1013.     if(amount[0] != 0) SendClientMessage(playerid, 0xFFCC66, string);
  1014.     return 1;
  1015. }
  1016.  
  1017. stock Listsquads(playerid)
  1018. {
  1019.     new amount[2], string[200], shortstr[55];
  1020.     SendClientMessage(playerid, 0xFFFFFF, "Current squads:");
  1021.     for(new x=0; x<MAX_SQUADS; x++)
  1022.     {
  1023.         if(squadinfo[x][active])
  1024.         {
  1025.             amount[0] ++;
  1026.             amount[1] ++;
  1027.             format(shortstr, sizeof(shortstr), "%s(ID:%d)", squadinfo[x][sqname], x);
  1028.             if(amount[1] == 1) format(string, sizeof(string), "%s", shortstr);
  1029.             if(amount[1] != 1) format(string, sizeof(string), "%s %s", string, shortstr);
  1030.             if(amount[0] == 4)
  1031.             {
  1032.                 SendClientMessage(playerid, 0xFFCC66, string);
  1033.                 string = "";
  1034.                 amount[0] = 0;
  1035.             }
  1036.         }
  1037.     }
  1038.     if(amount[1] == 0) SendClientMessage(playerid, 0xFFFF00, "There are currently no active squads!");
  1039.     if(amount[1] != 0) SendClientMessage(playerid, 0xFFCC66, string);
  1040.     return 1;
  1041. }
  1042.  
  1043.  
  1044. stock SendMessageToLeader(squadi, message[])
  1045.     return SendClientMessage(squadinfo[squadi][leader], 0xFFCC66, message);
  1046.  
  1047. stock squadJoin(playerid, squadi)
  1048. {
  1049.     squad[playerid][sid] = squadi;
  1050.     squad[playerid][order] = squadMembers(squadi);
  1051.     squad[playerid][attemptjoin] = -1;
  1052.     squad[playerid][invited] = -1;
  1053.     new pname[24], string[130];
  1054.     GetPlayerName(playerid, pname, 24);
  1055.     format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has joined your squad!", pname, playerid);
  1056.     SendMessageToAllsquadMembers(squadi, string);
  1057.     format(string, sizeof(string), "{FFCC66}SQUAD: You have joined squad %s(ID:%d)", squadinfo[squadi][sqname] ,squadi);
  1058.     SendClientMessage(playerid, -1, string);
  1059.     return 1;
  1060. }
  1061.  
  1062. stock FindNextSlot()
  1063. {
  1064.     new id;
  1065.     while(squadinfo[id][active]) id ++;
  1066.     return id;
  1067. }
  1068.  
  1069. stock IsSquadTaken(sqdname[])
  1070. {
  1071.     for(new x; x<MAX_SQUADS; x++)
  1072.     {
  1073.         if(squadinfo[x][active] == 1)
  1074.         {
  1075.             if(!strcmp(sqdname, squadinfo[x][sqname], true) && strlen(squadinfo[x][sqname]) != 0) return 1;
  1076.         }
  1077.     }
  1078.     return 0;
  1079. }
  1080.  
  1081. stock squadInvite(playerid, squadid)
  1082.     return squad[playerid][invited] = squadid;
  1083.  
  1084. stock CreateSquad(sqdname[], owner)
  1085. {
  1086.     new slotid = FindNextSlot();
  1087.    
  1088.    
  1089.     squadinfo[slotid][leader] = owner;
  1090.     format(squadinfo[slotid][sqname], 75, "%s", sqdname);
  1091.     squadinfo[slotid][active] = 1;
  1092.     squadinfo[slotid][sqteam] = GetPlayerTeam(owner);
  1093.     squadinfo[slotid][invitemode] = 0;
  1094.     squadinfo[slotid][sqmembers] = 1;
  1095.     squadinfo[slotid][sqmaxmembers] = 5;
  1096.     squad[owner][sid] = slotid;
  1097.     squad[owner][order] = 1;
  1098.    
  1099.     new string[120], team[MAX_PLAYERS], name[MAX_PLAYER_NAME];
  1100.     GetPlayerName(owner, name, sizeof(name));
  1101.    
  1102.     format(string, sizeof(string), "{FFCC66}SQUAD: You have created the squad %s(ID:%d)", sqdname, slotid);
  1103.     SendClientMessage(owner, -1, string);
  1104.    
  1105.     ShowPlayerDialog(owner, DIALOG_SQUAD_EDIT, DIALOG_STYLE_LIST, "Editing your Squad", "Edit Squad Name(Change the name)\nDelete Squad\nEdit Join Mode(Invite needed, or not needed)\nEdit max. squad member ammount( 3 - 5 )", "Select", "Close");
  1106.  
  1107.     foreach(Player, i)
  1108.     {
  1109.         team[i] = GetPlayerTeam(i);
  1110.         if(team[i] == team[owner])
  1111.         {
  1112.             format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has created a squad named %s", name, owner, sqdname);
  1113.             SendClientMessage(i, -1, string);
  1114.         }
  1115.     }
  1116.     return slotid;
  1117. }
  1118.  
  1119. stock LeaveSquad(playerid, reason)
  1120. {
  1121.     new squadid = squad[playerid][sid], orderid = squad[playerid][order], string[100], pname[24];
  1122.     squad[playerid][sid] = -1;
  1123.     squad[playerid][order] = -1;
  1124.     squadinfo[sid][sqmembers]--;
  1125.     squadCheck(squadid, orderid);
  1126.     GetPlayerName(playerid, pname, 24);
  1127.     if(reason == 0)
  1128.     {
  1129.         format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has left your squad (Left)!", pname, playerid);
  1130.         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You have left your squad");
  1131.     }
  1132.     else if(reason == 1)
  1133.     {
  1134.         format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has left your squad (Kicked)!", pname, playerid);
  1135.         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You have been kicked from your squad!");
  1136.     }
  1137.     else if(reason == 2)
  1138.     {
  1139.         format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has left your squad (Changed team)!", pname, playerid);
  1140.         SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You have been auto-removed from the squad due to changing the team");
  1141.     }
  1142.     else if(reason == 3)
  1143.     {
  1144.         format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has left your squad (Disconnected)!", pname, playerid);
  1145.     }
  1146.     else if(reason == 4)
  1147.     {
  1148.         format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has left your squad (Squad disbanded)!", pname, playerid);
  1149.     }
  1150.     SendMessageToAllsquadMembers(squadid, string);
  1151.     return 1;
  1152. }
  1153.  
  1154. stock squadCheck(squadid, orderid)
  1155. {
  1156.     new smems = squadMembers(squadid);
  1157.     if(!smems) squadinfo[squadid][active] = 0;
  1158.     if(smems != 0) ChangeMemberOrder(squadid, orderid);
  1159.     return 1;
  1160. }
  1161.  
  1162. stock squadMembers(squadid)
  1163. {
  1164.     if(!squadinfo[squadid][active]) return 0;
  1165.     new squadmembers;
  1166.     foreach(Player, i) if(squad[i][sid] == squadid) squadmembers++;
  1167.     return squadmembers;
  1168. }
  1169.  
  1170. stock ChangeMemberOrder(squadid, orderid)
  1171. {
  1172.     foreach(Player, x)
  1173.     {
  1174.         if(squad[x][sid] != squadid || squad[x][order] < orderid) continue;
  1175.         squad[x][order] --;
  1176.         if(squad[x][order] == 1)
  1177.         {
  1178.             squadinfo[squadid][leader] = x;
  1179.             new string[128], pname[24];
  1180.             GetPlayerName(x, pname, 24);
  1181.             format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has been promoted to the new squad leader!", pname, x);
  1182.             SendMessageToAllsquadMembers(squadid, string);
  1183.         }
  1184.     }
  1185.     return 1;
  1186. }
  1187.  
  1188. stock SendMessageToAllsquadMembers(squadid, message[])
  1189. {
  1190.     if(!squadinfo[squadid][active]) return 0;
  1191.     foreach(Player, x) if(squad[x][sid] == squadid) SendClientMessage(x, -1, message);
  1192.     return 1;
  1193. }
  1194. public SquadSpawn(playerid)
  1195. {
  1196.     new
  1197.         string[113],
  1198.         pname[MAX_PLAYER_NAME],
  1199.         tname[MAX_PLAYER_NAME],
  1200.         Float: X,
  1201.         Float: Y,
  1202.         Float: Z,
  1203.         squadmembercount = 0
  1204.     ;
  1205.    
  1206.     GetPlayerName(playerid, pname, sizeof(pname));
  1207.    
  1208.     if(squad[playerid][sid] != -1)
  1209.     {
  1210.         if(squad[playerid][leaderspawn])
  1211.         {
  1212.             foreach(Player, x)
  1213.             {
  1214.                 if(squad[x][sid] == squad[playerid][sid] && x != playerid)
  1215.                 {
  1216.                     if(squad[x][order])
  1217.                     {
  1218.                         GetPlayerName(x, tname, sizeof(tname));
  1219.  
  1220.                         format(string, sizeof(string), "{FFCC66}SQUAD: You've spawned on your Squad Leader, %s[%d]", tname, x);
  1221.                         SendClientMessage(playerid, -1, string);
  1222.  
  1223.                         format(string, sizeof(string), "{FFCC66}SQUAD: Your squad member %s[%d] has spawned on you.", pname, playerid);
  1224.                         SendClientMessage(x, -1, string);
  1225.  
  1226.                         GetPlayerPos(x, X, Y, Z);
  1227.                         SetPlayerPos(playerid, X, Y, Z);
  1228.                     }
  1229.                 }
  1230.             }
  1231.         }
  1232.         else if(squad[playerid][memberspawn])
  1233.         {
  1234.             foreach(Player, x)
  1235.             {
  1236.                 if(squad[x][sid] == squad[playerid][sid] && x != playerid)
  1237.                 {
  1238.                     squadmembercount++;
  1239.                     if(squadmembercount >= 1)
  1240.                     {
  1241.                         new RandomS = random(x);
  1242.  
  1243.                         GetPlayerPos(RandomS, X, Y, Z);
  1244.  
  1245.                         GetPlayerName(RandomS, tname, sizeof(tname));
  1246.  
  1247.                         format(string, sizeof(string), "{FFCC66}SQUAD: You've spawned on your Squad Member, %s[%d]", tname, x);
  1248.                         SendClientMessage(playerid, -1, string);
  1249.  
  1250.                         format(string, sizeof(string), "{FFCC66}SQUAD: Your squad member %s[%d] has spawned on you.", pname, playerid);
  1251.                         SendClientMessage(RandomS, -1, string);
  1252.  
  1253.                         SetPlayerPos(playerid, X, Y, Z);
  1254.                     }
  1255.                     else SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Not enough squad members to do this.");
  1256.                 }
  1257.             }
  1258.         }
  1259.     }
  1260.     return 1;
  1261. }
Advertisement
Add Comment
Please, Sign In to add comment