Guest User

[PAWN] [PAWNO] Squad System

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