Guest User

[PAWNO] [PAWN] Squad System ( UPDATED )

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