Guest User

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

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