SHARE
TWEET

Bodyguard Squads

Eddlm Nov 1st, 2015 859 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using GTA;
  2. using GTA.Math;
  3. using GTA.Native;
  4. using NativeUI;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Drawing;
  8. using System.Windows.Forms;
  9. using System.IO;
  10.  
  11. public class BodyguardSquads : Script
  12. {
  13.  
  14.     //NativeUI test
  15.     private MenuPool _menuPool;
  16.  
  17.     //Main Menu
  18.     private UIMenu mainMenu;
  19.  
  20.     private UIMenu Squad1Menu;
  21.     private UIMenu Squad2Menu;
  22.     private UIMenu Squad3Menu;
  23.     private UIMenu Squad4Menu;
  24.  
  25.     private UIMenuItem Squad1MenuItem;
  26.     private UIMenuItem Squad2MenuItem;
  27.     private UIMenuItem Squad3MenuItem;
  28.     private UIMenuItem Squad4MenuItem;
  29.  
  30.  
  31.  
  32.     // SQUAD SETUP
  33.     private UIMenuCheckboxItem Squad1ReactToEvents;
  34.     private UIMenuCheckboxItem Squad1Followplayer;
  35.  
  36.     private UIMenuCheckboxItem Squad2ReactToEvents;
  37.     private UIMenuCheckboxItem Squad2Followplayer;
  38.  
  39.     private UIMenuCheckboxItem Squad3ReactToEvents;
  40.     private UIMenuCheckboxItem Squad3Followplayer;
  41.  
  42.     private UIMenuCheckboxItem Squad4ReactToEvents;
  43.     private UIMenuCheckboxItem Squad4Followplayer;
  44.  
  45.     private UIMenuCheckboxItem Squad1GodMode;
  46.     private UIMenuCheckboxItem Squad2GodMode;
  47.     private UIMenuCheckboxItem Squad3GodMode;
  48.     private UIMenuCheckboxItem Squad4GodMode;
  49.  
  50.  
  51.     private UIMenuListItem Squad1StyleItem;
  52.     private UIMenuListItem Squad2StyleItem;
  53.     private UIMenuListItem Squad3StyleItem;
  54.     private UIMenuListItem Squad4StyleItem;
  55.  
  56.  
  57.     private UIMenuListItem MainWeaponSquad1List;
  58.     private UIMenuListItem MainWeaponSquad2List;
  59.     private UIMenuListItem MainWeaponSquad3List;
  60.     private UIMenuListItem MainWeaponSquad4List;
  61.  
  62.     private UIMenuListItem SecondaryWeaponSquad1List;
  63.     private UIMenuListItem SecondaryWeaponSquad2List;
  64.     private UIMenuListItem SecondaryWeaponSquad3List;
  65.     private UIMenuListItem SecondaryWeaponSquad4List;
  66.  
  67.     private UIMenuCheckboxItem Squad1DispatchToWaypoint;
  68.     private UIMenuCheckboxItem Squad2DispatchToWaypoint;
  69.     private UIMenuCheckboxItem Squad3DispatchToWaypoint;
  70.     private UIMenuCheckboxItem Squad4DispatchToWaypoint;
  71.  
  72.     private UIMenuCheckboxItem Squad1Autocall;
  73.     private UIMenuCheckboxItem Squad2Autocall;
  74.     private UIMenuCheckboxItem Squad3Autocall;
  75.     private UIMenuCheckboxItem Squad4Autocall;
  76.  
  77.     private UIMenuItem DeleteSquad1;
  78.     private UIMenuItem DeleteSquad2;
  79.     private UIMenuItem DeleteSquad3;
  80.     private UIMenuItem DeleteSquad4;
  81.  
  82.     private UIMenuItem CallSquad1;
  83.     private UIMenuItem CallSquad2;
  84.     private UIMenuItem CallSquad3;
  85.     private UIMenuItem CallSquad4;
  86.  
  87.     //RELATIONSHIPS MENU
  88.     private UIMenuItem Squad1Hate;
  89.     private UIMenuItem Squad1Like;
  90.  
  91.     private UIMenuItem Squad2Hate;
  92.     private UIMenuItem Squad2Like;
  93.  
  94.     private UIMenuItem Squad3Hate;
  95.     private UIMenuItem Squad3Like;
  96.  
  97.     private UIMenuItem Squad4Hate;
  98.     private UIMenuItem Squad4Like;
  99.  
  100.     private UIMenuCheckboxItem Squad1HateSquad2;
  101.     private UIMenuCheckboxItem Squad1HateSquad3;
  102.     private UIMenuCheckboxItem Squad1HateSquad4;
  103.  
  104.     private UIMenuCheckboxItem Squad2HateSquad1;
  105.     private UIMenuCheckboxItem Squad2HateSquad3;
  106.     private UIMenuCheckboxItem Squad2HateSquad4;
  107.  
  108.     private UIMenuCheckboxItem Squad3HateSquad1;
  109.     private UIMenuCheckboxItem Squad3HateSquad2;
  110.     private UIMenuCheckboxItem Squad3HateSquad4;
  111.  
  112.     private UIMenuCheckboxItem Squad4HateSquad1;
  113.     private UIMenuCheckboxItem Squad4HateSquad2;
  114.     private UIMenuCheckboxItem Squad4HateSquad3;
  115.  
  116.     private UIMenuCheckboxItem Squad1HatePlayer;
  117.     private UIMenuCheckboxItem Squad2HatePlayer;
  118.     private UIMenuCheckboxItem Squad3HatePlayer;
  119.     private UIMenuCheckboxItem Squad4HatePlayer;
  120.  
  121.  
  122.     // COMMON ORDERS
  123.     private UIMenuItem EscortMeSquad1;
  124.     private UIMenuItem EscortMeSquad2;
  125.     private UIMenuItem EscortMeSquad3;
  126.     private UIMenuItem EscortMeSquad4;
  127.  
  128.     private UIMenuItem GoToWaypointSquad1;
  129.     private UIMenuItem GoToWaypointSquad2;
  130.     private UIMenuItem GoToWaypointSquad3;
  131.     private UIMenuItem GoToWaypointSquad4;
  132.  
  133.     private UIMenuItem EnterLeaveVehicleSquad1;
  134.     private UIMenuItem EnterLeaveVehicleSquad2;
  135.     private UIMenuItem EnterLeaveVehicleSquad3;
  136.     private UIMenuItem EnterLeaveVehicleSquad4;
  137.  
  138.     private UIMenuItem GetBackToMeSquad1;
  139.     private UIMenuItem GetBackToMeSquad2;
  140.     private UIMenuItem GetBackToMeSquad3;
  141.     private UIMenuItem GetBackToMeSquad4;
  142.  
  143.     // SPECIAL ORDERS
  144.     private UIMenuItem RappelSquad1;
  145.     private UIMenuItem RappelSquad2;
  146.     private UIMenuItem RappelSquad3;
  147.     private UIMenuItem RappelSquad4;
  148.  
  149.     private UIMenuItem SwitchSirensSquad1;
  150.     private UIMenuItem SwitchSirensSquad2;
  151.     private UIMenuItem SwitchSirensSquad3;
  152.     private UIMenuItem SwitchSirensSquad4;
  153.  
  154.     private UIMenuItem AttachVehiclesSquad1;
  155.     private UIMenuItem AttachVehiclesSquad2;
  156.     private UIMenuItem AttachVehiclesSquad3;
  157.     private UIMenuItem AttachVehiclesSquad4;
  158.  
  159.     private UIMenuItem ParkNearbySquad1;
  160.     private UIMenuItem ParkNearbySquad2;
  161.     private UIMenuItem ParkNearbySquad3;
  162.     private UIMenuItem ParkNearbySquad4;
  163.  
  164.     private UIMenuItem FollowmeOffroadSquad1;
  165.     private UIMenuItem FollowmeOffroadSquad2;
  166.     private UIMenuItem FollowmeOffroadSquad3;
  167.     private UIMenuItem FollowmeOffroadSquad4;
  168.  
  169.  
  170.  
  171.     private UIMenuItem GuardThisAreaSquad1;
  172.     private UIMenuItem GuardThisAreaSquad2;
  173.     private UIMenuItem GuardThisAreaSquad3;
  174.     private UIMenuItem GuardThisAreaSquad4;
  175.  
  176.     //INTERNAL VARIABLES
  177.     private UIMenuListItem DrivingStyleSquad1;
  178.     private UIMenuListItem DrivingStyleSquad2;
  179.     private UIMenuListItem DrivingStyleSquad3;
  180.     private UIMenuListItem DrivingStyleSquad4;
  181.  
  182.     private UIMenuListItem Squad1VehicleSelection;
  183.     private UIMenuListItem Squad1NumberItem;
  184.     private UIMenuListItem Squad2VehicleSelection;
  185.     private UIMenuListItem Squad2NumberItem;
  186.     private UIMenuListItem Squad3VehicleSelection;
  187.     private UIMenuListItem Squad3NumberItem;
  188.     private UIMenuListItem Squad4VehicleSelection;
  189.     private UIMenuListItem Squad4NumberItem;
  190.  
  191.     //ALL SQUADS MENU
  192.     private UIMenu AllSquadsMenu;
  193.     private UIMenuItem AllSquadsMenuItem;
  194.     private UIMenuItem AllGoToWaypoint;
  195.     private UIMenuItem AllGetBackToMe;
  196.     private UIMenuItem AllCallSquad;
  197.     private UIMenuItem AllDismissSquad;
  198.     private UIMenuItem AllEnterLeave;
  199.  
  200.     //RACE MENU
  201.     private UIMenu AllSquadsRaceMenu;
  202.     private UIMenuItem AllParkAtMySide;
  203.     private UIMenuItem AllSquadsRaceMenuItem;
  204.     private UIMenuItem AllSquadsAddWaypoint;
  205.     private UIMenuItem AllSquadsClearWaypoints;
  206.     private UIMenuItem AllSquadsStartRace;
  207.  
  208.     //GLOBAL VARIABLES
  209.     List<Vector3> RaceWaypoints = new List<Vector3>();
  210.     List<Blip> RaceWaypointBlips = new List<Blip>();
  211.  
  212.     List<Entity> Squad1 = new List<Entity>();
  213.     List<Entity> Squad2 = new List<Entity>();
  214.     List<Entity> Squad3 = new List<Entity>();
  215.     List<Entity> Squad4 = new List<Entity>();
  216.  
  217.     List<Ped> DrivingCareful = new List<Ped>();
  218.     List<Ped> DrivingNormal = new List<Ped>();
  219.     List<Ped> DrivingFurious = new List<Ped>();
  220.     Vehicle Squad1Car;
  221.     Vehicle Squad2Car;
  222.     Vehicle Squad3Car;
  223.     Vehicle Squad4Car;
  224.  
  225.  
  226.     private int Squad1Group;
  227.     private int Squad2Group;
  228.     private int Squad3Group;
  229.     private int Squad4Group;
  230.  
  231.     private DateTime interval2sec = DateTime.Now; //        interval2sec = DateTime.Now;
  232.     private DateTime interval1sec = DateTime.Now; //        interval1sec = DateTime.Now;
  233.  
  234.     //SQUAD PEDS
  235.     private Ped Squad1Leader;
  236.     private Ped Squad1Member;
  237.     private Ped Squad2Leader;
  238.     private Ped Squad2Member;
  239.     private Ped Squad3Leader;
  240.     private Ped Squad3Member;
  241.     private Ped Squad4Leader;
  242.     private Ped Squad4Member;
  243.  
  244.  
  245.     ///RAYCAST INFO
  246.     private Vector3 hitcoord;
  247.     private Entity entitihit;
  248.  
  249.     //DEFAULT VALUES FOR CONFIG
  250.     private VehicleHash Squad1Vehicle = VehicleHash.Schafter2;
  251.     private VehicleHash Squad2Vehicle = VehicleHash.Schafter2;
  252.     private VehicleHash Squad3Vehicle = VehicleHash.Schafter2;
  253.     private VehicleHash Squad4Vehicle = VehicleHash.Schafter2;
  254.  
  255.     private string Squad1StylePed = "Army";
  256.     private string Squad2StylePed = "Army";
  257.     private string Squad3StylePed = "Army";
  258.     private string Squad4StylePed = "Army";
  259.  
  260.     private WeaponHash MainWeaponSquad1 = WeaponHash.Unarmed;
  261.     private WeaponHash SecondaryWeaponSquad1 = WeaponHash.Unarmed;
  262.     private WeaponHash MainWeaponSquad2 = WeaponHash.Unarmed;
  263.     private WeaponHash SecondaryWeaponSquad2 = WeaponHash.Unarmed;
  264.     private WeaponHash MainWeaponSquad3 = WeaponHash.Unarmed;
  265.     private WeaponHash SecondaryWeaponSquad3 = WeaponHash.Unarmed;
  266.     private WeaponHash MainWeaponSquad4 = WeaponHash.Unarmed;
  267.     private WeaponHash SecondaryWeaponSquad4 = WeaponHash.Unarmed;
  268.  
  269.     private int Squad1Number = 8;
  270.     private int Squad2Number = 8;
  271.     private int Squad3Number = 8;
  272.     private int Squad4Number = 8;
  273.  
  274.  
  275.     private string CustomStyle1Name = "Custom1";
  276.     private string CustomStyle2Name = "Custom2";
  277.     private Color Squad1Color = Color.FromArgb(255, 15, 170, 255);
  278.     private Color Squad2Color = Color.FromArgb(255, 249, 255, 79);
  279.     private Color Squad3Color = Color.FromArgb(255, 12, 173, 0);
  280.     private Color Squad4Color = Color.FromArgb(255, 255, 0, 0);
  281.  
  282.  
  283.     ///.INI CONFIG
  284.     private bool EnterAsPassengerEnabled = true;
  285.     private bool SquadStatusOnScreen = true;
  286.     private int SquadSpawnDistance = 300;
  287.  
  288.     private Keys MenuKey = Keys.X;
  289.     private Keys OrdersModeKey = Keys.C;
  290.     private Keys EnterAsPassengerKey = Keys.Space;
  291.     private float TimeScale;
  292.  
  293.  
  294.     ///SLOWTIME CONFIG
  295.     private bool WantedSlowsTime;
  296.     private bool HalfHealthSlowsTime;
  297.     private bool CombatSlowsTime;
  298.     private bool SlowTimeWhenManaging;
  299.  
  300.  
  301.     ///MORE VALUES
  302.     private int ordersmode = 0;
  303.     private Player player = Game.Player;
  304.     int AdvanceBodyguardRelationshipGroup = World.AddRelationshipGroup("AdvanceBodyguardRelationshipGroup");
  305.     int Squad1RelationshipGroup = World.AddRelationshipGroup("Squad1RelationshipGroup");
  306.     int Squad2RelationshipGroup = World.AddRelationshipGroup("Squad2RelationshipGroup");
  307.     int Squad3RelationshipGroup = World.AddRelationshipGroup("Squad3RelationshipGroup");
  308.     int Squad4RelationshipGroup = World.AddRelationshipGroup("Squad4RelationshipGroup");
  309.  
  310.     VehicleHash[] SquadTransportHashes = new VehicleHash[]
  311.     {
  312.         VehicleHash.Schafter2,
  313.         VehicleHash.Stretch,
  314.         VehicleHash.Burrito3,
  315.         VehicleHash.GBurrito2,
  316.         VehicleHash.Huntley,
  317.         VehicleHash.Cavalcade2,
  318.         VehicleHash.Granger,
  319.         VehicleHash.Bison,
  320.         VehicleHash.Mesa,
  321.         VehicleHash.Mesa3,
  322.         VehicleHash.Buffalo2,
  323.         VehicleHash.BType,
  324.         VehicleHash.Ztype,
  325.         VehicleHash.Kuruma,
  326.         VehicleHash.Kuruma2,
  327.         VehicleHash.Patriot,
  328.         VehicleHash.Rebel,
  329.         VehicleHash.Technical,
  330.         VehicleHash.Dubsta,
  331.         VehicleHash.Dubsta3,
  332.         VehicleHash.Sandking,
  333.         VehicleHash.Guardian,
  334.         VehicleHash.Insurgent2,
  335.         VehicleHash.Insurgent,
  336.         VehicleHash.Barracks,
  337.         VehicleHash.Rhino,
  338.         VehicleHash.Akuma,
  339.         VehicleHash.Enduro,
  340.         VehicleHash.Bati,
  341.         VehicleHash.Daemon,
  342.         VehicleHash.Innovation,
  343.         VehicleHash.Swift,
  344.         VehicleHash.Buzzard2,
  345.         VehicleHash.Buzzard,
  346.         VehicleHash.Annihilator,
  347.         VehicleHash.Valkyrie,
  348.         VehicleHash.Savage,
  349.         VehicleHash.Cargobob,
  350.         VehicleHash.Police,
  351.         VehicleHash.Police2,
  352.         VehicleHash.Police3,
  353.         VehicleHash.Polmav,
  354.         VehicleHash.FBI2,
  355.         VehicleHash.Riot,
  356.  
  357.     };
  358.     WeaponHash[] MainWeaponHashes = new WeaponHash[]
  359.     {
  360.                 WeaponHash.Unarmed,
  361.                 WeaponHash.HeavyPistol,
  362.                 WeaponHash.PumpShotgun,
  363.                 WeaponHash.SMG,
  364.                 WeaponHash.Gusenberg,
  365.                 WeaponHash.AssaultRifle,
  366.                 WeaponHash.AdvancedRifle,
  367.                 WeaponHash.CarbineRifle,
  368.                 WeaponHash.SpecialCarbine,
  369.                 WeaponHash.HeavySniper,
  370.                 WeaponHash.CombatMG,
  371.                 WeaponHash.Railgun,
  372.                 WeaponHash.Minigun,
  373.                 WeaponHash.RPG,
  374.     };
  375.  
  376.     WeaponHash[] SecondaryWeaponHashes = new WeaponHash[]
  377. {
  378.                 WeaponHash.Unarmed,
  379.                 WeaponHash.Nightstick,
  380.                 WeaponHash.StunGun,
  381.                 WeaponHash.Bat,
  382.                 WeaponHash.Knife,
  383.                 WeaponHash.Pistol,
  384.                 WeaponHash.SawnOffShotgun,
  385.                 WeaponHash.MicroSMG,
  386. };
  387.  
  388.  
  389.  
  390.     Random rnd = new Random();
  391.     protected int GetRandomInt(int min, int max)
  392.     {
  393.         return rnd.Next(min, max);
  394.     }
  395.  
  396.     List<String> Squad1Models = new List<String>
  397. {
  398.         "s_m_y_marine_03",
  399.         "s_m_y_marine_02",
  400.         "s_m_y_marine_01",
  401.         "s_m_m_marine_01",
  402.         "s_m_y_blackops_01",
  403.         "s_m_y_blackops_02",
  404.         "s_m_y_blackops_03"
  405. };
  406.  
  407.     List<String> Squad2Models = new List<String>
  408. {
  409.             "s_m_y_armymech_01",
  410.         "s_m_y_marine_03",
  411.         "s_m_y_marine_02",
  412.         "s_m_y_marine_01",
  413.         "s_m_m_marine_01",
  414.         "s_m_y_blackops_01",
  415.         "s_m_y_blackops_02",
  416.         "s_m_y_blackops_03"
  417.  
  418. };
  419.  
  420.     List<String> Squad3Models = new List<String>
  421. {
  422.             "s_m_y_armymech_01",
  423.         "s_m_y_marine_03",
  424.         "s_m_y_marine_02",
  425.         "s_m_y_marine_01",
  426.         "s_m_m_marine_01",
  427.         "s_m_y_blackops_01",
  428.         "s_m_y_blackops_02",
  429.         "s_m_y_blackops_03"
  430.  
  431. };
  432.     List<String> Squad4Models = new List<String>
  433. {
  434.             "s_m_y_armymech_01",
  435.         "s_m_y_marine_03",
  436.         "s_m_y_marine_02",
  437.         "s_m_y_marine_01",
  438.         "s_m_m_marine_01",
  439.         "s_m_y_blackops_01",
  440.         "s_m_y_blackops_02",
  441.         "s_m_y_blackops_03"
  442.  
  443. };
  444.     List<String> ArmyModels = new List<String>
  445.     {
  446.  
  447.         "s_m_y_armymech_01",
  448.         "s_m_y_marine_03",
  449.         "s_m_y_marine_02",
  450.         "s_m_y_marine_01",
  451.         "s_m_m_marine_01",
  452.         "s_m_y_blackops_01",
  453.         "s_m_y_blackops_02",
  454.         "s_m_y_blackops_03"
  455.     };
  456.  
  457.     List<String> PrivateSecurityModels = new List<String>
  458. {
  459.  
  460.     "s_m_m_highsec_01",
  461.     "s_m_m_highsec_02",
  462.     "s_m_y_doorman_01",
  463.     "s_m_y_devinsec_01"
  464. };
  465.     List<String> BallasModels = new List<String>
  466. {
  467.         "g_f_y_ballas_01",
  468.         "g_m_y_ballaeast_01",
  469.         "g_m_y_ballaorig_01",
  470.         "g_m_y_ballasout_01",
  471. };
  472.  
  473.  
  474.     List<String> FamiliesModels = new List<String>
  475. {
  476.         "mp_m_famdd_01",
  477.         "g_f_y_families_01",
  478.         "g_m_y_famca_01",
  479.         "g_m_y_famdnf_01",
  480.         "g_m_y_famfor_01"
  481. };
  482.     List<String> LostModels = new List<String>
  483. {
  484.         "g_m_y_lost_01",
  485.         "g_m_y_lost_02",
  486.         "g_m_y_lost_02",
  487.         "g_f_y_lost_01",
  488. };
  489.  
  490.     List<String> RedneckModels = new List<String>
  491. {
  492.         "a_m_m_hillbilly_01",
  493.         "a_m_m_hillbilly_02"
  494. };
  495.  
  496.     List<String> SWATModels = new List<String>
  497. {
  498.         "s_m_y_swat_01",
  499.  
  500. };
  501.  
  502.     List<String> PoliceModels = new List<String>
  503. {
  504.  
  505.         "s_f_y_cop_01",
  506.         "s_m_y_cop_01"
  507. };
  508.  
  509.     ///EMPTY CUSTOM MODEL LISTS TO FILL AT START
  510.     List<String> CustomModels1 = new List<String>
  511.     {
  512.  
  513.     };
  514.     List<String> CustomModels2 = new List<String>
  515.     {
  516.  
  517.     };
  518.  
  519.     List<Model> VehiclesWithSiren = new List<Model>
  520.         {
  521.             VehicleHash.Police,
  522.             VehicleHash.Police2,
  523.             VehicleHash.Police3,
  524.             VehicleHash.Police4,
  525.             VehicleHash.Policeb,
  526.             VehicleHash.PoliceOld1,
  527.             VehicleHash.PoliceOld2,
  528.             VehicleHash.Riot,
  529.             VehicleHash.FBI2,
  530.             VehicleHash.FBI,
  531.             VehicleHash.FireTruck,
  532.             VehicleHash.Ambulance,
  533.         };
  534.    
  535.  
  536.  
  537.  
  538.     public BodyguardSquads()
  539.     {
  540.         ScriptSettings config = ScriptSettings.Load(@"scripts\advanced_bodyguards.ini");
  541.         EnterAsPassengerEnabled = config.GetValue<bool>("SETTINGS", "EnterAsPassengerEnabled", true);
  542.         SquadStatusOnScreen = config.GetValue<bool>("SETTINGS", "SquadStatusOnScreen", true);
  543.         SquadSpawnDistance = config.GetValue<int>("SETTINGS", "SquadSpawnDistance", 300);
  544.         MenuKey = config.GetValue<Keys>("SETTINGS", "MenuKey", Keys.X);
  545.         OrdersModeKey = config.GetValue<Keys>("SETTINGS", "OrdersModeKey", Keys.C);
  546.         TimeScale = config.GetValue<float>("SETTINGS", "TimeScale", 0);
  547.         EnterAsPassengerKey = config.GetValue<Keys>("SETTINGS", "EnterAsPassengerKey", Keys.Space);
  548.  
  549.         SlowTimeWhenManaging = config.GetValue<bool>("SETTINGS", "SlowTimeWhenManaging", false);
  550.         WantedSlowsTime = config.GetValue<bool>("SETTINGS", "WantedSlowsTime", false);
  551.         HalfHealthSlowsTime = config.GetValue<bool>("SETTINGS", "HalfHealthSlowsTime", true);
  552.         CombatSlowsTime = config.GetValue<bool>("SETTINGS", "CombatSlowsTime", true);
  553.         CustomStyle1Name = config.GetValue<string>("SETTINGS", "CustomStyle1Name", "Custom1");
  554.         CustomStyle2Name = config.GetValue<string>("SETTINGS", "CustomStyle2Name", "Custom2");
  555.  
  556.         var Custommodel = config.GetValue<string>("SETTINGS", "CustomStyle1Model1", "u_m_y_mani");
  557.         CustomModels1.Add(Custommodel);
  558.         Custommodel = config.GetValue<string>("SETTINGS", "CustomStyle1Model2", "u_m_y_mani");
  559.         CustomModels1.Add(Custommodel);
  560.         Custommodel = config.GetValue<string>("SETTINGS", "CustomStyle1Model3", "u_m_y_mani");
  561.         CustomModels1.Add(Custommodel);
  562.         Custommodel = config.GetValue<string>("SETTINGS", "CustomStyle1Model4", "u_m_y_mani");
  563.         CustomModels1.Add(Custommodel);
  564.  
  565.         Custommodel = config.GetValue<string>("SETTINGS", "CustomStyle2Model1", "u_m_y_mani");
  566.         CustomModels2.Add(Custommodel);
  567.         Custommodel = config.GetValue<string>("SETTINGS", "CustomStyle2Model2", "u_m_y_mani");
  568.         CustomModels2.Add(Custommodel);
  569.         Custommodel = config.GetValue<string>("SETTINGS", "CustomStyle2Model3", "u_m_y_mani");
  570.         CustomModels2.Add(Custommodel);
  571.         Custommodel = config.GetValue<string>("SETTINGS", "CustomStyle2Model4", "u_m_y_mani");
  572.         CustomModels2.Add(Custommodel);
  573.         Custommodel = null;
  574.  
  575.  
  576.         var SquadStyle = new List<dynamic>
  577.         {
  578.             "Army",
  579.             "Private Security",
  580.             "Rednecks",
  581.             "Families",
  582.             "Ballas",
  583.             "The Lost",
  584.             CustomStyle1Name,
  585.             CustomStyle2Name,
  586.             "SWAT",
  587.             "Police",
  588.         };
  589.  
  590.         var MainWeaponsSquad = new List<dynamic>
  591.         {
  592.             "Unarmed",
  593.             "Heavy Pistol",
  594.             "Shotgun",
  595.             "SMG",
  596.             "Gusenberg Sweeper",
  597.             "Assault Rifle",
  598.             "Advanced Rifle",
  599.             "Carbine",
  600.             "Special Carbine",
  601.             "Heavy Sniper Rifle",
  602.             "Combat MG",
  603.             "Railgun",
  604.             "Minigun",
  605.             "RPG",
  606.         };
  607.  
  608.  
  609.         var SecondaryWeaponsSquad = new List<dynamic>
  610.         {
  611.             "Unarmed",
  612.             "Nightstick",
  613.             "Stun Gun",
  614.             "Baseball Bat",
  615.             "Knife",
  616.             "Pistol",
  617.             "Sawn Off Shotgun",
  618.             "MicroSMG",
  619.         };
  620.  
  621.         var NumberOfPeople = new List<dynamic>
  622.         {
  623.             1,
  624.             2,
  625.             3,
  626.             4,
  627.             5,
  628.             6,
  629.             7,
  630.             8,
  631.         };
  632.  
  633.  
  634.         var SquadVehicles = new List<dynamic>
  635.         {
  636.             "[Sedan] Schafter",
  637.             "[Limousine] Stretch",
  638.             "[Vans] Burrito",
  639.             "[Vans] Gang Burrito",
  640.             "[SUV] Huntley S",
  641.             "[SUV] Cavalcade",
  642.             "[SUV] Granger",
  643.             "[SUV] Bison",
  644.             "[4X4] Mesa",
  645.             "[Military] Army Mesa",
  646.             "[Sports] Buffalo",
  647.             "[Sports Classic] Roosewelt",
  648.             "[Sports Classic] ZType",
  649.             "[4X4] Kuruma",
  650.             "[4X4] Armored Kuruma",
  651.             "[4X4] Patriot",
  652.             "[4X4] Rebel",
  653.             "[4X4] Technical",
  654.             "[4X4] Dubsta",
  655.             "[4X4] Dubsta 6x6",
  656.             "[4X4] Sandking",
  657.             "[4X4] Guardian",
  658.             "[4X4] Insurgent",
  659.             "[4X4] Armed Insurgent",
  660.             "[Truck] Barracks",
  661.             "[Tank] Rhino",
  662.             "[Bikes] Akuma",
  663.             "[Bikes] Enduro",
  664.             "[Bikes] Bati 801",
  665.             "[Bikes] Daemon",
  666.             "[Bikes] Innovation",
  667.             "[Helis] Swift",
  668.             "[Helis] Buzzard",
  669.             "[Helis] Attack Buzzard",
  670.             "[Helis] Annihilator",
  671.             "[Helis] Valkyrie",
  672.             "[Helis] Savage",
  673.             "[Helis] Cargobob",
  674.             "[Police] Cruiser",
  675.             "[Police] Buffalo",
  676.             "[Police] Interceptor",
  677.             "[Police] Maverick",
  678.             "[FIB] Granger",
  679.             "[SWAT] Riot",
  680.         };
  681.  
  682.         var DrivingStyle = new List<dynamic>
  683.         {
  684.             "Careful",
  685.             "Normal",
  686.             "Fast & Furious",
  687.         };
  688.  
  689.         Tick += OnTick;
  690.         KeyDown += OnKeyDown;
  691.         KeyUp += OnKeyUp;
  692.  
  693.         _menuPool = new MenuPool();
  694.  
  695.         mainMenu = new UIMenu("Guard Commands", "");
  696.         _menuPool.Add(mainMenu);
  697.  
  698.         //SQUAD 1 MAIN MENU
  699.         Squad1MenuItem = new UIMenuItem("~b~Squad 1");
  700.         mainMenu.AddItem(Squad1MenuItem);
  701.         Squad1Menu = new UIMenu("~b~Squad 1", "");
  702.         _menuPool.Add(Squad1Menu);
  703.  
  704.         //SQUAD 1 SETUP
  705.         var Squad1SetupItem = new UIMenuItem("Squad Setup", "Set up this squad and configure their behavior.");
  706.         Squad1SetupItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  707.         Squad1Menu.AddItem(Squad1SetupItem);
  708.         var Squad1Setup = new UIMenu("~b~Squad Setup", "~b~Configure the first Squad from there.");
  709.         _menuPool.Add(Squad1Setup);
  710.         Squad1Menu.BindMenuToItem(Squad1Setup, Squad1SetupItem);
  711.         Squad1Setup.AddItem(Squad1StyleItem = new UIMenuListItem("Unit Style", SquadStyle, 0));
  712.         Squad1Setup.AddItem(Squad1NumberItem = new UIMenuListItem("Units", NumberOfPeople, 7));
  713.         Squad1Setup.AddItem(Squad1VehicleSelection = new UIMenuListItem("Vehicle", SquadVehicles, 0, "The vehicle they will come in. Be aware of how many passengers the vehicle will fit in."));
  714.         Squad1Setup.AddItem(MainWeaponSquad1List = new UIMenuListItem("Main weapon", MainWeaponsSquad, 0, "This list includes heavy weapons."));
  715.         Squad1Setup.AddItem(SecondaryWeaponSquad1List = new UIMenuListItem("Secondary weapon", SecondaryWeaponsSquad, 0, "This list includes melee and light weapons."));
  716.         Squad1Setup.AddItem(Squad1Autocall = new UIMenuCheckboxItem("Re-call when defeated", false));
  717.         Squad1Setup.AddItem(Squad1DispatchToWaypoint = new UIMenuCheckboxItem("Dispatch to Waypoint", false));
  718.         Squad1DispatchToWaypoint.Description = "If checked, the squad will be dispatched to your Waypoint instead of your actual position.";
  719.         Squad1Setup.AddItem(CallSquad1 = new UIMenuItem("Call Squad", "Spawn this squad with the above defined paramet."));
  720.         Squad1Setup.AddItem(DeleteSquad1 = new UIMenuItem("Dismiss Squad", "Make the Squad leave."));
  721.  
  722.         //SQUAD 1 CONFIG BEHAVIOR
  723.         var Squad1ConfigItem = new UIMenuItem("Squad Behaviour", "");
  724.         Squad1ConfigItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  725.         var Squad1Config = new UIMenu("~b~Squad Behaviour", "~b~These options affect the squad in real time.");
  726.         _menuPool.Add(Squad1Config);
  727.         Squad1Menu.AddItem(Squad1ConfigItem);
  728.         Squad1Menu.BindMenuToItem(Squad1Config, Squad1ConfigItem);
  729.         Squad1Config.AddItem(DrivingStyleSquad1 = new UIMenuListItem("Driving style", DrivingStyle, 1, "How the leader will drive. Careful: Slow, overtaking with care. Normal: Somewhat fast, overtaking with care. Fast: Fastest, careless overtaking."));
  730.         Squad1Config.AddItem(Squad1ReactToEvents = new UIMenuCheckboxItem("React to enemies", true, "When enabled, the squad will only obey when is not in combat."));
  731.         Squad1Config.AddItem(Squad1Followplayer = new UIMenuCheckboxItem("Follow Player", false, "The Squad will follow you automatically. They will hop in your vehicles, too."));
  732.         Squad1Config.AddItem(Squad1GodMode = new UIMenuCheckboxItem("God Mode", false, "People kept asking for this."));
  733.  
  734.         //SQUAD 1 SPECIAL ORDERS
  735.         var Squad1SpecialOrdersItem = new UIMenuItem("Special Orders","This submenu contains orders that can only be issued under certain conditions.");
  736.         Squad1Menu.AddItem(Squad1SpecialOrdersItem);
  737.         Squad1SpecialOrdersItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  738.         var Squad1SpecialOrdersMenu = new UIMenu("~b~Special Orders", "~b~Not so common orders.");
  739.         _menuPool.Add(Squad1SpecialOrdersMenu);
  740.  
  741.         Squad1Menu.BindMenuToItem(Squad1SpecialOrdersMenu, Squad1SpecialOrdersItem);
  742.         Squad1SpecialOrdersMenu.AddItem(SwitchSirensSquad1 = new UIMenuItem("Siren on/off", "If the squad leader is in an Emergency vehicle, it will switch the vehicle's sirens on or off."));
  743.         Squad1SpecialOrdersMenu.AddItem(RappelSquad1 = new UIMenuItem("Rappel From Heli", "If the squad is in an Helicopter that allows rappeling, the passengers will rappel to the ground."));        
  744.         Squad1SpecialOrdersMenu.AddItem(AttachVehiclesSquad1 = new UIMenuItem("Attach/Detach vehicle", "If the squad is driving a Cargobob, Truck or Towtruck, they will attach nearby vehicles to them."));
  745.         Squad1SpecialOrdersMenu.AddItem(ParkNearbySquad1 = new UIMenuItem("Park Nearby", "The Squad leader will try to park his vehicle nearby."));
  746.         Squad1SpecialOrdersMenu.AddItem(FollowmeOffroadSquad1 = new UIMenuItem("Follow me, we're going offroad", "The Squad leader will try follow you offroad."));
  747.         Squad1SpecialOrdersMenu.AddItem(GuardThisAreaSquad1 = new UIMenuItem("Watch out for enemies", "The Squad leader will try to watch out for enemies."));
  748.  
  749.         //SQUAD 1 RELATIONSHIPS
  750.         var Squad1RelationshipsItem = new UIMenuItem("Relationships Menu", "Define the faction relationships.");
  751.         Squad1Config.AddItem(Squad1RelationshipsItem);
  752.  
  753.         Squad1RelationshipsItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  754.         var Squad1RelationshipsMenu = new UIMenu("~b~Relationships Menu", "~b~Define the faction relationships.");
  755.         _menuPool.Add(Squad1RelationshipsMenu);
  756.         Squad1Config.BindMenuToItem(Squad1RelationshipsMenu, Squad1RelationshipsItem);
  757.  
  758.         Squad1RelationshipsMenu.AddItem(Squad1HateSquad2 = new UIMenuCheckboxItem("Hate Squad 2", false, "While checked, Squad 1 will attack Squad 2 on sight."));
  759.         Squad1RelationshipsMenu.AddItem(Squad1HateSquad3 = new UIMenuCheckboxItem("Hate Squad 3", false, "While checked, Squad 1 will attack Squad 2 on sight."));
  760.         Squad1RelationshipsMenu.AddItem(Squad1HateSquad4 = new UIMenuCheckboxItem("Hate Squad 4", false, "While checked, Squad 1 will attack Squad 2 on sight."));
  761.         Squad1RelationshipsMenu.AddItem(Squad1HatePlayer = new UIMenuCheckboxItem("Hate Player", false, "While checked, Squad 1 will attack you on sight."));
  762.  
  763.         Squad1RelationshipsMenu.AddItem(Squad1Hate = new UIMenuItem("Open Hate Input", "Any RelationshipGroup you type here will be hated by this Squad. If the squad already hates that RelationShipGroup, they will stop hating it."));
  764.         Squad1RelationshipsMenu.AddItem(Squad1Like = new UIMenuItem("Open Allies Input", "Any RelationshipGroup you type here will be liked by this Squad. If the squad already likes RelationShipGroup, they will stop liking it."));
  765.  
  766.         //SQUAD 1 MAIN MENU PART 2
  767.         Squad1Menu.AddItem(EscortMeSquad1 = new UIMenuItem("Escort my vehicle", "The leader will follow your vehicle. If you're on foot, Helicopters can follow you too."));
  768.         Squad1Menu.AddItem(GetBackToMeSquad1 = new UIMenuItem("Get back to me", "The leader will try to run/drive to your position, or the nearest point possible. They will get to their vehicles if you're too far."));
  769.         Squad1Menu.AddItem(GoToWaypointSquad1 = new UIMenuItem("Go to waypoint", "The leader will try to run/drive to the waypoint, or the nearest point possible."));
  770.         Squad1Menu.AddItem(EnterLeaveVehicleSquad1 = new UIMenuItem("Enter/exit/land vehicle", "The squad will leave their current vehicle or go back to their last vehicle, if they are on foot. Also counts as 'landing' when in an Helicopter."));
  771.         mainMenu.BindMenuToItem(Squad1Menu, Squad1MenuItem);
  772.  
  773.  
  774.         var banner = new UIResRectangle();
  775.         banner.Color = Color.FromArgb(255, 0, 85, 150);
  776.         Squad1Menu.SetBannerType(banner);
  777.         Squad1Config.SetBannerType(banner);
  778.         Squad1Setup.SetBannerType(banner);
  779.         Squad1SpecialOrdersMenu.SetBannerType(banner);
  780.         Squad1RelationshipsMenu.SetBannerType(banner);
  781.  
  782.         //SQUAD 2 MAIN MENU
  783.         Squad2MenuItem = new UIMenuItem("~y~Squad 2");
  784.         mainMenu.AddItem(Squad2MenuItem);
  785.         Squad2Menu = new UIMenu("~y~Squad 2","");
  786.         _menuPool.Add(Squad2Menu);
  787.  
  788.         //SQUAD 2 SETUP
  789.         var Squad2SetupItem = new UIMenuItem("Squad Setup", "Set up this squad and configure their behavior.");
  790.         Squad2SetupItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  791.         Squad2Menu.AddItem(Squad2SetupItem);
  792.         var Squad2Setup = new UIMenu("~y~Squad Setup", "~y~Configure the second Squad from there.");
  793.         _menuPool.Add(Squad2Setup);
  794.         Squad2Menu.BindMenuToItem(Squad2Setup, Squad2SetupItem);
  795.         Squad2Setup.AddItem(Squad2StyleItem = new UIMenuListItem("Unit Style", SquadStyle, 0));
  796.         Squad2Setup.AddItem(Squad2NumberItem = new UIMenuListItem("Units", NumberOfPeople, 7));
  797.         Squad2Setup.AddItem(Squad2VehicleSelection = new UIMenuListItem("Vehicle", SquadVehicles, 0, "The vehicle they will come in. Be aware of how many passengers the vehicle will fit in."));
  798.         Squad2Setup.AddItem(MainWeaponSquad2List = new UIMenuListItem("Main weapon", MainWeaponsSquad, 0));
  799.         Squad2Setup.AddItem(SecondaryWeaponSquad2List = new UIMenuListItem("Secondary weapon", SecondaryWeaponsSquad, 0, "This list includes melee and light weapons."));
  800.  
  801.         Squad2Setup.AddItem(Squad2Autocall = new UIMenuCheckboxItem("Re-call when defeated", false));
  802.         Squad2Setup.AddItem(Squad2DispatchToWaypoint = new UIMenuCheckboxItem("Dispatch to Waypoint", false));
  803.         Squad2DispatchToWaypoint.Description = "If checked, the squad will be dispatched to your Waypoint instead of your actual position.";
  804.  
  805.         Squad2Setup.AddItem(CallSquad2 = new UIMenuItem("Call Squad", "Spawn this squad with the above defined parameters."));
  806.         Squad2Setup.AddItem(DeleteSquad2 = new UIMenuItem("Dismiss Squad", "Make the Squad leave."));
  807.  
  808.         //SQUAD 2 CONFIG BEHAVIOR
  809.         var Squad2ConfigItem = new UIMenuItem("Squad Behaviour", "");
  810.         Squad2ConfigItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  811.         var Squad2Config = new UIMenu("~y~Squad Behaviour", "~y~These options affect the squad in real time.");
  812.         _menuPool.Add(Squad2Config);
  813.         Squad2Menu.AddItem(Squad2ConfigItem);
  814.         Squad2Menu.BindMenuToItem(Squad2Config, Squad2ConfigItem);
  815.  
  816.         Squad2Config.AddItem(DrivingStyleSquad2 = new UIMenuListItem("Driving style", DrivingStyle, 1, "How the leader will drive. Careful: Slow, overtaking with care. Normal: Somewhat fast, overtaking with care. Fast: Fastest, careless overtaking."));
  817.         Squad2Config.AddItem(Squad2ReactToEvents = new UIMenuCheckboxItem("React to enemies", true, "When enabled, the squad will only obey when is not in combat."));
  818.         Squad2Config.AddItem(Squad2Followplayer = new UIMenuCheckboxItem("Follow Player", false, "The Squad will follow you automatically. They will hop in your vehicles, too."));
  819.         Squad2Config.AddItem(Squad2GodMode = new UIMenuCheckboxItem("God Mode", false, "People kept asking for this."));
  820.  
  821.         //SQUAD 2 SPECIAL ORDERS
  822.         var Squad2SpecialOrdersItem = new UIMenuItem("Special Orders", "This submenu contains orders that can only be issued under certain conditions.");
  823.         Squad2SpecialOrdersItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  824.  
  825.         Squad2Menu.AddItem(Squad2SpecialOrdersItem);
  826.         var Squad2SpecialOrdersMenu = new UIMenu("~y~Special Orders", "~y~Not so common orders.");
  827.         _menuPool.Add(Squad2SpecialOrdersMenu);
  828.         Squad2Menu.BindMenuToItem(Squad2SpecialOrdersMenu, Squad2SpecialOrdersItem);
  829.         Squad2SpecialOrdersMenu.AddItem(SwitchSirensSquad2 = new UIMenuItem("Siren on/off", "If the squad leader is in an Emergency vehicle, it will switch the vehicle's sirens on or off."));
  830.         Squad2Menu.BindMenuToItem(Squad2SpecialOrdersMenu, Squad2SpecialOrdersItem);
  831.         Squad2SpecialOrdersMenu.AddItem(RappelSquad2 = new UIMenuItem("Rappel From Heli", "If the squad is in an Helicopter that allows rappeling, the passengers will rappel to the ground."));
  832.         Squad2SpecialOrdersMenu.AddItem(AttachVehiclesSquad2 = new UIMenuItem("Attach/Detach vehicle", "If the squad is driving a Cargobob, Truck or Towtruck, they will attach nearby vehicles to them."));
  833.         Squad2SpecialOrdersMenu.AddItem(ParkNearbySquad2 = new UIMenuItem("Park Nearby", "The Squad leader will try to park his vehicle nearby."));
  834.         Squad2SpecialOrdersMenu.AddItem(FollowmeOffroadSquad2 = new UIMenuItem("Follow me, we're going offroad", "The Squad leader will try follow you offroad."));
  835.         Squad2SpecialOrdersMenu.AddItem(GuardThisAreaSquad2 = new UIMenuItem("Watch out for enemies", "The Squad leader will try to watch out for enemies."));
  836.  
  837.         //SQUAD 2 RELATIONSHIPS
  838.         var Squad2RelationshipsItem = new UIMenuItem("Relationships Menu", "Define the faction relationships.");
  839.         Squad2Config.AddItem(Squad2RelationshipsItem);
  840.  
  841.         Squad2RelationshipsItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  842.         var Squad2RelationshipsMenu = new UIMenu("~y~Relationships Menu", "~y~Define the faction relationships.");
  843.         _menuPool.Add(Squad2RelationshipsMenu);
  844.         Squad2Config.BindMenuToItem(Squad2RelationshipsMenu, Squad2RelationshipsItem);
  845.         Squad2RelationshipsMenu.AddItem(Squad2HateSquad1 = new UIMenuCheckboxItem("Hate Squad 1", false, "While checked, Squad 2 will attack Squad 1 on sight."));
  846.         Squad2RelationshipsMenu.AddItem(Squad2HateSquad3 = new UIMenuCheckboxItem("Hate Squad 3", false, "While checked, Squad 2 will attack Squad 1 on sight."));
  847.         Squad2RelationshipsMenu.AddItem(Squad2HateSquad4 = new UIMenuCheckboxItem("Hate Squad 4", false, "While checked, Squad 2 will attack Squad 1 on sight."));
  848.         Squad2RelationshipsMenu.AddItem(Squad2HatePlayer = new UIMenuCheckboxItem("Hate Player", false, "While checked, Squad 2 will attack you on sight."));
  849.         Squad2RelationshipsMenu.AddItem(Squad2Hate = new UIMenuItem("Open Hate Input", "Any RelationshipGroup you type here will be hated by this Squad. If the squad already hates that RelationshipGroup, they will stop hating it."));
  850.         Squad2RelationshipsMenu.AddItem(Squad2Like = new UIMenuItem("Open Allies Input", "Any RelationshipGroup you type here will be liked by this Squad. If the squad already likes RelationshipGroup, they will stop liking it."));
  851.  
  852.         //SQUAD 2 MAIN MENU PART 2
  853.         Squad2Menu.AddItem(EscortMeSquad2 = new UIMenuItem("Escort my vehicle", "The leader will follow your vehicle. If you're on foot, Helicopters can follow you too."));
  854.         Squad2Menu.AddItem(GetBackToMeSquad2 = new UIMenuItem("Get back to me", "The leader will try to run/drive to your position, or the nearest point possible. They will get to their vehicles if you're too far."));
  855.  
  856.         Squad2Menu.AddItem(GoToWaypointSquad2 = new UIMenuItem("Go to waypoint", "The leader will try to run/drive to the waypoint, or the nearest point possible."));
  857.         Squad2Menu.AddItem(EnterLeaveVehicleSquad2 = new UIMenuItem("Enter/exit/land vehicle", "The squad will leave their current vehicle or go back to their last vehicle, if they are on foot. Also counts as 'landing' when in an Helicopter."));
  858.         mainMenu.BindMenuToItem(Squad2Menu, Squad2MenuItem);
  859.  
  860.         var banner2 = new UIResRectangle();
  861.  
  862.         banner2.Color = Color.FromArgb(255, 143, 124, 0);
  863.  
  864.  
  865.  
  866.  
  867.         //SQUAD 3 MAIN MENU
  868.         Squad3MenuItem = new UIMenuItem("~g~Squad 3");
  869.         mainMenu.AddItem(Squad3MenuItem);
  870.         Squad3Menu = new UIMenu("~g~Squad 3", "");
  871.         _menuPool.Add(Squad3Menu);
  872.  
  873.         //SQUAD 3 SETUP
  874.         var Squad3SetupItem = new UIMenuItem("Squad Setup", "Set up this squad and configure their behavior.");
  875.         Squad3SetupItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  876.         Squad3Menu.AddItem(Squad3SetupItem);
  877.         var Squad3Setup = new UIMenu("~g~Squad Setup", "~g~Configure the first Squad from there.");
  878.         _menuPool.Add(Squad3Setup);
  879.         Squad3Menu.BindMenuToItem(Squad3Setup, Squad3SetupItem);
  880.         Squad3Setup.AddItem(Squad3StyleItem = new UIMenuListItem("Unit Style", SquadStyle, 0));
  881.         Squad3Setup.AddItem(Squad3NumberItem = new UIMenuListItem("Units", NumberOfPeople, 7));
  882.         Squad3Setup.AddItem(Squad3VehicleSelection = new UIMenuListItem("Vehicle", SquadVehicles, 0, "The vehicle they will come in. Be aware of how many passengers the vehicle will fit in."));
  883.         Squad3Setup.AddItem(MainWeaponSquad3List = new UIMenuListItem("Main weapon", MainWeaponsSquad, 0, "This list includes heavy weapons."));
  884.         Squad3Setup.AddItem(SecondaryWeaponSquad3List = new UIMenuListItem("Secondary weapon", SecondaryWeaponsSquad, 0, "This list includes melee and light weapons."));
  885.         Squad3Setup.AddItem(Squad3Autocall = new UIMenuCheckboxItem("Re-call when defeated", false));
  886.         Squad3Setup.AddItem(Squad3DispatchToWaypoint = new UIMenuCheckboxItem("Dispatch to Waypoint", false));
  887.         Squad3DispatchToWaypoint.Description = "If checked, the squad will be dispatched to your Waypoint instead of your actual position.";
  888.         Squad3Setup.AddItem(CallSquad3 = new UIMenuItem("Call Squad", "Spawn this squad with the above defined paramet."));
  889.         Squad3Setup.AddItem(DeleteSquad3 = new UIMenuItem("Dismiss Squad", "Make the Squad leave."));
  890.  
  891.         //SQUAD 3 CONFIG BEHAVIOR
  892.         var Squad3ConfigItem = new UIMenuItem("Squad Behaviour", "");
  893.         Squad3ConfigItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  894.         var Squad3Config = new UIMenu("~g~Squad Behaviour", "~g~These options affect the squad in real time.");
  895.         _menuPool.Add(Squad3Config);
  896.         Squad3Menu.AddItem(Squad3ConfigItem);
  897.         Squad3Menu.BindMenuToItem(Squad3Config, Squad3ConfigItem);
  898.         Squad3Config.AddItem(DrivingStyleSquad3 = new UIMenuListItem("Driving style", DrivingStyle, 1, "How the leader will drive. Careful: Slow, overtaking with care. Normal: Somewhat fast, overtaking with care. Fast: Fastest, careless overtaking."));
  899.         Squad3Config.AddItem(Squad3ReactToEvents = new UIMenuCheckboxItem("React to enemies", true, "When enabled, the squad will only obey when is not in combat."));
  900.         Squad3Config.AddItem(Squad3Followplayer = new UIMenuCheckboxItem("Follow Player", false, "The Squad will follow you automatically. They will hop in your vehicles, too."));
  901.         Squad3Config.AddItem(Squad3GodMode = new UIMenuCheckboxItem("God Mode", false, "People kept asking for this."));
  902.  
  903.         //SQUAD 3 SPECIAL ORDERS
  904.         var Squad3SpecialOrdersItem = new UIMenuItem("Special Orders", "This submenu contains orders that can only be issued under certain conditions.");
  905.         Squad3Menu.AddItem(Squad3SpecialOrdersItem);
  906.         Squad3SpecialOrdersItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  907.         var Squad3SpecialOrdersMenu = new UIMenu("~g~Special Orders", "~g~Not so common orders.");
  908.         _menuPool.Add(Squad3SpecialOrdersMenu);
  909.  
  910.         Squad3Menu.BindMenuToItem(Squad3SpecialOrdersMenu, Squad3SpecialOrdersItem);
  911.         Squad3SpecialOrdersMenu.AddItem(SwitchSirensSquad3 = new UIMenuItem("Siren on/off", "If the squad leader is in an Emergency vehicle, it will switch the vehicle's sirens on or off."));
  912.         Squad3SpecialOrdersMenu.AddItem(RappelSquad3 = new UIMenuItem("Rappel From Heli", "If the squad is in an Helicopter that allows rappeling, the passengers will rappel to the ground."));
  913.         Squad3SpecialOrdersMenu.AddItem(AttachVehiclesSquad3 = new UIMenuItem("Attach/Detach vehicle", "If the squad is driving a Cargobob, Truck or Towtruck, they will attach nearby vehicles to them."));
  914.         Squad3SpecialOrdersMenu.AddItem(ParkNearbySquad3 = new UIMenuItem("Park Nearby", "The Squad leader will try to park his vehicle nearby."));
  915.         Squad3SpecialOrdersMenu.AddItem(FollowmeOffroadSquad3 = new UIMenuItem("Follow me, we're going offroad", "The Squad leader will try follow you offroad."));
  916.         Squad3SpecialOrdersMenu.AddItem(GuardThisAreaSquad3 = new UIMenuItem("Watch out for enemies", "The Squad leader will try to watch out for enemies."));
  917.  
  918.         //SQUAD 3 RELATIONSHIPS
  919.         var Squad3RelationshipsItem = new UIMenuItem("Relationships Menu", "Define the faction relationships.");
  920.         Squad3Config.AddItem(Squad3RelationshipsItem);
  921.  
  922.         Squad3RelationshipsItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  923.         var Squad3RelationshipsMenu = new UIMenu("~g~Relationships Menu", "~g~Define the faction relationships.");
  924.         _menuPool.Add(Squad3RelationshipsMenu);
  925.         Squad3Config.BindMenuToItem(Squad3RelationshipsMenu, Squad3RelationshipsItem);
  926.  
  927.         Squad3RelationshipsMenu.AddItem(Squad3HateSquad1 = new UIMenuCheckboxItem("Hate Squad 1", false, "While checked, SQUAD 3 will attack Squad 2 on sight."));
  928.         Squad3RelationshipsMenu.AddItem(Squad3HateSquad2 = new UIMenuCheckboxItem("Hate Squad 2", false, "While checked, SQUAD 3 will attack Squad 2 on sight."));
  929.         Squad3RelationshipsMenu.AddItem(Squad3HateSquad4 = new UIMenuCheckboxItem("Hate Squad 4", false, "While checked, SQUAD 3 will attack Squad 2 on sight."));
  930.         Squad3RelationshipsMenu.AddItem(Squad3HatePlayer = new UIMenuCheckboxItem("Hate Player", false, "While checked, SQUAD 3 will attack you on sight."));
  931.  
  932.         Squad3RelationshipsMenu.AddItem(Squad3Hate = new UIMenuItem("Open Hate Input", "Any RelationshipGroup you type here will be hated by this Squad. If the squad already hates that RelationShipGroup, they will stop hating it."));
  933.         Squad3RelationshipsMenu.AddItem(Squad3Like = new UIMenuItem("Open Allies Input", "Any RelationshipGroup you type here will be liked by this Squad. If the squad already likes RelationShipGroup, they will stop liking it."));
  934.  
  935.         //SQUAD 3 MAIN MENU PART 2
  936.         Squad3Menu.AddItem(EscortMeSquad3 = new UIMenuItem("Escort my vehicle", "The leader will follow your vehicle. If you're on foot, Helicopters can follow you too."));
  937.         Squad3Menu.AddItem(GetBackToMeSquad3 = new UIMenuItem("Get back to me", "The leader will try to run/drive to your position, or the nearest point possible. They will get to their vehicles if you're too far."));
  938.         Squad3Menu.AddItem(GoToWaypointSquad3 = new UIMenuItem("Go to waypoint", "The leader will try to run/drive to the waypoint, or the nearest point possible."));
  939.         Squad3Menu.AddItem(EnterLeaveVehicleSquad3 = new UIMenuItem("Enter/exit/land vehicle", "The squad will leave their current vehicle or go back to their last vehicle, if they are on foot. Also counts as 'landing' when in an Helicopter."));
  940.         mainMenu.BindMenuToItem(Squad3Menu, Squad3MenuItem);
  941.  
  942.  
  943.         var banner3 = new UIResRectangle();
  944.         banner3.Color = Color.FromArgb(255, 12, 173, 0);
  945.         Squad3Menu.SetBannerType(banner3);
  946.         Squad3Config.SetBannerType(banner3);
  947.         Squad3Setup.SetBannerType(banner3);
  948.         Squad3SpecialOrdersMenu.SetBannerType(banner3);
  949.         Squad3RelationshipsMenu.SetBannerType(banner3);
  950.  
  951.  
  952.  
  953.  
  954.         //SQUAD 4 MAIN MENU
  955.         Squad4MenuItem = new UIMenuItem("~o~Squad 4");
  956.         mainMenu.AddItem(Squad4MenuItem);
  957.         Squad4Menu = new UIMenu("~o~Squad 4", "");
  958.         _menuPool.Add(Squad4Menu);
  959.  
  960.         //SQUAD 4 SETUP
  961.         var Squad4SetupItem = new UIMenuItem("Squad Setup", "Set up this squad and configure their behavior.");
  962.         Squad4SetupItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  963.         Squad4Menu.AddItem(Squad4SetupItem);
  964.         var Squad4Setup = new UIMenu("~o~Squad Setup", "~o~Configure the first Squad from there.");
  965.         _menuPool.Add(Squad4Setup);
  966.         Squad4Menu.BindMenuToItem(Squad4Setup, Squad4SetupItem);
  967.         Squad4Setup.AddItem(Squad4StyleItem = new UIMenuListItem("Unit Style", SquadStyle, 0));
  968.         Squad4Setup.AddItem(Squad4NumberItem = new UIMenuListItem("Units", NumberOfPeople, 7));
  969.         Squad4Setup.AddItem(Squad4VehicleSelection = new UIMenuListItem("Vehicle", SquadVehicles, 0, "The vehicle they will come in. Be aware of how many passengers the vehicle will fit in."));
  970.         Squad4Setup.AddItem(MainWeaponSquad4List = new UIMenuListItem("Main weapon", MainWeaponsSquad, 0, "This list includes heavy weapons."));
  971.         Squad4Setup.AddItem(SecondaryWeaponSquad4List = new UIMenuListItem("Secondary weapon", SecondaryWeaponsSquad, 0, "This list includes melee and light weapons."));
  972.         Squad4Setup.AddItem(Squad4Autocall = new UIMenuCheckboxItem("Re-call when defeated", false));
  973.         Squad4Setup.AddItem(Squad4DispatchToWaypoint = new UIMenuCheckboxItem("Dispatch to Waypoint", false));
  974.         Squad4DispatchToWaypoint.Description = "If checked, the squad will be dispatched to your Waypoint instead of your actual position.";
  975.         Squad4Setup.AddItem(CallSquad4 = new UIMenuItem("Call Squad", "Spawn this squad with the above defined paramet."));
  976.         Squad4Setup.AddItem(DeleteSquad4 = new UIMenuItem("Dismiss Squad", "Make the Squad leave."));
  977.  
  978.         //SQUAD 4 CONFIG BEHAVIOR
  979.         var Squad4ConfigItem = new UIMenuItem("Squad Behaviour", "");
  980.         Squad4ConfigItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  981.         var Squad4Config = new UIMenu("~o~Squad Behaviour", "~o~These options affect the squad in real time.");
  982.         _menuPool.Add(Squad4Config);
  983.         Squad4Menu.AddItem(Squad4ConfigItem);
  984.         Squad4Menu.BindMenuToItem(Squad4Config, Squad4ConfigItem);
  985.         Squad4Config.AddItem(DrivingStyleSquad4 = new UIMenuListItem("Driving style", DrivingStyle, 1, "How the leader will drive. Careful: Slow, overtaking with care. Normal: Somewhat fast, overtaking with care. Fast: Fastest, careless overtaking."));
  986.         Squad4Config.AddItem(Squad4ReactToEvents = new UIMenuCheckboxItem("React to enemies", true, "When enabled, the squad will only obey when is not in combat."));
  987.         Squad4Config.AddItem(Squad4Followplayer = new UIMenuCheckboxItem("Follow Player", false, "The Squad will follow you automatically. They will hop in your vehicles, too."));
  988.         Squad4Config.AddItem(Squad4GodMode = new UIMenuCheckboxItem("God Mode", false, "People kept asking for this."));
  989.  
  990.         //SQUAD 4 SPECIAL ORDERS
  991.         var Squad4SpecialOrdersItem = new UIMenuItem("Special Orders", "This submenu contains orders that can only be issued under certain conditions.");
  992.         Squad4Menu.AddItem(Squad4SpecialOrdersItem);
  993.         Squad4SpecialOrdersItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  994.         var Squad4SpecialOrdersMenu = new UIMenu("~o~Special Orders", "~o~Not so common orders.");
  995.         _menuPool.Add(Squad4SpecialOrdersMenu);
  996.  
  997.         Squad4Menu.BindMenuToItem(Squad4SpecialOrdersMenu, Squad4SpecialOrdersItem);
  998.         Squad4SpecialOrdersMenu.AddItem(SwitchSirensSquad4 = new UIMenuItem("Siren on/off", "If the squad leader is in an Emergency vehicle, it will switch the vehicle's sirens on or off."));
  999.         Squad4SpecialOrdersMenu.AddItem(RappelSquad4 = new UIMenuItem("Rappel From Heli", "If the squad is in an Helicopter that allows rappeling, the passengers will rappel to the ground."));
  1000.         Squad4SpecialOrdersMenu.AddItem(AttachVehiclesSquad4 = new UIMenuItem("Attach/Detach vehicle", "If the squad is driving a Cargobob, Truck or Towtruck, they will attach nearby vehicles to them."));
  1001.         Squad4SpecialOrdersMenu.AddItem(ParkNearbySquad4 = new UIMenuItem("Park Nearby", "The Squad leader will try to park his vehicle nearby."));
  1002.         Squad4SpecialOrdersMenu.AddItem(FollowmeOffroadSquad4 = new UIMenuItem("Follow me, we're going offroad", "The Squad leader will try follow you offroad."));
  1003.         Squad4SpecialOrdersMenu.AddItem(GuardThisAreaSquad4 = new UIMenuItem("Watch out for enemies", "The Squad leader will try to watch out for enemies."));
  1004.  
  1005.         //SQUAD 4 RELATIONSHIPS
  1006.         var Squad4RelationshipsItem = new UIMenuItem("Relationships Menu", "Define the faction relationships.");
  1007.         Squad4Config.AddItem(Squad4RelationshipsItem);
  1008.  
  1009.         Squad4RelationshipsItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  1010.         var Squad4RelationshipsMenu = new UIMenu("~o~Relationships Menu", "~o~Define the faction relationships.");
  1011.         _menuPool.Add(Squad4RelationshipsMenu);
  1012.         Squad4Config.BindMenuToItem(Squad4RelationshipsMenu, Squad4RelationshipsItem);
  1013.  
  1014.         Squad4RelationshipsMenu.AddItem(Squad4HateSquad1 = new UIMenuCheckboxItem("Hate Squad 1", false, "While checked, SQUAD 4 will attack Squad 2 on sight."));
  1015.         Squad4RelationshipsMenu.AddItem(Squad4HateSquad2 = new UIMenuCheckboxItem("Hate Squad 2", false, "While checked, SQUAD 4 will attack Squad 2 on sight."));
  1016.         Squad4RelationshipsMenu.AddItem(Squad4HateSquad3 = new UIMenuCheckboxItem("Hate Squad 3", false, "While checked, SQUAD 4 will attack Squad 2 on sight."));
  1017.         Squad4RelationshipsMenu.AddItem(Squad4HatePlayer = new UIMenuCheckboxItem("Hate Player", false, "While checked, SQUAD 4 will attack you on sight."));
  1018.  
  1019.         Squad4RelationshipsMenu.AddItem(Squad4Hate = new UIMenuItem("Open Hate Input", "Any RelationshipGroup you type here will be hated by this Squad. If the squad already hates that RelationShipGroup, they will stop hating it."));
  1020.         Squad4RelationshipsMenu.AddItem(Squad4Like = new UIMenuItem("Open Allies Input", "Any RelationshipGroup you type here will be liked by this Squad. If the squad already likes RelationShipGroup, they will stop liking it."));
  1021.  
  1022.         //SQUAD 4 MAIN MENU PART 2
  1023.         Squad4Menu.AddItem(EscortMeSquad4 = new UIMenuItem("Escort my vehicle", "The leader will follow your vehicle. If you're on foot, Helicopters can follow you too."));
  1024.         Squad4Menu.AddItem(GetBackToMeSquad4 = new UIMenuItem("Get back to me", "The leader will try to run/drive to your position, or the nearest point possible. They will get to their vehicles if you're too far."));
  1025.         Squad4Menu.AddItem(GoToWaypointSquad4 = new UIMenuItem("Go to waypoint", "The leader will try to run/drive to the waypoint, or the nearest point possible."));
  1026.         Squad4Menu.AddItem(EnterLeaveVehicleSquad4 = new UIMenuItem("Enter/exit/land vehicle", "The squad will leave their current vehicle or go back to their last vehicle, if they are on foot. Also counts as 'landing' when in an Helicopter."));
  1027.         mainMenu.BindMenuToItem(Squad4Menu, Squad4MenuItem);
  1028.  
  1029.  
  1030.         var banner4 = new UIResRectangle();
  1031.         banner4.Color = Squad4Color;
  1032.         Squad4Menu.SetBannerType(banner4);
  1033.         Squad4Config.SetBannerType(banner4);
  1034.         Squad4Setup.SetBannerType(banner4);
  1035.         Squad4SpecialOrdersMenu.SetBannerType(banner4);
  1036.         Squad4RelationshipsMenu.SetBannerType(banner4);
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.         //ALL SQUADS MAIN MENU
  1046.         mainMenu.AddItem(AllSquadsMenuItem = new UIMenuItem("All Squads","Apply orders to all the squads at once."));        
  1047.         _menuPool.Add(AllSquadsMenu = new UIMenu("All Squads", "Apply orders to all the squads at once."));
  1048.         mainMenu.BindMenuToItem(AllSquadsMenu, AllSquadsMenuItem);
  1049.  
  1050.         AllSquadsMenu.AddItem(AllGoToWaypoint = new UIMenuItem("Go to waypoint", "The leader will try to run/drive to the waypoint, or the nearest point possible."));
  1051.         AllSquadsMenu.AddItem(AllGetBackToMe = new UIMenuItem("Get back to me", "The leader will try to run/drive to your position, or the nearest point possible. They will get to their vehicles if you're too far."));
  1052.         AllSquadsMenu.AddItem(AllEnterLeave = new UIMenuItem("Enter/Leave/Land vehicle", "The squads will leave their current vehicles or go back to their last vehicles, if they are on foot. Also counts as 'landing' when in an Helicopter."));
  1053.         AllSquadsMenu.AddItem(AllCallSquad = new UIMenuItem("Call", "All the Squads will be spawned with their current setup."));
  1054.         AllSquadsMenu.AddItem(AllDismissSquad = new UIMenuItem("Dimiss", "All the Squads will be dismissed."));
  1055.  
  1056.         //ALL SQUADS RACE
  1057.         AllSquadsMenu.AddItem(AllSquadsRaceMenuItem = new UIMenuItem("Race commands", "Some commands to set up races with the squads."));
  1058.         _menuPool.Add(AllSquadsRaceMenu = new UIMenu("Race Commands", "Smoke 'em."));
  1059.         AllSquadsRaceMenuItem.SetLeftBadge(UIMenuItem.BadgeStyle.Michael);
  1060.         AllSquadsMenu.BindMenuToItem(AllSquadsRaceMenu, AllSquadsRaceMenuItem);
  1061.  
  1062.         AllSquadsRaceMenu.AddItem(AllSquadsAddWaypoint = new UIMenuItem("Add Waypoint", "The current map waypoint position will be added as a waypoint for the race. If there is no map waypoint set, your own position will be used."));
  1063.         AllSquadsRaceMenu.AddItem(AllSquadsClearWaypoints = new UIMenuItem("Clear All Waypoints", "Remove all waypoints so you can start from scratch."));
  1064.         AllSquadsRaceMenu.AddItem(AllParkAtMySide = new UIMenuItem("Park at my sides", "The Squad leaders will park at your sides. Think of it as an improvised starting line."));
  1065.         AllSquadsRaceMenu.AddItem(AllSquadsStartRace = new UIMenuItem("Start Race", "Makes all squad leaders drive their vehicles through the waypoints you defined. They will stop at the last one."));
  1066.  
  1067.         var banner5 = new UIResRectangle();
  1068.         banner5.Color = Color.FromArgb(255, 118, 118, 118);
  1069.         AllSquadsRaceMenu.SetBannerType(banner5);
  1070.         AllSquadsMenu.SetBannerType(banner5);
  1071.  
  1072.  
  1073.         mainMenu.MouseControlsEnabled = false;
  1074.         foreach (UIMenu menu in _menuPool.ToList())
  1075.         {
  1076.             menu.RefreshIndex();
  1077.             menu.OnItemSelect += OnItemSelect;
  1078.             menu.OnListChange += OnListChange;
  1079.             menu.OnCheckboxChange += OnCheckboxChange;
  1080.             menu.OnIndexChange += OnItemChange;
  1081.             menu.OnMenuClose += OnMenuClose;
  1082.         }
  1083.  
  1084.  
  1085.         //SQUADS LOVE U
  1086.         World.SetRelationshipBetweenGroups(Relationship.Companion, Squad1RelationshipGroup, Game.Player.Character.RelationshipGroup);
  1087.         World.SetRelationshipBetweenGroups(Relationship.Companion, Squad2RelationshipGroup, Game.Player.Character.RelationshipGroup);
  1088.         World.SetRelationshipBetweenGroups(Relationship.Companion, Squad3RelationshipGroup, Game.Player.Character.RelationshipGroup);
  1089.         World.SetRelationshipBetweenGroups(Relationship.Companion, Squad4RelationshipGroup, Game.Player.Character.RelationshipGroup);
  1090.  
  1091.         //NOoSE Mod compatiblity
  1092.  
  1093.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "MOD_NOOSE"), Squad1RelationshipGroup, Relationship.Companion);
  1094.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "MOD_NOOSE"), Squad2RelationshipGroup, Relationship.Companion);
  1095.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "MOD_NOOSE"), Squad3RelationshipGroup, Relationship.Companion);
  1096.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "MOD_NOOSE"), Squad4RelationshipGroup, Relationship.Companion);
  1097.  
  1098.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "noose_targets"), Squad1RelationshipGroup, Relationship.Hate);
  1099.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "noose_targets"), Squad2RelationshipGroup, Relationship.Hate);
  1100.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "noose_targets"), Squad3RelationshipGroup, Relationship.Hate);
  1101.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "noose_targets"), Squad4RelationshipGroup, Relationship.Hate);
  1102.  
  1103.         //Arms Trading compatiblity        
  1104.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "Enemy Gang"), Squad1RelationshipGroup, Relationship.Hate);
  1105.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "Enemy Gang"), Squad2RelationshipGroup, Relationship.Hate);
  1106.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "Enemy Gang"), Squad3RelationshipGroup, Relationship.Hate);
  1107.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "Enemy Gang"), Squad4RelationshipGroup, Relationship.Hate);
  1108.  
  1109.         //General compatiblity
  1110.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "HATES_PLAYER"), Squad1RelationshipGroup, Relationship.Hate);
  1111.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "HATES_PLAYER"), Squad2RelationshipGroup, Relationship.Hate);
  1112.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "HATES_PLAYER"), Squad3RelationshipGroup, Relationship.Hate);
  1113.         SetRelationshipGroup(Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, "HATES_PLAYER"), Squad4RelationshipGroup, Relationship.Hate);
  1114.  
  1115.         //SQUADS LOVE EACH OTHER BY DEFAULT
  1116.         SetRelationshipGroup(Squad1RelationshipGroup, Squad2RelationshipGroup, Relationship.Companion);
  1117.         SetRelationshipGroup(Squad1RelationshipGroup, Squad3RelationshipGroup, Relationship.Companion);
  1118.         SetRelationshipGroup(Squad1RelationshipGroup, Squad4RelationshipGroup, Relationship.Companion);
  1119.  
  1120.         SetRelationshipGroup(Squad2RelationshipGroup, Squad1RelationshipGroup, Relationship.Companion);
  1121.         SetRelationshipGroup(Squad2RelationshipGroup, Squad3RelationshipGroup, Relationship.Companion);
  1122.         SetRelationshipGroup(Squad2RelationshipGroup, Squad4RelationshipGroup, Relationship.Companion);
  1123.  
  1124.         SetRelationshipGroup(Squad3RelationshipGroup, Squad1RelationshipGroup, Relationship.Companion);
  1125.         SetRelationshipGroup(Squad3RelationshipGroup, Squad2RelationshipGroup, Relationship.Companion);
  1126.         SetRelationshipGroup(Squad3RelationshipGroup, Squad4RelationshipGroup, Relationship.Companion);
  1127.  
  1128.         SetRelationshipGroup(Squad4RelationshipGroup, Squad1RelationshipGroup, Relationship.Companion);
  1129.         SetRelationshipGroup(Squad4RelationshipGroup, Squad2RelationshipGroup, Relationship.Companion);
  1130.         SetRelationshipGroup(Squad4RelationshipGroup, Squad3RelationshipGroup, Relationship.Companion);
  1131.  
  1132.     }
  1133.  
  1134.  
  1135.     //TEST, NOT USED
  1136.     public void RefreshSquadDesc()
  1137.     {
  1138.         Squad1MenuItem.Description = IsSquadActive(1);
  1139.         Squad2MenuItem.Description = IsSquadActive(2);
  1140.     }
  1141.     public string IsSquadActive(int Squad)
  1142.     {
  1143.         switch (Squad)
  1144.         {
  1145.             case 1:
  1146.                 {
  1147.                     if (CanWeUse(Squad1Leader))
  1148.                     {
  1149.                         if (Squad1Leader.IsSittingInVehicle())
  1150.                         {
  1151.                             return "In "+Squad1Leader.CurrentVehicle.FriendlyName;
  1152.                         }
  1153.                         else
  1154.                         {
  1155.                             return "On foot";
  1156.                         }
  1157.                     }
  1158.                     else
  1159.                     {
  1160.                         return "";
  1161.                     }
  1162.                 }
  1163.             case 2:
  1164.                 {
  1165.                     if (CanWeUse(Squad2Leader))
  1166.                     {
  1167.                         if (Squad2Leader.IsSittingInVehicle())
  1168.                         {
  1169.                             return "In "+ Squad2Leader.CurrentVehicle.FriendlyName;
  1170.                         }
  1171.                         else
  1172.                         {
  1173.                             return "On Foot";
  1174.  
  1175.                         }
  1176.                     }
  1177.                     else
  1178.                     {
  1179.                         return "";
  1180.                     }
  1181.                 }
  1182.         }
  1183.  
  1184.         return "";
  1185.     }
  1186.  
  1187.  
  1188.  
  1189.     public void OnMenuClose(UIMenu sender)
  1190.     {
  1191.         if (sender ==mainMenu)
  1192.         {
  1193.             Game.TimeScale = 1;
  1194.  
  1195.         }
  1196.     }
  1197.     public void OnItemChange(UIMenu sender, int index)
  1198.     {
  1199.  
  1200.     }
  1201.  
  1202.     public void OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkbox, bool Checked)
  1203.     {
  1204.         if (checkbox == Squad1ReactToEvents)
  1205.         {
  1206.             if (CanWeUse(Squad1Leader))
  1207.             {
  1208.  
  1209.                 Squad1Leader.BlockPermanentEvents = !Checked;
  1210.             }
  1211.             else
  1212.             {
  1213.                 UI.Notify("~b~Squad 1 ~w~does not exist.");
  1214.             }
  1215.         }
  1216.  
  1217.         if (checkbox == Squad2ReactToEvents)
  1218.         {
  1219.             if (CanWeUse(Squad2Leader))
  1220.             {
  1221.  
  1222.                 Squad2Leader.BlockPermanentEvents = !Checked;
  1223.             }
  1224.             else
  1225.             {
  1226.                 UI.Notify("~y~Squad 2~w~ does not exist.");
  1227.             }
  1228.         }
  1229.  
  1230.         if (checkbox == Squad3ReactToEvents)
  1231.         {
  1232.             if (CanWeUse(Squad3Leader))
  1233.             {
  1234.  
  1235.                 Squad3Leader.BlockPermanentEvents = !Checked;
  1236.             }
  1237.             else
  1238.             {
  1239.                 UI.Notify("~b~Squad 1 ~w~does not exist.");
  1240.             }
  1241.         }
  1242.         if (checkbox == Squad4ReactToEvents)
  1243.         {
  1244.             if (CanWeUse(Squad4Leader))
  1245.             {
  1246.  
  1247.                 Squad4Leader.BlockPermanentEvents = !Checked;
  1248.             }
  1249.             else
  1250.             {
  1251.                 UI.Notify("~b~Squad 1 ~w~does not exist.");
  1252.             }
  1253.         }
  1254.         if (checkbox == Squad1HateSquad2)
  1255.         {
  1256.             if (Checked)
  1257.             {
  1258.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad1RelationshipGroup, Squad2RelationshipGroup);
  1259.             }
  1260.             else
  1261.             {
  1262.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad1RelationshipGroup, Squad2RelationshipGroup);
  1263.             }
  1264.         }
  1265.         if (checkbox == Squad1HateSquad3)
  1266.         {
  1267.             if (Checked)
  1268.             {
  1269.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad1RelationshipGroup, Squad3RelationshipGroup);
  1270.             }
  1271.             else
  1272.             {
  1273.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad1RelationshipGroup, Squad3RelationshipGroup);
  1274.             }
  1275.         }
  1276.         if (checkbox == Squad1HateSquad2)
  1277.         {
  1278.             if (Checked)
  1279.             {
  1280.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad1RelationshipGroup, Squad4RelationshipGroup);
  1281.             }
  1282.             else
  1283.             {
  1284.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad1RelationshipGroup, Squad4RelationshipGroup);
  1285.             }
  1286.         }
  1287.  
  1288.         if (checkbox == Squad1HatePlayer)
  1289.         {
  1290.             if (Checked)
  1291.             {
  1292.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad1RelationshipGroup, Game.Player.Character.RelationshipGroup);
  1293.             }
  1294.             else
  1295.             {
  1296.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad1RelationshipGroup, Game.Player.Character.RelationshipGroup);
  1297.             }
  1298.         }
  1299.  
  1300.         if (checkbox == Squad2HatePlayer)
  1301.         {
  1302.             if (Checked)
  1303.             {
  1304.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad2RelationshipGroup, Game.Player.Character.RelationshipGroup);
  1305.             }
  1306.             else
  1307.             {
  1308.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad2RelationshipGroup, Game.Player.Character.RelationshipGroup);
  1309.             }
  1310.         }
  1311.  
  1312.         if (checkbox == Squad3HatePlayer)
  1313.         {
  1314.             if (Checked)
  1315.             {
  1316.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad3RelationshipGroup, Game.Player.Character.RelationshipGroup);
  1317.             }
  1318.             else
  1319.             {
  1320.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad3RelationshipGroup, Game.Player.Character.RelationshipGroup);
  1321.             }
  1322.         }
  1323.  
  1324.         if (checkbox == Squad4HatePlayer)
  1325.         {
  1326.             if (Checked)
  1327.             {
  1328.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad4RelationshipGroup, Game.Player.Character.RelationshipGroup);
  1329.             }
  1330.             else
  1331.             {
  1332.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad4RelationshipGroup, Game.Player.Character.RelationshipGroup);
  1333.             }
  1334.         }
  1335.  
  1336.         if (checkbox == Squad2HateSquad1)
  1337.         {
  1338.             if (Checked)
  1339.             {
  1340.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad2RelationshipGroup, Squad1RelationshipGroup);
  1341.             }
  1342.             else
  1343.             {
  1344.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad2RelationshipGroup, Squad1RelationshipGroup);
  1345.             }
  1346.         }
  1347.         if (checkbox == Squad2HateSquad3)
  1348.         {
  1349.             if (Checked)
  1350.             {
  1351.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad2RelationshipGroup, Squad3RelationshipGroup);
  1352.             }
  1353.             else
  1354.             {
  1355.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad2RelationshipGroup, Squad3RelationshipGroup);
  1356.             }
  1357.         }
  1358.         if (checkbox == Squad2HateSquad4)
  1359.         {
  1360.             if (Checked)
  1361.             {
  1362.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad2RelationshipGroup, Squad4RelationshipGroup);
  1363.             }
  1364.             else
  1365.             {
  1366.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad2RelationshipGroup, Squad4RelationshipGroup);
  1367.             }
  1368.         }
  1369.         if (checkbox == Squad3HateSquad1)
  1370.         {
  1371.             if (Checked)
  1372.             {
  1373.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad3RelationshipGroup, Squad1RelationshipGroup);
  1374.             }
  1375.             else
  1376.             {
  1377.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad3RelationshipGroup, Squad1RelationshipGroup);
  1378.             }
  1379.         }
  1380.         if (checkbox == Squad3HateSquad2)
  1381.         {
  1382.             if (Checked)
  1383.             {
  1384.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad3RelationshipGroup, Squad2RelationshipGroup);
  1385.             }
  1386.             else
  1387.             {
  1388.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad3RelationshipGroup, Squad2RelationshipGroup);
  1389.             }
  1390.         }
  1391.         if (checkbox == Squad3HateSquad4)
  1392.         {
  1393.             if (Checked)
  1394.             {
  1395.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad3RelationshipGroup, Squad4RelationshipGroup);
  1396.             }
  1397.             else
  1398.             {
  1399.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad3RelationshipGroup, Squad4RelationshipGroup);
  1400.             }
  1401.         }
  1402.         if (checkbox == Squad4HateSquad1)
  1403.         {
  1404.             if (Checked)
  1405.             {
  1406.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad4RelationshipGroup, Squad1RelationshipGroup);
  1407.             }
  1408.             else
  1409.             {
  1410.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad4RelationshipGroup, Squad1RelationshipGroup);
  1411.             }
  1412.         }
  1413.         if (checkbox == Squad4HateSquad2)
  1414.         {
  1415.             if (Checked)
  1416.             {
  1417.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad4RelationshipGroup, Squad2RelationshipGroup);
  1418.             }
  1419.             else
  1420.             {
  1421.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad4RelationshipGroup, Squad2RelationshipGroup);
  1422.             }
  1423.         }
  1424.         if (checkbox == Squad4HateSquad3)
  1425.         {
  1426.             if (Checked)
  1427.             {
  1428.                 World.SetRelationshipBetweenGroups(Relationship.Hate, Squad4RelationshipGroup, Squad3RelationshipGroup);
  1429.             }
  1430.             else
  1431.             {
  1432.                 World.SetRelationshipBetweenGroups(Relationship.Companion, Squad4RelationshipGroup, Squad3RelationshipGroup);
  1433.             }
  1434.         }
  1435.         if (checkbox == Squad2GodMode)
  1436.         {
  1437.             foreach (Ped ped in Squad2)
  1438.             {
  1439.                 ped.IsInvincible = Checked;
  1440.             }
  1441.             if (CanWeUse(GetLastVehicle(Squad2Leader)))
  1442.             {
  1443.                 GetLastVehicle(Squad2Leader).IsInvincible = Checked;
  1444.             }
  1445.         }
  1446.  
  1447.         if (checkbox == Squad3GodMode)
  1448.         {
  1449.             foreach (Ped ped in Squad3)
  1450.             {
  1451.                 ped.IsInvincible = Checked;
  1452.             }
  1453.             if (CanWeUse(GetLastVehicle(Squad3Leader)))
  1454.             {
  1455.                 GetLastVehicle(Squad3Leader).IsInvincible = Checked;
  1456.             }
  1457.         }
  1458.         if (checkbox == Squad4GodMode)
  1459.         {
  1460.             foreach (Ped ped in Squad4)
  1461.             {
  1462.                 ped.IsInvincible = Checked;
  1463.             }
  1464.             if (CanWeUse(GetLastVehicle(Squad4Leader)))
  1465.             {
  1466.                 GetLastVehicle(Squad4Leader).IsInvincible = Checked;
  1467.             }
  1468.         }
  1469.  
  1470.         if (checkbox == Squad1GodMode)
  1471.         {
  1472.             foreach (Ped ped in Squad1)
  1473.             {
  1474.                 ped.IsInvincible = Checked;
  1475.             }
  1476.  
  1477.         }
  1478.         if (checkbox == Squad1Followplayer)
  1479.         {
  1480.             if (CanWeUse(Squad1Leader))
  1481.             {
  1482.                 if (Squad1Followplayer.Checked)
  1483.                 {
  1484.                     UI.ShowSubtitle("~b~Squad 1~w~ will follow you from now on.");
  1485.                     foreach (Ped ped in Squad1)
  1486.                     {
  1487.                         Function.Call(Hash.REMOVE_PED_FROM_GROUP, ped.Handle);
  1488.                         Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, ped.Handle, Function.Call<int>(Hash.GET_PED_GROUP_INDEX, Game.Player.Character.Handle));
  1489.                     }
  1490.                 }
  1491.                 else
  1492.                 {
  1493.                     UI.ShowSubtitle("~b~Squad 1 ~w~won't follow you from now on.");
  1494.  
  1495.                     Squad1Group = Function.Call<int>(Hash.CREATE_GROUP);
  1496.  
  1497.                     foreach (Ped ped in Squad1)
  1498.                     {
  1499.                         Function.Call(Hash.REMOVE_PED_FROM_GROUP, ped.Handle);
  1500.                         if (ped == Squad1Leader)
  1501.                         {
  1502.                             Function.Call(Hash.SET_PED_AS_GROUP_LEADER, ped.Handle, Squad1Group);
  1503.                         }
  1504.                         else
  1505.                         {
  1506.                             Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, ped.Handle, Squad1Group);
  1507.                             Function.Call(Hash.SET_PED_NEVER_LEAVES_GROUP, ped, 1);
  1508.                         }
  1509.                     }
  1510.                 }
  1511.             }
  1512.             else
  1513.             {
  1514.                 UI.Notify("~b~Squad 1 ~w~does not exist.");
  1515.             }
  1516.         }
  1517.  
  1518.  
  1519.         if (checkbox == Squad2Followplayer)
  1520.         {
  1521.             if (CanWeUse(Squad2Leader))
  1522.             {
  1523.                 UI.ShowSubtitle("~y~Squad 2 ~w~will follow you from now on.");
  1524.  
  1525.                 if (Squad2Followplayer.Checked)
  1526.                 {
  1527.                     foreach (Ped ped in Squad2)
  1528.                     {
  1529.                         Function.Call(Hash.REMOVE_PED_FROM_GROUP, ped.Handle);
  1530.                         Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, ped.Handle, Function.Call<int>(Hash.GET_PED_GROUP_INDEX, Game.Player.Character.Handle));
  1531.                     }
  1532.                 }
  1533.                 else
  1534.                 {
  1535.                     UI.ShowSubtitle("~y~Squad 2~w~ won't follow you from now on.");
  1536.  
  1537.                     Squad2Group = Function.Call<int>(Hash.CREATE_GROUP);
  1538.  
  1539.                     foreach (Ped ped in Squad2)
  1540.                     {
  1541.                         Function.Call(Hash.REMOVE_PED_FROM_GROUP, ped.Handle);
  1542.                         if (ped == Squad2Leader)
  1543.                         {
  1544.                             Function.Call(Hash.SET_PED_AS_GROUP_LEADER, ped.Handle, Squad2Group);
  1545.                         }
  1546.                         else
  1547.                         {
  1548.                             Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, ped.Handle, Squad2Group);
  1549.                             Function.Call(Hash.SET_PED_NEVER_LEAVES_GROUP, ped, 1);
  1550.                         }
  1551.                     }
  1552.                 }
  1553.             }
  1554.             else
  1555.             {
  1556.                 UI.Notify("~y~Squad 2~w~ does not exist.");
  1557.             }
  1558.         }
  1559.  
  1560.         if (checkbox == Squad3Followplayer)
  1561.         {
  1562.             if (CanWeUse(Squad3Leader))
  1563.             {
  1564.                 if (Squad3Followplayer.Checked)
  1565.                 {
  1566.                     UI.ShowSubtitle("~b~Squad 3~w~ will follow you from now on.");
  1567.                     foreach (Ped ped in Squad3)
  1568.                     {
  1569.                         Function.Call(Hash.REMOVE_PED_FROM_GROUP, ped.Handle);
  1570.                         Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, ped.Handle, Function.Call<int>(Hash.GET_PED_GROUP_INDEX, Game.Player.Character.Handle));
  1571.                     }
  1572.                 }
  1573.                 else
  1574.                 {
  1575.                     UI.ShowSubtitle("~b~Squad 3 ~w~won't follow you from now on.");
  1576.  
  1577.                     Squad3Group = Function.Call<int>(Hash.CREATE_GROUP);
  1578.  
  1579.                     foreach (Ped ped in Squad3)
  1580.                     {
  1581.                         Function.Call(Hash.REMOVE_PED_FROM_GROUP, ped.Handle);
  1582.                         if (ped == Squad3Leader)
  1583.                         {
  1584.                             Function.Call(Hash.SET_PED_AS_GROUP_LEADER, ped.Handle, Squad3Group);
  1585.                         }
  1586.                         else
  1587.                         {
  1588.                             Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, ped.Handle, Squad3Group);
  1589.                             Function.Call(Hash.SET_PED_NEVER_LEAVES_GROUP, ped, 1);
  1590.                         }
  1591.                     }
  1592.                 }
  1593.             }
  1594.             else
  1595.             {
  1596.                 UI.Notify("~b~Squad 3 ~w~does not exist.");
  1597.             }
  1598.         }
  1599.  
  1600.         if (checkbox == Squad4Followplayer)
  1601.         {
  1602.             if (CanWeUse(Squad4Leader))
  1603.             {
  1604.                 if (Squad4Followplayer.Checked)
  1605.                 {
  1606.                     UI.ShowSubtitle("~b~Squad 3~w~ will follow you from now on.");
  1607.                     foreach (Ped ped in Squad4)
  1608.                     {
  1609.                         Function.Call(Hash.REMOVE_PED_FROM_GROUP, ped.Handle);
  1610.                         Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, ped.Handle, Function.Call<int>(Hash.GET_PED_GROUP_INDEX, Game.Player.Character.Handle));
  1611.                     }
  1612.                 }
  1613.                 else
  1614.                 {
  1615.                     UI.ShowSubtitle("~b~Squad 3 ~w~won't follow you from now on.");
  1616.  
  1617.                     Squad4Group = Function.Call<int>(Hash.CREATE_GROUP);
  1618.  
  1619.                     foreach (Ped ped in Squad4)
  1620.                     {
  1621.                         Function.Call(Hash.REMOVE_PED_FROM_GROUP, ped.Handle);
  1622.                         if (ped == Squad4Leader)
  1623.                         {
  1624.                             Function.Call(Hash.SET_PED_AS_GROUP_LEADER, ped.Handle, Squad4Group);
  1625.                         }
  1626.                         else
  1627.                         {
  1628.                             Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, ped.Handle, Squad4Group);
  1629.                             Function.Call(Hash.SET_PED_NEVER_LEAVES_GROUP, ped, 1);
  1630.                         }
  1631.                     }
  1632.                 }
  1633.             }
  1634.             else
  1635.             {
  1636.                 UI.Notify("~b~Squad 3 ~w~does not exist.");
  1637.             }
  1638.         }
  1639.  
  1640.  
  1641.     }
  1642.  
  1643.     public void OnListChange(UIMenu sender, UIMenuListItem list, int index)
  1644.     {
  1645.         if (list == Squad1NumberItem)
  1646.         {
  1647.             Squad1Number = list.IndexToItem(index);
  1648.         }
  1649.         if (list == Squad1VehicleSelection)
  1650.         {
  1651.             Squad1Vehicle = SquadTransportHashes[index];
  1652.         }
  1653.         if (list == Squad2NumberItem)
  1654.         {
  1655.             Squad2Number = list.IndexToItem(index);
  1656.         }
  1657.         if (list == Squad2VehicleSelection)
  1658.         {
  1659.             Squad2Vehicle = SquadTransportHashes[index];
  1660.         }
  1661.  
  1662.  
  1663.         if (list == Squad3NumberItem)
  1664.         {
  1665.             Squad3Number = list.IndexToItem(index);
  1666.         }
  1667.         if (list == Squad3VehicleSelection)
  1668.         {
  1669.             Squad3Vehicle = SquadTransportHashes[index];
  1670.         }
  1671.         if (list == Squad4NumberItem)
  1672.         {
  1673.             Squad4Number = list.IndexToItem(index);
  1674.         }
  1675.         if (list == Squad4VehicleSelection)
  1676.         {
  1677.             Squad4Vehicle = SquadTransportHashes[index];
  1678.         }
  1679.  
  1680.         if (list == MainWeaponSquad1List)
  1681.         {
  1682.             MainWeaponSquad1 = MainWeaponHashes[index];
  1683.         }
  1684.         if (list == SecondaryWeaponSquad1List)
  1685.         {
  1686.             SecondaryWeaponSquad1 = SecondaryWeaponHashes[index];
  1687.         }
  1688.         if (list == MainWeaponSquad2List)
  1689.         {
  1690.             MainWeaponSquad2 = MainWeaponHashes[index];
  1691.         }
  1692.         if (list == SecondaryWeaponSquad2List)
  1693.         {
  1694.             SecondaryWeaponSquad2 = SecondaryWeaponHashes[index];
  1695.         }
  1696.  
  1697.         if (list == MainWeaponSquad3List)
  1698.         {
  1699.             MainWeaponSquad3 = MainWeaponHashes[index];
  1700.         }
  1701.         if (list == SecondaryWeaponSquad3List)
  1702.         {
  1703.             SecondaryWeaponSquad3 = SecondaryWeaponHashes[index];
  1704.         }
  1705.         if (list == MainWeaponSquad4List)
  1706.         {
  1707.             MainWeaponSquad4 = MainWeaponHashes[index];
  1708.         }
  1709.         if (list == SecondaryWeaponSquad4List)
  1710.         {
  1711.             SecondaryWeaponSquad4 = SecondaryWeaponHashes[index];
  1712.         }
  1713.         if (list == Squad1StyleItem)
  1714.         {
  1715.             Squad1StylePed = list.IndexToItem(index);
  1716.  
  1717.             if (Squad1StylePed == "Army")
  1718.             {
  1719.                 Squad1Models = ArmyModels;
  1720.  
  1721.             }
  1722.             if (Squad1StylePed == "Police")
  1723.             {
  1724.                 Squad1Models = PoliceModels;
  1725.  
  1726.             }
  1727.             if (Squad1StylePed == "Rednecks")
  1728.             {
  1729.                 Squad1Models = RedneckModels;
  1730.  
  1731.             }
  1732.  
  1733.             if (Squad1StylePed == "Private Security")
  1734.             {
  1735.                 Squad1Models = PrivateSecurityModels;
  1736.  
  1737.             }
  1738.            
  1739.             if (Squad1StylePed == "Ballas")
  1740.             {
  1741.                 Squad1Models = BallasModels;
  1742.             }
  1743.             if (Squad1StylePed == "Families")
  1744.             {
  1745.                 Squad1Models = FamiliesModels;
  1746.             }
  1747.             if (Squad1StylePed == "SWAT")
  1748.             {
  1749.                 Squad1Models = SWATModels;
  1750.             }
  1751.             if (Squad1StylePed == "The Lost")
  1752.             {
  1753.                 Squad1Models = LostModels;
  1754.             }
  1755.             if (Squad1StylePed == CustomStyle1Name + "")
  1756.             {
  1757.                 Squad1Models = CustomModels1;
  1758.             }
  1759.             if (Squad1StylePed == CustomStyle2Name + "")
  1760.             {
  1761.                 Squad1Models = CustomModels2;
  1762.             }
  1763.         }
  1764.         if (list == Squad2StyleItem)
  1765.         {
  1766.             Squad2StylePed = list.IndexToItem(index);
  1767.  
  1768.             if (Squad2StylePed == "Army")
  1769.             {
  1770.                 Squad2Models = ArmyModels;
  1771.  
  1772.             }
  1773.             if (Squad2StylePed == "Police")
  1774.             {
  1775.                 Squad2Models = PoliceModels;
  1776.  
  1777.             }
  1778.             if (Squad2StylePed == "Rednecks")
  1779.             {
  1780.                 Squad2Models = RedneckModels;
  1781.  
  1782.             }
  1783.  
  1784.             if (Squad2StylePed == "Private Security")
  1785.             {
  1786.                 Squad2Models = PrivateSecurityModels;
  1787.             }
  1788.  
  1789.             if (Squad2StylePed == "Families")
  1790.             {
  1791.                 Squad2Models = FamiliesModels;
  1792.             }
  1793.             if (Squad2StylePed == "SWAT")
  1794.             {
  1795.                 Squad2Models = SWATModels;
  1796.             }
  1797.             if (Squad2StylePed == "The Lost")
  1798.             {
  1799.                 Squad2Models = LostModels;
  1800.             }
  1801.             if (Squad2StylePed == CustomStyle1Name+"")
  1802.             {
  1803.                 Squad2Models = CustomModels1;
  1804.             }
  1805.             if (Squad2StylePed == CustomStyle2Name + "")
  1806.             {
  1807.                 Squad2Models = CustomModels2;
  1808.             }
  1809.         }
  1810.  
  1811.         if (list == Squad3StyleItem)
  1812.         {
  1813.             Squad3StylePed = list.IndexToItem(index);
  1814.  
  1815.             if (Squad3StylePed == "Army")
  1816.             {
  1817.                 Squad3Models = ArmyModels;
  1818.             }
  1819.             if (Squad3StylePed == "Police")
  1820.             {
  1821.                 Squad3Models = PoliceModels;
  1822.             }
  1823.             if (Squad3StylePed == "Rednecks")
  1824.             {
  1825.                 Squad3Models = RedneckModels;
  1826.             }
  1827.             if (Squad3StylePed == "Private Security")
  1828.             {
  1829.                 Squad3Models = PrivateSecurityModels;
  1830.             }
  1831.             if (Squad3StylePed == "Ballas")
  1832.             {
  1833.                 Squad3Models = BallasModels;
  1834.             }
  1835.             if (Squad3StylePed == "Families")
  1836.             {
  1837.                 Squad3Models = FamiliesModels;
  1838.             }
  1839.             if (Squad3StylePed == "SWAT")
  1840.             {
  1841.                 Squad3Models = SWATModels;
  1842.             }
  1843.             if (Squad3StylePed == "The Lost")
  1844.             {
  1845.                 Squad3Models = LostModels;
  1846.             }
  1847.             if (Squad3StylePed == CustomStyle1Name + "")
  1848.             {
  1849.                 Squad3Models = CustomModels1;
  1850.             }
  1851.             if (Squad3StylePed == CustomStyle2Name + "")
  1852.             {
  1853.                 Squad3Models = CustomModels2;
  1854.             }
  1855.         }
  1856.         if (list == Squad4StyleItem)
  1857.         {
  1858.             Squad4StylePed = list.IndexToItem(index);
  1859.  
  1860.             if (Squad4StylePed == "Army")
  1861.             {
  1862.                 Squad4Models = ArmyModels;
  1863.             }
  1864.             if (Squad4StylePed == "Police")
  1865.             {
  1866.                 Squad4Models = PoliceModels;
  1867.             }
  1868.             if (Squad4StylePed == "Rednecks")
  1869.             {
  1870.                 Squad4Models = RedneckModels;
  1871.             }
  1872.             if (Squad4StylePed == "Private Security")
  1873.             {
  1874.                 Squad4Models = PrivateSecurityModels;
  1875.             }
  1876.             if (Squad4StylePed == "Ballas")
  1877.             {
  1878.                 Squad4Models = BallasModels;
  1879.             }
  1880.             if (Squad4StylePed == "Families")
  1881.             {
  1882.                 Squad4Models = FamiliesModels;
  1883.             }
  1884.             if (Squad4StylePed == "SWAT")
  1885.             {
  1886.                 Squad4Models = SWATModels;
  1887.             }
  1888.             if (Squad4StylePed == "The Lost")
  1889.             {
  1890.                 Squad4Models = LostModels;
  1891.             }
  1892.             if (Squad4StylePed == CustomStyle1Name + "")
  1893.             {
  1894.                 Squad4Models = CustomModels1;
  1895.             }
  1896.             if (Squad4StylePed == CustomStyle2Name + "")
  1897.             {
  1898.                 Squad4Models = CustomModels2;
  1899.             }
  1900.         }
  1901.         if (list == DrivingStyleSquad1)
  1902.         {
  1903.  
  1904.             if (DrivingCareful.Contains(Squad1Leader)) { DrivingCareful.RemoveAt(DrivingCareful.IndexOf(Squad1Leader)); }
  1905.             if (DrivingNormal.Contains(Squad1Leader)) { DrivingNormal.RemoveAt(DrivingNormal.IndexOf(Squad1Leader)); }
  1906.             if (DrivingFurious.Contains(Squad1Leader)) { DrivingFurious.RemoveAt(DrivingFurious.IndexOf(Squad1Leader)); }
  1907.  
  1908.             string Style = list.IndexToItem(index).ToString();
  1909.             if (Style == "Careful" && CanWeUse(Squad1Leader))
  1910.             {
  1911.                 DrivingCareful.Add(Squad1Leader);
  1912.                 SetDrivingStyleAndCruiseSpeed(Squad1Leader,1|2|4|16|32,20f);
  1913.             }
  1914.             if (Style == "Normal" && CanWeUse(Squad1Leader))
  1915.             {
  1916.                 DrivingNormal.Add(Squad1Leader);
  1917.                 SetDrivingStyleAndCruiseSpeed(Squad1Leader, 1 | 2 | 4 | 16 | 32, 30f);
  1918.  
  1919.             }
  1920.             if (Style == "Fast & Furious" && CanWeUse(Squad1Leader))
  1921.             {
  1922.                 DrivingFurious.Add(Squad1Leader);
  1923.                 SetDrivingStyleAndCruiseSpeed(Squad1Leader, 4 | 16 | 32, 70f);
  1924.  
  1925.             }
  1926.         }
  1927.         if (list == DrivingStyleSquad2)
  1928.         {
  1929.             if (DrivingCareful.Contains(Squad2Leader)) { DrivingCareful.RemoveAt(DrivingCareful.IndexOf(Squad2Leader)); }
  1930.             if (DrivingNormal.Contains(Squad2Leader)) { DrivingNormal.RemoveAt(DrivingNormal.IndexOf(Squad2Leader)); }
  1931.             if (DrivingFurious.Contains(Squad2Leader)) { DrivingFurious.RemoveAt(DrivingFurious.IndexOf(Squad2Leader)); }
  1932.  
  1933.             string Style = list.IndexToItem(index).ToString();
  1934.             if (Style == "Careful" && CanWeUse(Squad2Leader))
  1935.             {
  1936.                 DrivingCareful.Add(Squad2Leader);
  1937.                 SetDrivingStyleAndCruiseSpeed(Squad2Leader, 1 | 2 | 4 | 16 | 32, 20f);
  1938.  
  1939.             }
  1940.             if (Style == "Normal" && CanWeUse(Squad2Leader))
  1941.             {
  1942.                 DrivingNormal.Add(Squad2Leader);
  1943.                 SetDrivingStyleAndCruiseSpeed(Squad2Leader, 1 | 2 | 4 | 16 | 32, 30f);
  1944.  
  1945.             }
  1946.             if (Style == "Fast & Furious" && CanWeUse(Squad2Leader))
  1947.             {
  1948.                 DrivingFurious.Add(Squad2Leader);
  1949.                 SetDrivingStyleAndCruiseSpeed(Squad2Leader,  4 | 16 | 32, 70f);
  1950.  
  1951.             }
  1952.         }
  1953.         if (list == DrivingStyleSquad3)
  1954.         {
  1955.             if (DrivingCareful.Contains(Squad3Leader)) { DrivingCareful.RemoveAt(DrivingCareful.IndexOf(Squad3Leader)); }
  1956.             if (DrivingNormal.Contains(Squad3Leader)) { DrivingNormal.RemoveAt(DrivingNormal.IndexOf(Squad3Leader)); }
  1957.             if (DrivingFurious.Contains(Squad3Leader)) { DrivingFurious.RemoveAt(DrivingFurious.IndexOf(Squad3Leader)); }
  1958.  
  1959.             string Style = list.IndexToItem(index).ToString();
  1960.             if (Style == "Careful" && CanWeUse(Squad3Leader))
  1961.             {
  1962.                 DrivingCareful.Add(Squad3Leader);
  1963.                 SetDrivingStyleAndCruiseSpeed(Squad3Leader, 1 | 2 | 4 | 16 | 32, 20f);
  1964.  
  1965.             }
  1966.             if (Style == "Normal" && CanWeUse(Squad3Leader))
  1967.             {
  1968.                 DrivingNormal.Add(Squad3Leader);
  1969.                 SetDrivingStyleAndCruiseSpeed(Squad3Leader, 1 | 2 | 4 | 16 | 32, 30f);
  1970.  
  1971.             }
  1972.             if (Style == "Fast & Furious" && CanWeUse(Squad3Leader))
  1973.             {
  1974.                 DrivingFurious.Add(Squad3Leader);
  1975.                 SetDrivingStyleAndCruiseSpeed(Squad3Leader, 4 | 16 | 32, 70f);
  1976.             }
  1977.         }
  1978.  
  1979.         if (list == DrivingStyleSquad4)
  1980.         {
  1981.             if (DrivingCareful.Contains(Squad4Leader)) { DrivingCareful.RemoveAt(DrivingCareful.IndexOf(Squad4Leader)); }
  1982.             if (DrivingNormal.Contains(Squad4Leader)) { DrivingNormal.RemoveAt(DrivingNormal.IndexOf(Squad4Leader)); }
  1983.             if (DrivingFurious.Contains(Squad4Leader)) { DrivingFurious.RemoveAt(DrivingFurious.IndexOf(Squad4Leader)); }
  1984.  
  1985.             string Style = list.IndexToItem(index).ToString();
  1986.             if (Style == "Careful" && CanWeUse(Squad4Leader))
  1987.             {
  1988.                 DrivingCareful.Add(Squad4Leader);
  1989.                 SetDrivingStyleAndCruiseSpeed(Squad4Leader, 1 | 2 | 4 | 16 | 32, 20f);
  1990.  
  1991.             }
  1992.             if (Style == "Normal" && CanWeUse(Squad4Leader))
  1993.             {
  1994.                 DrivingNormal.Add(Squad4Leader);
  1995.                 SetDrivingStyleAndCruiseSpeed(Squad4Leader, 1 | 2 | 4 | 16 | 32, 30f);
  1996.  
  1997.             }
  1998.             if (Style == "Fast & Furious" && CanWeUse(Squad4Leader))
  1999.             {
  2000.                 DrivingFurious.Add(Squad4Leader);
  2001.                 SetDrivingStyleAndCruiseSpeed(Squad4Leader, 4 | 16 | 32, 70f);
  2002.             }
  2003.         }
  2004.     }
  2005.  
  2006.  
  2007.     void SwitchSirens(Ped RecieveOrder)
  2008.     {
  2009.  
  2010.         if (CanWeUse(RecieveOrder) && RecieveOrder.IsSittingInVehicle())
  2011.         {
  2012.             Model veh = RecieveOrder.CurrentVehicle.Model;
  2013.             if (VehiclesWithSiren.Contains(veh))
  2014.             {
  2015.                 RecieveOrder.CurrentVehicle.SirenActive = !RecieveOrder.CurrentVehicle.SirenActive;
  2016.             }
  2017.             else
  2018.             {
  2019.                 UI.ShowSubtitle("This vehicle doesn't have siren.");
  2020.             }
  2021.         }
  2022.     }
  2023.  
  2024.     void AttachVehicle(Ped SquadLeader)
  2025.     {
  2026.         if (CanWeUse(SquadLeader) && SquadLeader.IsSittingInVehicle())
  2027.         {
  2028.             var veh = SquadLeader.CurrentVehicle;
  2029.  
  2030.             if (veh.Model == new Model(VehicleHash.Cargobob))
  2031.             {
  2032.                 if (Function.Call<bool>(GTA.Native.Hash._0x1821D91AD4B56108, veh) == false) //_IS_CARGOBOB_HOOK_ACTIVE
  2033.                 {
  2034.                     Function.Call(GTA.Native.Hash._0x7BEB0C7A235F6F3B, veh);
  2035.                 }
  2036.                 else
  2037.                 {
  2038.                 }
  2039.  
  2040.                 if (CanWeUse(Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_ATTACHED_TO_CARGOBOB, veh)))
  2041.                 {
  2042.                     Vehicle vehicle = Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_ATTACHED_TO_CARGOBOB, veh);
  2043.                     if (!vehicle.IsStopped)
  2044.                     {
  2045.                         //vehicle.Position = veh.Position + veh.UpVector * -3;
  2046.                         Function.Call<Vehicle>(GTA.Native.Hash.DETACH_VEHICLE_FROM_ANY_CARGOBOB, vehicle);
  2047.                     }
  2048.                 }
  2049.                 else
  2050.                 {
  2051.                     var nearbyvehs = World.GetNearbyVehicles(veh.Position + new Vector3(0, 0, -5), 6);
  2052.                     foreach (Vehicle vehicle in nearbyvehs)
  2053.                     {
  2054.                         if (CanWeUse(vehicle) && vehicle != veh)
  2055.                         {
  2056.                             Function.Call(GTA.Native.Hash.ATTACH_VEHICLE_TO_CARGOBOB, veh, vehicle, 1, vehicle.Position.X, vehicle.Position.Y, vehicle.Position.Z);
  2057.                             break;
  2058.                         }
  2059.                     }
  2060.                 }
  2061.             }
  2062.             if (veh.Model == new Model(VehicleHash.Phantom) || veh.Model == new Model(VehicleHash.Packer) || veh.Model == new Model(VehicleHash.Hauler))
  2063.             {
  2064.                 var nearbyvehs = World.GetNearbyVehicles(veh.Position + veh.ForwardVector * -5, 10);
  2065.                 foreach (Vehicle vehicle in nearbyvehs)
  2066.                 {
  2067.                     if (CanWeUse(vehicle) && vehicle != veh)
  2068.                     {
  2069.                         if (Function.Call<bool>(GTA.Native.Hash.IS_VEHICLE_ATTACHED_TO_TRAILER, veh) == false)
  2070.                         {
  2071.                             Function.Call(GTA.Native.Hash.ATTACH_VEHICLE_TO_TRAILER, veh, vehicle, 10);
  2072.                             break;
  2073.                         }
  2074.                         else
  2075.                         {
  2076.                             Function.Call(GTA.Native.Hash.DETACH_VEHICLE_FROM_TRAILER, veh);
  2077.                             break;
  2078.                         }
  2079.                     }
  2080.                 }
  2081.             }
  2082.             if (veh.Model == new Model(VehicleHash.TowTruck) || veh.Model == new Model(VehicleHash.TowTruck2))
  2083.             {
  2084.                 var nearbyvehs = World.GetNearbyVehicles(veh.Position + veh.ForwardVector * -3, 10);
  2085.                 foreach (Vehicle vehicle in nearbyvehs)
  2086.                 {
  2087.                     if (CanWeUse(vehicle) && vehicle != veh)
  2088.                     {
  2089.                         //Squad1Leader.CurrentVehicle.SoundHorn(500);
  2090.                         if (Function.Call<bool>(GTA.Native.Hash.IS_VEHICLE_ATTACHED_TO_TOW_TRUCK, veh, vehicle) == false)
  2091.                         {
  2092.                             Function.Call(GTA.Native.Hash.ATTACH_VEHICLE_TO_TOW_TRUCK, veh, vehicle, 10, veh.Position.X, veh.Position.Y, veh.Position.Z);
  2093.                             Function.Call(GTA.Native.Hash._SET_TOW_TRUCK_CRANE_RAISED, 0.0);
  2094.                             break;
  2095.                         }
  2096.                         else
  2097.                         {
  2098.                             Function.Call(GTA.Native.Hash.DETACH_VEHICLE_FROM_TOW_TRUCK, veh, vehicle);
  2099.                             break;
  2100.                         }
  2101.                     }
  2102.                 }
  2103.             }
  2104.         }
  2105.     }
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.     public void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)
  2112.     {
  2113.  
  2114.         if (selectedItem == AttachVehiclesSquad1)
  2115.         {
  2116.             AttachVehicle(Squad1Leader);
  2117.         }
  2118.         if (selectedItem == AttachVehiclesSquad2)
  2119.         {
  2120.             AttachVehicle(Squad2Leader);
  2121.         }
  2122.         if (selectedItem == AttachVehiclesSquad3)
  2123.         {
  2124.             AttachVehicle(Squad3Leader);
  2125.         }
  2126.         if (selectedItem == AttachVehiclesSquad4)
  2127.         {
  2128.             AttachVehicle(Squad4Leader);
  2129.         }
  2130.         if (selectedItem == SwitchSirensSquad1)
  2131.         {
  2132.             SwitchSirens(Squad1Leader);
  2133.         }
  2134.         if (selectedItem == SwitchSirensSquad2)
  2135.         {
  2136.             SwitchSirens(Squad2Leader);
  2137.         }
  2138.         if (selectedItem == SwitchSirensSquad3)
  2139.         {
  2140.             SwitchSirens(Squad3Leader);
  2141.         }
  2142.         if (selectedItem == SwitchSirensSquad4)
  2143.         {
  2144.             SwitchSirens(Squad4Leader);
  2145.         }
  2146.         if (selectedItem == RappelSquad1)
  2147.         {
  2148.             RappelFunction(Squad1Leader);
  2149.         }
  2150.         if (selectedItem == RappelSquad2)
  2151.         {
  2152.             RappelFunction(Squad2Leader);
  2153.         }
  2154.         if (selectedItem == RappelSquad3)
  2155.         {
  2156.             RappelFunction(Squad3Leader);
  2157.         }
  2158.         if (selectedItem == RappelSquad4)
  2159.         {
  2160.             RappelFunction(Squad4Leader);
  2161.         }
  2162.         if (selectedItem == ParkNearbySquad1)
  2163.         {
  2164.             ParkNearby(Squad1Leader);
  2165.         }
  2166.         if (selectedItem == ParkNearbySquad2)
  2167.         {
  2168.             ParkNearby(Squad2Leader);
  2169.         }
  2170.         if (selectedItem == ParkNearbySquad3)
  2171.         {
  2172.             ParkNearby(Squad3Leader);
  2173.         }
  2174.         if (selectedItem == ParkNearbySquad4)
  2175.         {
  2176.             ParkNearby(Squad4Leader);
  2177.         }
  2178.         if (selectedItem == FollowmeOffroadSquad1)
  2179.         {
  2180.             FollowmeOffroad(Squad1Leader);
  2181.         }
  2182.         if (selectedItem == GuardThisAreaSquad1)
  2183.         {
  2184.             GuardArea(Squad1Leader);
  2185.         }
  2186.         if (selectedItem == GuardThisAreaSquad2)
  2187.         {
  2188.             GuardArea(Squad2Leader);
  2189.         }
  2190.         if (selectedItem == GuardThisAreaSquad3)
  2191.         {
  2192.             GuardArea(Squad3Leader);
  2193.         }
  2194.         if (selectedItem == GuardThisAreaSquad4)
  2195.         {
  2196.             GuardArea(Squad4Leader);
  2197.         }
  2198.         if (selectedItem == FollowmeOffroadSquad2)
  2199.         {
  2200.             FollowmeOffroad(Squad2Leader);
  2201.         }
  2202.         if (selectedItem == FollowmeOffroadSquad3)
  2203.         {
  2204.             FollowmeOffroad(Squad3Leader);
  2205.         }
  2206.         if (selectedItem == FollowmeOffroadSquad4)
  2207.         {
  2208.             FollowmeOffroad(Squad4Leader);
  2209.         }
  2210.         if (selectedItem == GetBackToMeSquad1)
  2211.         {
  2212.             UI.ShowSubtitle("Get back to me.");
  2213.             GoThereSmart(Squad1Leader, Game.Player.Character.Position);
  2214.         }
  2215.  
  2216.         if (selectedItem == GetBackToMeSquad2)
  2217.         {
  2218.             UI.ShowSubtitle("Get back to me.");
  2219.             GoThereSmart(Squad2Leader, Game.Player.Character.Position);
  2220.         }
  2221.         if (selectedItem == GetBackToMeSquad3)
  2222.         {
  2223.             UI.ShowSubtitle("Get back to me.");
  2224.             GoThereSmart(Squad3Leader, Game.Player.Character.Position);
  2225.         }
  2226.         if (selectedItem == GetBackToMeSquad4)
  2227.         {
  2228.             UI.ShowSubtitle("Get back to me.");
  2229.             GoThereSmart(Squad4Leader, Game.Player.Character.Position);
  2230.         }
  2231.  
  2232.         if (selectedItem == DeleteSquad1)
  2233.         {
  2234.             RemoveSquad1();
  2235.         }
  2236.  
  2237.         if (selectedItem == DeleteSquad2)
  2238.         {
  2239.             RemoveSquad2();
  2240.         }
  2241.         if (selectedItem == DeleteSquad3)
  2242.         {
  2243.             RemoveSquad3();
  2244.         }
  2245.         if (selectedItem == DeleteSquad4)
  2246.         {
  2247.             RemoveSquad4();
  2248.         }
  2249.         if (selectedItem == EscortMeSquad1)
  2250.         {
  2251.             NonSituationalEscortMe(Squad1Leader);
  2252.         }
  2253.  
  2254.         if (selectedItem == EscortMeSquad2)
  2255.         {
  2256.             NonSituationalEscortMe(Squad2Leader);
  2257.         }
  2258.         if (selectedItem == EscortMeSquad3)
  2259.         {
  2260.             NonSituationalEscortMe(Squad3Leader);
  2261.         }
  2262.         if (selectedItem == EscortMeSquad4)
  2263.         {
  2264.             NonSituationalEscortMe(Squad4Leader);
  2265.         }
  2266.         if (selectedItem == GoToWaypointSquad1)
  2267.         {
  2268.             NonSituationalGoToWaypoint(Squad1Leader);
  2269.         }
  2270.         if (selectedItem == GoToWaypointSquad2)
  2271.         {
  2272.             NonSituationalGoToWaypoint(Squad2Leader);
  2273.         }
  2274.         if (selectedItem == GoToWaypointSquad3)
  2275.         {
  2276.             NonSituationalGoToWaypoint(Squad3Leader);
  2277.         }
  2278.         if (selectedItem == GoToWaypointSquad4)
  2279.         {
  2280.             NonSituationalGoToWaypoint(Squad4Leader);
  2281.         }
  2282.         if (selectedItem == EnterLeaveVehicleSquad1)
  2283.         {
  2284.             NonSituationalEnterLeaveVehicle(Squad1Leader);
  2285.         }
  2286.         if (selectedItem == EnterLeaveVehicleSquad2)
  2287.         {
  2288.             NonSituationalEnterLeaveVehicle(Squad2Leader);
  2289.         }
  2290.         if (selectedItem == EnterLeaveVehicleSquad3)
  2291.         {
  2292.             NonSituationalEnterLeaveVehicle(Squad3Leader);
  2293.         }
  2294.  
  2295.         if (selectedItem == EnterLeaveVehicleSquad4)
  2296.         {
  2297.             NonSituationalEnterLeaveVehicle(Squad4Leader);
  2298.         }
  2299.         if (selectedItem == CallSquad1 && Squad1.Count == 0)
  2300.         {
  2301.             var pasengerz = Function.Call<int>(GTA.Native.Hash._GET_VEHICLE_MODEL_MAX_NUMBER_OF_PASSENGERS, new Model(Squad1Vehicle));
  2302.             if (pasengerz < Squad1Number) { Squad1Number = pasengerz; }
  2303.             CreateSquad1();
  2304.         }
  2305.         if (selectedItem == CallSquad2 && Squad2.Count == 0)
  2306.         {
  2307.             var pasengerz = Function.Call<int>(GTA.Native.Hash._GET_VEHICLE_MODEL_MAX_NUMBER_OF_PASSENGERS, (Model)Squad2Vehicle);
  2308.             if (pasengerz < Squad2Number) { Squad2Number = pasengerz; }
  2309.             CreateSquad2();
  2310.         }
  2311.         if (selectedItem == CallSquad3 && Squad3.Count == 0)
  2312.         {
  2313.             var pasengerz = Function.Call<int>(GTA.Native.Hash._GET_VEHICLE_MODEL_MAX_NUMBER_OF_PASSENGERS, (Model)Squad3Vehicle);
  2314.             if (pasengerz < Squad3Number) { Squad3Number = pasengerz; }
  2315.             CreateSquad3();
  2316.         }
  2317.         if (selectedItem == CallSquad4 && Squad4.Count == 0)
  2318.         {
  2319.             var pasengerz = Function.Call<int>(GTA.Native.Hash._GET_VEHICLE_MODEL_MAX_NUMBER_OF_PASSENGERS, (Model)Squad4Vehicle);
  2320.             if (pasengerz < Squad4Number) { Squad4Number = pasengerz; }
  2321.             CreateSquad4();
  2322.         }
  2323.         if (selectedItem == Squad1Hate)
  2324.         {
  2325.             string pregunta = Game.GetUserInput(20);
  2326.             if (pregunta != null && pregunta != "")
  2327.             {
  2328.                 if (World.GetRelationshipBetweenGroups(Squad1RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta)) != Relationship.Hate)
  2329.                 {
  2330.                     World.SetRelationshipBetweenGroups(Relationship.Hate, Squad1RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2331.                     UI.Notify("Squad 1 now hates " + pregunta + " faction.");
  2332.                 }
  2333.                 else
  2334.                 {
  2335.                     World.SetRelationshipBetweenGroups(Relationship.Neutral, Squad1RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2336.                     UI.Notify("Squad 1 stopped hating " + pregunta + " faction.");
  2337.                 }
  2338.             }
  2339.         }
  2340.         if (selectedItem == Squad1Like)
  2341.         {
  2342.             string pregunta = Game.GetUserInput(20);
  2343.             if (pregunta != null && pregunta != "")
  2344.             {
  2345.                 if (World.GetRelationshipBetweenGroups(Squad1RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta)) != Relationship.Companion)
  2346.                 {
  2347.                     World.SetRelationshipBetweenGroups(Relationship.Companion, Squad1RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2348.                     UI.Notify("Squad 1 now likes " + pregunta + " faction.");
  2349.                 }
  2350.                 else
  2351.                 {
  2352.                     World.SetRelationshipBetweenGroups(Relationship.Neutral, Squad1RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2353.                     UI.Notify("Squad 1 stopped liking " + pregunta + " faction.");
  2354.                 }
  2355.             }
  2356.         }
  2357.  
  2358.  
  2359.         if (selectedItem == Squad2Hate)
  2360.         {
  2361.             string pregunta = Game.GetUserInput(20);
  2362.             if (pregunta != null || pregunta != "")
  2363.             {
  2364.                 if (World.GetRelationshipBetweenGroups(Squad2RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta)) != Relationship.Hate)
  2365.                 {
  2366.                     World.SetRelationshipBetweenGroups(Relationship.Hate, Squad2RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2367.                     UI.Notify("Squad 2 now hates " + pregunta + " faction.");
  2368.                 }
  2369.                 else
  2370.                 {
  2371.                     World.SetRelationshipBetweenGroups(Relationship.Neutral, Squad2RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2372.                     UI.Notify("Squad 2 stopped hating " + pregunta + " faction.");
  2373.                 }
  2374.             }
  2375.         }
  2376.         if (selectedItem == Squad2Like)
  2377.         {
  2378.             string pregunta = Game.GetUserInput(20);
  2379.             if (pregunta != null || pregunta != "")
  2380.             {
  2381.                 if (World.GetRelationshipBetweenGroups(Squad2RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta)) != Relationship.Companion)
  2382.                 {
  2383.                     World.SetRelationshipBetweenGroups(Relationship.Companion, Squad2RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2384.                     UI.Notify("Squad 2 now likes " + pregunta + " faction.");
  2385.                 }
  2386.                 else
  2387.                 {
  2388.                     World.SetRelationshipBetweenGroups(Relationship.Neutral, Squad2RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2389.                     UI.Notify("Squad 2 stopped liking " + pregunta + " faction.");
  2390.                 }
  2391.             }
  2392.         }
  2393.         if (selectedItem == Squad3Hate)
  2394.         {
  2395.             string pregunta = Game.GetUserInput(20);
  2396.             if (pregunta != null && pregunta != "")
  2397.             {
  2398.                 if (World.GetRelationshipBetweenGroups(Squad3RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta)) != Relationship.Hate)
  2399.                 {
  2400.                     World.SetRelationshipBetweenGroups(Relationship.Hate, Squad3RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2401.                     UI.Notify("Squad 1 now hates " + pregunta + " faction.");
  2402.                 }
  2403.                 else
  2404.                 {
  2405.                     World.SetRelationshipBetweenGroups(Relationship.Neutral, Squad3RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2406.                     UI.Notify("Squad 1 stopped hating " + pregunta + " faction.");
  2407.                 }
  2408.             }
  2409.         }
  2410.         if (selectedItem == Squad3Like)
  2411.         {
  2412.             string pregunta = Game.GetUserInput(20);
  2413.             if (pregunta != null && pregunta != "")
  2414.             {
  2415.                 if (World.GetRelationshipBetweenGroups(Squad3RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta)) != Relationship.Companion)
  2416.                 {
  2417.                     World.SetRelationshipBetweenGroups(Relationship.Companion, Squad3RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2418.                     UI.Notify("Squad 1 now likes " + pregunta + " faction.");
  2419.                 }
  2420.                 else
  2421.                 {
  2422.                     World.SetRelationshipBetweenGroups(Relationship.Neutral, Squad3RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2423.                     UI.Notify("Squad 1 stopped liking " + pregunta + " faction.");
  2424.                 }
  2425.             }
  2426.         }
  2427.  
  2428.  
  2429.  
  2430.         if (selectedItem == Squad4Hate)
  2431.         {
  2432.             string pregunta = Game.GetUserInput(20);
  2433.             if (pregunta != null && pregunta != "")
  2434.             {
  2435.                 if (World.GetRelationshipBetweenGroups(Squad4RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta)) != Relationship.Hate)
  2436.                 {
  2437.                     World.SetRelationshipBetweenGroups(Relationship.Hate, Squad4RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2438.                     UI.Notify("Squad 1 now hates " + pregunta + " faction.");
  2439.                 }
  2440.                 else
  2441.                 {
  2442.                     World.SetRelationshipBetweenGroups(Relationship.Neutral, Squad4RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2443.                     UI.Notify("Squad 1 stopped hating " + pregunta + " faction.");
  2444.                 }
  2445.             }
  2446.         }
  2447.         if (selectedItem == Squad4Like)
  2448.         {
  2449.             string pregunta = Game.GetUserInput(20);
  2450.             if (pregunta != null && pregunta != "")
  2451.             {
  2452.                 if (World.GetRelationshipBetweenGroups(Squad4RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta)) != Relationship.Companion)
  2453.                 {
  2454.                     World.SetRelationshipBetweenGroups(Relationship.Companion, Squad4RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2455.                     UI.Notify("Squad 1 now likes " + pregunta + " faction.");
  2456.                 }
  2457.                 else
  2458.                 {
  2459.                     World.SetRelationshipBetweenGroups(Relationship.Neutral, Squad4RelationshipGroup, Function.Call<int>(GTA.Native.Hash.GET_HASH_KEY, pregunta));
  2460.                     UI.Notify("Squad 1 stopped liking " + pregunta + " faction.");
  2461.                 }
  2462.             }
  2463.         }
  2464.  
  2465.         if (selectedItem == AllGoToWaypoint)
  2466.         {
  2467.             if (CanWeUse(Squad1Leader))
  2468.             {
  2469.                 NonSituationalGoToWaypoint(Squad1Leader);
  2470.             }
  2471.             if (CanWeUse(Squad2Leader))
  2472.             {
  2473.                 NonSituationalGoToWaypoint(Squad2Leader);
  2474.             }
  2475.             if (CanWeUse(Squad3Leader))
  2476.             {
  2477.                 NonSituationalGoToWaypoint(Squad3Leader);
  2478.             }
  2479.             if (CanWeUse(Squad4Leader))
  2480.             {
  2481.                 NonSituationalGoToWaypoint(Squad4Leader);
  2482.             }
  2483.         }
  2484.         if (selectedItem == AllGetBackToMe)
  2485.         {
  2486.             UI.ShowSubtitle("All, get back to me.");
  2487.  
  2488.             if (CanWeUse(Squad1Leader))
  2489.             {
  2490.                 GoThereSmart(Squad1Leader,Game.Player.Character.Position);
  2491.             }
  2492.             if (CanWeUse(Squad2Leader))
  2493.             {
  2494.                 GoThereSmart(Squad2Leader, Game.Player.Character.Position);
  2495.             }
  2496.             if (CanWeUse(Squad3Leader))
  2497.             {
  2498.                 GoThereSmart(Squad3Leader, Game.Player.Character.Position);
  2499.             }
  2500.             if (CanWeUse(Squad4Leader))
  2501.             {
  2502.                 GoThereSmart(Squad4Leader, Game.Player.Character.Position);
  2503.             }
  2504.         }
  2505.         if (selectedItem == AllCallSquad)
  2506.         {
  2507.             if (Squad1.Count == 0)
  2508.             {
  2509.                 var pasengerz = Function.Call<int>(GTA.Native.Hash._GET_VEHICLE_MODEL_MAX_NUMBER_OF_PASSENGERS, (Model)Squad1Vehicle);
  2510.                 if (pasengerz < Squad1Number) { Squad1Number = pasengerz; }
  2511.                 CreateSquad1();
  2512.             }
  2513.  
  2514.             if (Squad2.Count == 0)
  2515.             {
  2516.                 var pasengerz = Function.Call<int>(GTA.Native.Hash._GET_VEHICLE_MODEL_MAX_NUMBER_OF_PASSENGERS, (Model)Squad2Vehicle);
  2517.                 if (pasengerz < Squad2Number) { Squad2Number = pasengerz; }
  2518.                 CreateSquad2();
  2519.             }
  2520.             if (Squad3.Count == 0)
  2521.             {
  2522.                 var pasengerz = Function.Call<int>(GTA.Native.Hash._GET_VEHICLE_MODEL_MAX_NUMBER_OF_PASSENGERS, (Model)Squad3Vehicle);
  2523.                 if (pasengerz < Squad3Number) { Squad3Number = pasengerz; }
  2524.                 CreateSquad3();
  2525.             }
  2526.             if (Squad4.Count == 0)
  2527.             {
  2528.                 var pasengerz = Function.Call<int>(GTA.Native.Hash._GET_VEHICLE_MODEL_MAX_NUMBER_OF_PASSENGERS, (Model)Squad4Vehicle);
  2529.                 if (pasengerz < Squad4Number) { Squad4Number = pasengerz; }
  2530.                 CreateSquad4();
  2531.             }
  2532.         }
  2533.         if (selectedItem == AllDismissSquad)
  2534.         {
  2535.             RemoveSquad1();
  2536.             RemoveSquad2();
  2537.             RemoveSquad3();
  2538.             RemoveSquad4();
  2539.  
  2540.         }
  2541.         if (selectedItem == AllEnterLeave)
  2542.         {
  2543.             NonSituationalEnterLeaveVehicle(Squad1Leader);
  2544.             NonSituationalEnterLeaveVehicle(Squad2Leader);
  2545.             NonSituationalEnterLeaveVehicle(Squad3Leader);
  2546.             NonSituationalEnterLeaveVehicle(Squad4Leader);
  2547.  
  2548.         }
  2549.  
  2550.         if (selectedItem == AllParkAtMySide)
  2551.         {
  2552.             if (CanWeUse(Squad1Leader))
  2553.             {
  2554.                 Vector3 ParkingPos = Game.Player.Character.Position+ Game.Player.Character.RightVector*-3;
  2555.                 Function.Call(GTA.Native.Hash.TASK_VEHICLE_PARK, Squad1Leader, GetLastVehicle(Squad1Leader), ParkingPos.X, ParkingPos.Y, ParkingPos.Z, Game.Player.Character.Heading, 1, 30f, false);
  2556.             }
  2557.             if (CanWeUse(Squad2Leader))
  2558.             {
  2559.                 Vector3 ParkingPos = Game.Player.Character.Position + Game.Player.Character.RightVector * 3;
  2560.                 Function.Call(GTA.Native.Hash.TASK_VEHICLE_PARK, Squad2Leader, GetLastVehicle(Squad2Leader), ParkingPos.X, ParkingPos.Y, ParkingPos.Z, Game.Player.Character.Heading, 1, 30f, false);
  2561.             }
  2562.             if (CanWeUse(Squad3Leader))
  2563.             {
  2564.                 Vector3 ParkingPos = Game.Player.Character.Position + Game.Player.Character.RightVector * -6;
  2565.                 Function.Call(GTA.Native.Hash.TASK_VEHICLE_PARK, Squad3Leader, GetLastVehicle(Squad3Leader), ParkingPos.X, ParkingPos.Y, ParkingPos.Z, Game.Player.Character.Heading, 1, 30f, false);
  2566.             }
  2567.             if (CanWeUse(Squad4Leader))
  2568.             {
  2569.                 Vector3 ParkingPos = Game.Player.Character.Position + Game.Player.Character.RightVector * 6;
  2570.                 Function.Call(GTA.Native.Hash.TASK_VEHICLE_PARK, Squad4Leader, GetLastVehicle(Squad4Leader), ParkingPos.X, ParkingPos.Y, ParkingPos.Z, Game.Player.Character.Heading, 1, 30f, false);
  2571.             }
  2572.         }
  2573.  
  2574.  
  2575.         if (selectedItem == AllSquadsAddWaypoint)
  2576.         {
  2577.             if (RaceWaypoints.Count <8)
  2578.             {
  2579.                 if (Function.Call<bool>(Hash.IS_WAYPOINT_ACTIVE))
  2580.                 {
  2581.                     if (GetWaypointCoords() != Vector3.Zero)
  2582.                     {
  2583.                         if (RaceWaypoints.Contains(GetWaypointCoords()))
  2584.                         {
  2585.                             UI.Notify("This waypoint is already set.");
  2586.                         }
  2587.                         else
  2588.                         {
  2589.                             RaceWaypoints.Add(GetWaypointCoords());
  2590.                             Blip blop = World.CreateBlip(GetWaypointCoords());
  2591.                             blop.Color = BlipColor.White;
  2592.                             RaceWaypointBlips.Add(blop);
  2593.                             blop.ShowNumber(RaceWaypointBlips.Count);
  2594.                             UI.Notify("Waypoint added (" + World.GetStreetName(GetWaypointCoords()) + ")");                            
  2595.                         }
  2596.                     }
  2597.                     else
  2598.                     {
  2599.                         UI.Notify("Waypoint coords not valid.");
  2600.                     }
  2601.                 }
  2602.                 else
  2603.                 {
  2604.                     RaceWaypoints.Add(Game.Player.Character.Position);
  2605.                     UI.Notify(Game.Player.Character.Position.ToString());
  2606.                     Blip blop = World.CreateBlip(Game.Player.Character.Position);
  2607.                     blop.Color = BlipColor.White;
  2608.                     RaceWaypointBlips.Add(blop);
  2609.                     blop.ShowNumber(RaceWaypointBlips.Count);
  2610.                 }
  2611.             }
  2612.             else
  2613.             {
  2614.                 UI.Notify("You can't place more waypoints, sorry.\nEngine limits.");
  2615.             }
  2616.         }
  2617.  
  2618.         if (selectedItem == AllSquadsClearWaypoints)
  2619.         {
  2620.             UI.Notify("Waypoints cleared.");
  2621.             RaceWaypoints.Clear();
  2622.             foreach (Blip blop in RaceWaypointBlips)
  2623.             {
  2624.                 blop.Remove();
  2625.             }
  2626.             RaceWaypointBlips.Clear();
  2627.         }
  2628.  
  2629.         if (selectedItem == AllSquadsStartRace)
  2630.         {
  2631.             if (CanWeUse(Squad1Leader))
  2632.             {
  2633.                 TaskSequence RaceSequence = new TaskSequence();
  2634.                 foreach ( Vector3 pos in RaceWaypoints)
  2635.                 {
  2636.                     Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, 0, GetLastVehicle(Squad1Leader), pos.X, pos.Y, pos.Z, 70f, 4 | 16 | 32| 262144, 10f);
  2637.                     Function.Call(Hash.TASK_PAUSE, 0, 5);
  2638.                 }
  2639.                 RaceSequence.Close();
  2640.                 Squad1Leader.Task.PerformSequence(RaceSequence);
  2641.             }
  2642.             if (CanWeUse(Squad2Leader))
  2643.             {
  2644.                 TaskSequence RaceSequence = new TaskSequence();
  2645.                 foreach (Vector3 pos in RaceWaypoints)
  2646.                 {
  2647.                     Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, 0, GetLastVehicle(Squad2Leader), pos.X, pos.Y, pos.Z, 70f, 4 | 16 | 32| 262144, 10f);
  2648.                     Function.Call(Hash.TASK_PAUSE, 0, 5);
  2649.                 }
  2650.                 RaceSequence.Close();
  2651.                 Squad2Leader.Task.PerformSequence(RaceSequence);
  2652.             }
  2653.  
  2654.  
  2655.             if (CanWeUse(Squad3Leader))
  2656.             {
  2657.                 TaskSequence RaceSequence = new TaskSequence();
  2658.                 foreach (Vector3 pos in RaceWaypoints)
  2659.                 {
  2660.                     Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, 0, GetLastVehicle(Squad3Leader), pos.X, pos.Y, pos.Z, 70f, 4 | 16 | 32 | 262144, 10f);
  2661.                     Function.Call(Hash.TASK_PAUSE, 0, 5);
  2662.                 }
  2663.                 RaceSequence.Close();
  2664.                 Squad3Leader.Task.PerformSequence(RaceSequence);
  2665.             }
  2666.  
  2667.             if (CanWeUse(Squad4Leader))
  2668.             {
  2669.                 TaskSequence RaceSequence = new TaskSequence();
  2670.                 foreach (Vector3 pos in RaceWaypoints)
  2671.                 {
  2672.                     Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, 0, GetLastVehicle(Squad4Leader), pos.X, pos.Y, pos.Z, 70f, 4 | 16 | 32 | 262144, 10f);
  2673.                     Function.Call(Hash.TASK_PAUSE, 0, 5);
  2674.                 }
  2675.                 RaceSequence.Close();
  2676.                 Squad4Leader.Task.PerformSequence(RaceSequence);
  2677.             }
  2678.         }
  2679.     }
  2680.  
  2681.  
  2682.  
  2683.     void FollowmeOffroad(Ped RecieveOrder)
  2684.     {
  2685.         if (CanWeUse(RecieveOrder))
  2686.         {
  2687.             if (DrivingCareful.Contains(RecieveOrder))
  2688.             {
  2689.                 GTA.Native.Function.Call(GTA.Native.Hash.TASK_VEHICLE_ESCORT, RecieveOrder, RecieveOrder.CurrentVehicle, Game.Player.Character.CurrentVehicle, -1, 10.0, 1 | 4 | 16 | 32 | 4194304, 5f, 10f, 20f);
  2690.             }
  2691.             if (DrivingNormal.Contains(RecieveOrder))
  2692.             {
  2693.                 GTA.Native.Function.Call(GTA.Native.Hash.TASK_VEHICLE_ESCORT, RecieveOrder, RecieveOrder.CurrentVehicle, Game.Player.Character.CurrentVehicle, -1, 20.0, 1 | 4 | 16 | 32 | 4194304, 5f, 10f, 20f);
  2694.             }
  2695.             if (DrivingFurious.Contains(RecieveOrder))
  2696.             {
  2697.                 GTA.Native.Function.Call(GTA.Native.Hash.TASK_VEHICLE_ESCORT, RecieveOrder, RecieveOrder.CurrentVehicle, Game.Player.Character.CurrentVehicle, -1, 40.0, 1 | 4 | 16 | 32 | 4194304, 5f, 10f, 20f);
  2698.             }
  2699.             UI.ShowSubtitle("We goin' offroad m8", 1000);
  2700.         }
  2701.     }
  2702.  
  2703.     Vehicle GetLastVehicle(Ped RecieveOrder)
  2704.     {
  2705.         Vehicle vehicle = null;
  2706.         if (GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, true) != null)
  2707.         {
  2708.             vehicle = GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, true);
  2709.             if (vehicle.IsAlive)
  2710.             {
  2711.                 return vehicle;
  2712.             }
  2713.         }
  2714.         else
  2715.         {
  2716.             if (GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, false) != null)
  2717.             {
  2718.                 vehicle = GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, false);
  2719.                 if (vehicle.IsAlive)
  2720.                 {
  2721.                     return vehicle;
  2722.                 }
  2723.             }
  2724.         }
  2725.         return vehicle;
  2726.     }
  2727.  
  2728.     bool IsAnyVehicleThere(Vector3 pos, Entity ent)
  2729.     {
  2730.         foreach (Vehicle veh in World.GetNearbyVehicles(pos, 5f))
  2731.         {
  2732.             if (veh != ent)
  2733.             {
  2734.                 return true;
  2735.             }
  2736.         }
  2737.         return false;
  2738.     }
  2739.  
  2740.     void ParkNearby(Ped RecieveOrder)
  2741.     {
  2742.         if (CanWeUse(RecieveOrder) && CanWeUse(GetLastVehicle(RecieveOrder)))
  2743.         {
  2744.             bool ParkingatSides = false;
  2745.             bool CanPark = false;
  2746.             Vector3 ParkingPos = RecieveOrder.Position;
  2747.             Vector3 PreParkingPos = RecieveOrder.Position;
  2748.  
  2749.             float Heading = RecieveOrder.Heading;
  2750.  
  2751.             var nearbyvehs = World.GetNearbyVehicles(RecieveOrder.Position, 60);
  2752.             foreach (Vehicle nearbyvehicle in nearbyvehs)
  2753.             {
  2754.                 if (nearbyvehicle != GetLastVehicle(RecieveOrder) && !CanWeUse(nearbyvehicle.GetPedOnSeat(VehicleSeat.Driver)))
  2755.                 {
  2756.                     if (!IsAnyVehicleThere(nearbyvehicle.Position + (nearbyvehicle.ForwardVector * -6), nearbyvehicle))
  2757.                     {
  2758.                         if (Function.Call<bool>(GTA.Native.Hash.IS_BIG_VEHICLE, nearbyvehicle))
  2759.                         {
  2760.                             ParkingPos = nearbyvehicle.Position + (nearbyvehicle.ForwardVector * -10);
  2761.                         }
  2762.                         else
  2763.                         {
  2764.                             ParkingPos = nearbyvehicle.Position + (nearbyvehicle.ForwardVector * -6);
  2765.                         }
  2766.                         PreParkingPos = nearbyvehicle.Position + (nearbyvehicle.ForwardVector * -20);
  2767.                         UI.Notify("No obstacles behind vehicle");
  2768.                         Heading = nearbyvehicle.Heading;
  2769.                         CanPark = true;
  2770.                         break;
  2771.                     }
  2772.                     else if (!IsAnyVehicleThere(nearbyvehicle.Position + (nearbyvehicle.RightVector * -6), nearbyvehicle))
  2773.                     {
  2774.                         if (Function.Call<bool>(GTA.Native.Hash.IS_BIG_VEHICLE, nearbyvehicle))
  2775.                         {
  2776.                             ParkingPos = nearbyvehicle.Position + (nearbyvehicle.RightVector * -6);
  2777.                         }
  2778.                         else
  2779.                         {
  2780.                             ParkingPos = nearbyvehicle.Position + (nearbyvehicle.RightVector * -3);
  2781.                         }
  2782.                         PreParkingPos = nearbyvehicle.Position + (nearbyvehicle.RightVector * -3) + (nearbyvehicle.ForwardVector * -20);
  2783.  
  2784.                         UI.Notify("No obstacles at the left side");
  2785.                         Heading = nearbyvehicle.Heading;
  2786.                         CanPark = true;
  2787.                         ParkingatSides = true;
  2788.                         break;
  2789.                     }
  2790.                     else if (!IsAnyVehicleThere(nearbyvehicle.Position + (nearbyvehicle.RightVector * 6), nearbyvehicle))
  2791.                     {
  2792.                         if (Function.Call<bool>(GTA.Native.Hash.IS_BIG_VEHICLE, nearbyvehicle))
  2793.                         {
  2794.                             ParkingPos = nearbyvehicle.Position + (nearbyvehicle.RightVector * 6);
  2795.                         }
  2796.                         else
  2797.                         {
  2798.                             ParkingPos = nearbyvehicle.Position + (nearbyvehicle.RightVector * 3);
  2799.                         }
  2800.                         PreParkingPos = nearbyvehicle.Position + (nearbyvehicle.RightVector * 3) +(nearbyvehicle.ForwardVector * -20);
  2801.  
  2802.                         UI.Notify("No obstacles at the right side");
  2803.                         Heading = nearbyvehicle.Heading;
  2804.                         CanPark = true;
  2805.                         ParkingatSides = true;
  2806.                         break;
  2807.                     }
  2808.                 }
  2809.             }
  2810.             if (CanPark)
  2811.             {
  2812.                 if (ParkingatSides)
  2813.                 {
  2814.                     Function.Call(GTA.Native.Hash.TASK_VEHICLE_PARK, RecieveOrder, GetLastVehicle(RecieveOrder), ParkingPos.X, ParkingPos.Y, ParkingPos.Z, Heading, 1, 30f, false);
  2815.                 }
  2816.                 else
  2817.                 {
  2818.                     TaskSequence DriverSequence = new TaskSequence();
  2819.                     Function.Call(Hash.TASK_VEHICLE_GOTO_NAVMESH, 0, GetLastVehicle(RecieveOrder), PreParkingPos.X, PreParkingPos.Y, PreParkingPos.Z, 6f, 4194304 | 1 | 2 | 4 | 16 | 32, 3f);
  2820.                     Function.Call(Hash.TASK_PAUSE, 0, 1);
  2821.                     Function.Call(GTA.Native.Hash.TASK_VEHICLE_PARK, 0, GetLastVehicle(RecieveOrder), ParkingPos.X, ParkingPos.Y, ParkingPos.Z, Heading, 1, 30f, false);
  2822.                     DriverSequence.Close();
  2823.                     RecieveOrder.Task.PerformSequence(DriverSequence);
  2824.                 }
  2825.             }
  2826.             else
  2827.             {
  2828.                 UI.Notify("Didn't find suitable parking");
  2829.             }
  2830.         }        
  2831.     }
  2832.  
  2833.  
  2834.     void PreparePed(Ped ped, WeaponHash weapon, WeaponHash weapon2)
  2835.     {
  2836.         Function.Call(GTA.Native.Hash.SET_PED_COMBAT_MOVEMENT, ped, 2);
  2837.  
  2838.         Function.Call(GTA.Native.Hash.SET_DRIVER_ABILITY, ped,100f);
  2839.  
  2840.         ped.AlwaysDiesOnLowHealth = false;
  2841.         ped.Accuracy = 90;
  2842.         ped.Armor = 100;
  2843.         ped.AlwaysKeepTask = true;
  2844.         ped.CanSwitchWeapons = true;
  2845.         ped.Weapons.Give(weapon, 900, false, true);
  2846.         ped.Weapons.Give(weapon2, 900, false, true);
  2847.     }
  2848.  
  2849.     public Vector3 RotToDir(Vector3 Rot)
  2850.     {
  2851.  
  2852.         float z = Rot.Z;
  2853.         float retz = z * 0.0174532924F;//degree to radian
  2854.         float x = Rot.X;
  2855.         float retx = x * 0.0174532924F;
  2856.         float absx = (float)System.Math.Abs(System.Math.Cos(retx));
  2857.         return new Vector3((float)-System.Math.Sin(retz) * absx, (float)System.Math.Cos(retz) * absx, (float)System.Math.Sin(retx));
  2858.  
  2859.     }
  2860.  
  2861.     public RaycastResult Cam_Raycast_Forward()
  2862.     {
  2863.         Vector3 camrot = Function.Call<Vector3>(Hash.GET_GAMEPLAY_CAM_ROT, 0);
  2864.         Vector3 campos = Function.Call<Vector3>(Hash.GET_GAMEPLAY_CAM_COORD);
  2865.  
  2866.         Vector3 multiplied = new Vector3(RotToDir(camrot).X * 1000.0f, RotToDir(camrot).Y * 1000.0f, RotToDir(camrot).Z * 1000.0f);
  2867.         RaycastResult ray = World.Raycast(campos+Game.Player.Character.ForwardVector, campos + multiplied * 5000, IntersectOptions.Everything);
  2868.         return ray;
  2869.     }
  2870.  
  2871.     public RaycastResult RaycastDrive(Vector3 pos1, Vector3 pos2)
  2872.     {
  2873.         RaycastResult ray = World.Raycast(pos1, pos2 + new Vector3(0, 0, 1), IntersectOptions.Map);
  2874.         return ray;
  2875.     }
  2876.  
  2877.     void DriveTo(Ped RecieveOrder, Vector3 coord,float stopdistance)
  2878.     {
  2879.         if (RecieveOrder.IsSittingInVehicle())
  2880.         {
  2881.         if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_HELI, RecieveOrder.CurrentVehicle.Model))
  2882.         {
  2883.                 if (RecieveOrder.CurrentVehicle.Model == new Model(VehicleHash.Cargobob))
  2884.                 {
  2885.                     Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, coord.X, coord.Y, coord.Z + 30, 30.0, 0, RecieveOrder.CurrentVehicle.Model, 6, 60, 30.0);
  2886.                 }
  2887.                 else
  2888.                 {
  2889.                     Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, coord.X, coord.Y, coord.Z + 30, 60.0, 0, RecieveOrder.CurrentVehicle.Model, 6, 200, 20.0);
  2890.                 }
  2891.             }
  2892.             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_CAR, RecieveOrder.CurrentVehicle.Model) || GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_BIKE, RecieveOrder.CurrentVehicle.Model) || GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_QUADBIKE, RecieveOrder.CurrentVehicle.Model))
  2893.             {
  2894.                 if (DrivingCareful.Contains(RecieveOrder))
  2895.                 {
  2896.                     Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, coord.X, coord.Y, coord.Z, 20f, 1|2|32, stopdistance);
  2897.                 }
  2898.                 if (DrivingNormal.Contains(RecieveOrder))
  2899.                 {
  2900.                     Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, coord.X, coord.Y, coord.Z, 30f, 1|2|4|16|32, stopdistance);
  2901.                 }
  2902.                 if (DrivingFurious.Contains(RecieveOrder))
  2903.                 {
  2904.                     Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, coord.X, coord.Y, coord.Z, 70f, 4 | 16 | 32 | 262144 , stopdistance); //| 16384 | 8192 | 4096 | 2048 // | 65536 | 32768 < superpathing //  2097152| 1048576 | 524288 likes dirtroads   // | 131072
  2905.                 }
  2906.             }
  2907.         }
  2908.         else
  2909.         {
  2910.             UI.Notify("~r~ Bodyguards Squads Error:\nTried to make a ped drive, but the ped wasn't in a vehicle.");
  2911.         }
  2912.     }
  2913.  
  2914.     void GoThereSmart(Ped RecieveOrder, Vector3 coord)
  2915.     {
  2916.         if (CanWeUse(RecieveOrder) && RecieveOrder.IsAlive && coord != null)
  2917.         {
  2918.             if (RecieveOrder.IsSittingInVehicle())
  2919.             {
  2920.                 DriveTo(RecieveOrder, coord,20);
  2921.             }
  2922.             if (RecieveOrder.IsOnFoot)
  2923.             {
  2924.                 Vehicle lastveh = GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, true);
  2925.                 if (RecieveOrder.Position.DistanceTo(coord) > 200 && CanWeUse(lastveh) && lastveh.IsAlive)
  2926.                 {
  2927.                     if (Squad1.Contains(RecieveOrder))
  2928.                     {
  2929.                         GetSquadIntoVehicle(Squad1, lastveh);
  2930.                     }
  2931.                     if (Squad2.Contains(RecieveOrder))
  2932.                     {
  2933.                         GetSquadIntoVehicle(Squad2, lastveh);
  2934.                     }
  2935.                     Script.Wait(0);
  2936.                     DriveTo(RecieveOrder, coord,20);
  2937.                 }
  2938.                 else
  2939.                 {
  2940.                     RecieveOrder.Task.RunTo(coord, false);
  2941.                 }
  2942.             }
  2943.         }
  2944.     }
  2945.  
  2946.     private Vector3 ToGround(Vector3 position)
  2947.     {
  2948.         position.Z = World.GetGroundHeight(new Vector2(position.X, position.Y));
  2949.         return new Vector3(position.X, position.Y, position.Z);
  2950.     }
  2951.  
  2952.  
  2953.     Vector3 GetWaypointCoords()
  2954.     {
  2955.            Vector3 pos = Function.Call<Vector3>(Hash.GET_BLIP_COORDS, Function.Call<Blip>(Hash.GET_FIRST_BLIP_INFO_ID, 8));
  2956.  
  2957.         if (Function.Call<bool>(Hash.IS_WAYPOINT_ACTIVE) && pos != null || pos != new Vector3(0, 0, 0))
  2958.         {
  2959.             Vector3 WayPos = ToGround(pos);
  2960.             if (WayPos.Z == 0 || WayPos.Z == 1)
  2961.             {
  2962.                 WayPos = World.GetNextPositionOnStreet(WayPos);
  2963.                 return WayPos;
  2964.             }
  2965.         }
  2966.         return Vector3.Zero;
  2967.     }
  2968.  
  2969.     void NonSituationalGoToWaypoint(Ped RecieveOrder)
  2970.     {
  2971.         if (CanWeUse(RecieveOrder) && RecieveOrder.IsAlive)
  2972.         {
  2973.             Vector3 nonsituationalwaypointcoords = Function.Call<Vector3>(Hash.GET_BLIP_COORDS, Function.Call<Blip>(Hash.GET_FIRST_BLIP_INFO_ID, 8));
  2974.             if (Function.Call<bool>(Hash.IS_WAYPOINT_ACTIVE) && nonsituationalwaypointcoords != null || nonsituationalwaypointcoords != new Vector3(0,0,0))
  2975.             {
  2976.                 UI.ShowSubtitle("Go to the marked position.");
  2977.                 Vector3 WayPos = ToGround(nonsituationalwaypointcoords);
  2978.                 if (WayPos.Z == 0 || WayPos.Z == 1)
  2979.                 {
  2980.                     WayPos = World.GetNextPositionOnStreet(WayPos);
  2981.                     //UI.ShowSubtitle("Waypoint Z coord not valid, nearest valid place will be used (" + World.GetStreetName(WayPos).ToString() + ").");
  2982.                 }
  2983.  
  2984.                 if (CanWeUse(RecieveOrder) && RecieveOrder.IsAlive)
  2985.                 {
  2986.                     if (WayPos != new Vector3(0, 0, 0))
  2987.                     {
  2988.                         GoThereSmart(RecieveOrder, WayPos);
  2989.                     }
  2990.                     else
  2991.                     {
  2992.                         UI.ShowSubtitle("~r~Invalid Waypoint coords (" + WayPos.ToString() + ") \n~w~Place a new one.");
  2993.                     }
  2994.                 }
  2995.             }
  2996.             else
  2997.             {
  2998.                 UI.ShowSubtitle("There is no waypoint set.", 2000);
  2999.             }
  3000.         }
  3001.         else
  3002.         {
  3003.             UI.ShowSubtitle("There is no Squad Leader to give orders.", 2000);
  3004.         }
  3005.     }
  3006.  
  3007.  
  3008.     void DispatchToWaypoint(Ped RecieveOrder)
  3009.     {
  3010.         if (CanWeUse(RecieveOrder) && RecieveOrder.IsAlive)
  3011.         {
  3012.             Vector3 nonsituationalwaypointcoords = Function.Call<Vector3>(Hash.GET_BLIP_COORDS, Function.Call<Blip>(Hash.GET_FIRST_BLIP_INFO_ID, 8));
  3013.             if (Function.Call<bool>(Hash.IS_WAYPOINT_ACTIVE) && nonsituationalwaypointcoords != null || nonsituationalwaypointcoords != new Vector3(0, 0, 0))
  3014.             {
  3015.                 Vector3 WayPos = ToGround(nonsituationalwaypointcoords);
  3016.                 if (WayPos.Z == 0 || WayPos.Z == 1)
  3017.                 {
  3018.                     WayPos = World.GetNextPositionOnStreet(WayPos);
  3019.                     //UI.ShowSubtitle("Waypoint Z coord not valid, nearest valid place will be used (" + World.GetStreetName(WayPos).ToString() + ").");
  3020.                 }
  3021.  
  3022.                 if (CanWeUse(RecieveOrder) && RecieveOrder.IsAlive)
  3023.                 {
  3024.                     if (WayPos != Vector3.Zero)
  3025.                     {
  3026.                         GoThereSmart(RecieveOrder, WayPos);
  3027.                     }
  3028.                     else
  3029.                     {
  3030.                         GoThereSmart(RecieveOrder, Game.Player.Character.Position);
  3031.                         UI.ShowSubtitle("~r~Invalid Waypoint coords (" + WayPos.ToString() + "), the Squad will go to you.");
  3032.                     }
  3033.                 }
  3034.             }
  3035.             else
  3036.             {
  3037.                 GoThereSmart(RecieveOrder, Game.Player.Character.Position);
  3038.                 UI.ShowSubtitle("Waypoint not set, Squad will go to you.", 2000);
  3039.             }
  3040.         }
  3041.         else
  3042.         {
  3043.             UI.ShowSubtitle("There is no Squad Leader to give orders.", 2000);
  3044.         }
  3045.     }
  3046.  
  3047.  
  3048.     void NonSituationalEscortMe(Ped RecieveOrder)
  3049.     {
  3050.         if (CanWeUse(RecieveOrder) && RecieveOrder.IsAlive)
  3051.         {
  3052.             if (RecieveOrder.IsSittingInVehicle())
  3053.             {
  3054.                 if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_HELI, RecieveOrder.CurrentVehicle.Model))
  3055.                 {
  3056.                     UI.ShowSubtitle("Protect me (Heli)", 1000);
  3057.                     Function.Call(Hash.TASK_VEHICLE_HELI_PROTECT, RecieveOrder, RecieveOrder.CurrentVehicle,Game.Player.Character, 50f, 32, 50f, 35, 1); //32 o 0 no cambia
  3058.                 }
  3059.                 if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_CAR, RecieveOrder.CurrentVehicle.Model) || GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_BIKE, RecieveOrder.CurrentVehicle.Model) || GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_QUADBIKE, RecieveOrder.CurrentVehicle.Model))
  3060.                 {
  3061.                     if (Game.Player.Character.IsSittingInVehicle())
  3062.                     {
  3063.                         if (DrivingCareful.Contains(RecieveOrder))
  3064.                         {
  3065.                             UI.ShowSubtitle("Escort my " + Game.Player.Character.CurrentVehicle.FriendlyName + ". Careful.", 1000);
  3066.                             GTA.Native.Function.Call(GTA.Native.Hash.TASK_VEHICLE_ESCORT, RecieveOrder, RecieveOrder.CurrentVehicle, Game.Player.Character.CurrentVehicle, -1, 40.0, 1 | 2 | 4 | 32, 20f, 1f, 5f);
  3067.                         }
  3068.                         if (DrivingNormal.Contains(RecieveOrder))
  3069.                         {
  3070.                             GTA.Native.Function.Call(GTA.Native.Hash.SET_DRIVE_TASK_DRIVING_STYLE, RecieveOrder, 6);
  3071.  
  3072.                             UI.ShowSubtitle("Escort my " + Game.Player.Character.CurrentVehicle.FriendlyName + ".", 1000);
  3073.                             GTA.Native.Function.Call(GTA.Native.Hash.TASK_VEHICLE_ESCORT, RecieveOrder, RecieveOrder.CurrentVehicle, Game.Player.Character.CurrentVehicle, -1, 60f, 1 | 2 | 4 | 16 | 32, 0f, 0f, 10f);
  3074.                         }
  3075.                         if (DrivingFurious.Contains(RecieveOrder))
  3076.                         {
  3077.                             UI.ShowSubtitle("Escort my " + Game.Player.Character.CurrentVehicle.FriendlyName + ". Be with me no matter what.", 1000);
  3078.                             GTA.Native.Function.Call(GTA.Native.Hash.TASK_VEHICLE_ESCORT, RecieveOrder, RecieveOrder.CurrentVehicle, Game.Player.Character.CurrentVehicle, -1, 200f, 1 | 4 | 16 | 32, 0f, 0f, 20f);
  3079.                         }
  3080.                     }
  3081.                 }
  3082.             }
  3083.             else
  3084.             {
  3085.                 UI.ShowSubtitle("The Squad Leader needs to be in a vehicle to escort you.");
  3086.             }
  3087.         }
  3088.         else
  3089.         {
  3090.             UI.ShowSubtitle("There is no Squad Leader to give orders.", 2000);
  3091.         }
  3092.     }
  3093.  
  3094.     void NonSituationalEnterLeaveVehicle(Ped RecieveOrder)
  3095.     {
  3096.         if (CanWeUse(RecieveOrder) && RecieveOrder.IsAlive)
  3097.         {
  3098.             if (RecieveOrder.IsSittingInVehicle())
  3099.             {
  3100.                 if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_HELI, RecieveOrder.CurrentVehicle.Model))
  3101.                 {
  3102.                     if (RecieveOrder.CurrentVehicle.IsStopped)
  3103.                     {
  3104.                         RecieveOrder.Task.LeaveVehicle();
  3105.                         UI.ShowSubtitle("Leave the " + RecieveOrder.CurrentVehicle.FriendlyName + ".", 1000);
  3106.  
  3107.                     }
  3108.                     else
  3109.                     {
  3110.                         UI.ShowSubtitle("Land the " + RecieveOrder.CurrentVehicle.FriendlyName + ".", 1000);
  3111.                         Function.Call(Hash.TASK_HELI_MISSION, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, 0, 0, RecieveOrder.Position.X, RecieveOrder.Position.Y, RecieveOrder.Position.Z, 20, 40f, 1f, 36f, 15, 15, -1f, 1);
  3112.                     }
  3113.                 }
  3114.                 else
  3115.                 {
  3116.                     Function.Call<bool>(GTA.Native.Hash.TASK_LEAVE_VEHICLE, RecieveOrder, RecieveOrder.CurrentVehicle, 0);
  3117.                     UI.ShowSubtitle("Leave the " + RecieveOrder.CurrentVehicle.FriendlyName + ".", 1000);
  3118.  
  3119.                 }
  3120.             }
  3121.             else
  3122.             {
  3123.                 Vehicle lastveh = GTA.Native.Function.Call<Vehicle>(GTA.Native.Hash.GET_VEHICLE_PED_IS_IN, RecieveOrder, true);
  3124.                 if (CanWeUse(lastveh))
  3125.                 {
  3126.                     if (lastveh.IsAlive)
  3127.                     {
  3128.                         GTA.Native.Function.Call<bool>(GTA.Native.Hash.TASK_ENTER_VEHICLE, RecieveOrder, lastveh, -1, -1, 2.0, 1, 0);
  3129.                         UI.ShowSubtitle("Get back to the " + lastveh.FriendlyName + ".", 1000);
  3130.                     }
  3131.                     else
  3132.                     {
  3133.                         UI.ShowSubtitle("This squad can't get in their " + lastveh.FriendlyName + ", it is destroyed.", 1000);
  3134.                     }
  3135.                 }
  3136.             }
  3137.         }
  3138.         else
  3139.         {
  3140.             UI.ShowSubtitle("There is no Squad Leader to give orders.", 2000);
  3141.         }
  3142.     }
  3143.  
  3144.     void NonSituationalLeaveVehicle(Ped RecieveOrder)
  3145.     {
  3146.         if (CanWeUse(RecieveOrder) && RecieveOrder.IsAlive)
  3147.         {
  3148.             if (!RecieveOrder.IsOnFoot && CanWeUse(RecieveOrder.CurrentVehicle))
  3149.             {
  3150.                 RecieveOrder.Task.LeaveVehicle(RecieveOrder.CurrentVehicle, true);
  3151.             }
  3152.         }
  3153.     }
  3154.  
  3155.     void RappelFunction(Ped RecieveOrder)
  3156.     {
  3157.         if (CanWeUse(RecieveOrder))
  3158.         {
  3159.             if (CanWeUse(RecieveOrder.CurrentVehicle))
  3160.             {
  3161.                 if (RecieveOrder.CurrentVehicle.Model == new Model(VehicleHash.Polmav) || RecieveOrder.CurrentVehicle.Model == new Model(VehicleHash.Maverick))
  3162.                 {
  3163.                     UI.ShowSubtitle("Make your passengers rappel from the " + RecieveOrder.CurrentVehicle.FriendlyName + ".");
  3164.                     if (CanWeUse(RecieveOrder.CurrentVehicle.GetPedOnSeat(VehicleSeat.LeftRear)))
  3165.                     {
  3166.                         Function.Call(Hash.TASK_RAPPEL_FROM_HELI, RecieveOrder.CurrentVehicle.GetPedOnSeat(VehicleSeat.LeftRear), 1f);
  3167.                     }
  3168.                     if (CanWeUse(RecieveOrder.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightRear)))
  3169.                     {
  3170.                         Function.Call(Hash.TASK_RAPPEL_FROM_HELI, RecieveOrder.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightRear), 1f);
  3171.                     }
  3172.                     if (!CanWeUse(RecieveOrder.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightRear)) && !CanWeUse(RecieveOrder.CurrentVehicle.GetPedOnSeat(VehicleSeat.LeftRear)) && CanWeUse(RecieveOrder.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightFront)))
  3173.                     {
  3174.                         RecieveOrder.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightFront).SetIntoVehicle(RecieveOrder.CurrentVehicle, VehicleSeat.RightRear);
  3175.                         Function.Call(Hash.TASK_RAPPEL_FROM_HELI, RecieveOrder.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightRear), 1f);
  3176.                     }
  3177.  
  3178.                 }
  3179.                 else
  3180.                 {
  3181.                     UI.ShowSubtitle("Squad Leader's vehicle does not allow rappeling.");
  3182.                 }
  3183.             }
  3184.             else
  3185.             {
  3186.                 UI.ShowSubtitle("Squad Leader is not in a vehicle.");
  3187.             }
  3188.         }
  3189.         else
  3190.         {
  3191.             UI.ShowSubtitle("Squad Leader not found.");
  3192.         }
  3193.     }
  3194.  
  3195.     void ApplyOrder(Ped RecieveOrder)
  3196.     {
  3197.         //UI.Notify(hitcoord.ToString());
  3198.         if (CanWeUse(RecieveOrder) && RecieveOrder.IsAlive)
  3199.         {
  3200.             if (!RecieveOrder.IsSittingInVehicle())
  3201.             {
  3202.                 if (CanWeUse(entitihit))
  3203.                 {
  3204.                     if (entitihit is Vehicle && entitihit.IsAlive)
  3205.                     {
  3206.                         Vehicle entityveh = entitihit as Vehicle;
  3207.                         if (CanWeUse(entityveh.GetPedOnSeat(VehicleSeat.Driver)) && (entityveh.GetPedOnSeat(VehicleSeat.Driver) == Squad1Leader || entityveh.GetPedOnSeat(VehicleSeat.Driver) == Squad2Leader || entityveh.GetPedOnSeat(VehicleSeat.Driver) == Squad3Leader || entityveh.GetPedOnSeat(VehicleSeat.Driver) == Squad4Leader || entityveh.GetPedOnSeat(VehicleSeat.Driver) == Game.Player.Character))
  3208.                         {
  3209.                             UI.ShowSubtitle("Enter that " + entityveh.FriendlyName + " as passenger", 1000);
  3210.                             int max_seats = GTA.Native.Function.Call<int>(GTA.Native.Hash.GET_VEHICLE_MAX_NUMBER_OF_PASSENGERS, entityveh);
  3211.  
  3212.                             for (int i = -5; i < max_seats; i++)
  3213.                             {
  3214.                                 if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_VEHICLE_SEAT_FREE, entityveh, i))
  3215.                                 {
  3216.                                     GTA.Native.Function.Call<bool>(GTA.Native.Hash.TASK_ENTER_VEHICLE, RecieveOrder, entityveh, -1, i, 2.0, 1, 0);
  3217.                                     break;
  3218.                                 }
  3219.                             }
  3220.                         }
  3221.                         else
  3222.                         {
  3223.                             RecieveOrder.Task.DriveTo(entityveh, entityveh.Position, 4, 200f);
  3224.                             UI.ShowSubtitle("Enter that " + entityveh.FriendlyName, 1000);
  3225.                         }
  3226.  
  3227.                     }
  3228.                     if (entitihit is Ped)
  3229.                     {
  3230.                         Ped entityped = entitihit as Ped;
  3231.                         if (entityped != RecieveOrder)
  3232.                         {
  3233.                             UI.ShowSubtitle("Attack that ped", 1000);
  3234.                             RecieveOrder.Task.FightAgainst(entityped, -1);
  3235.                         }
  3236.                     }
  3237.                 }
  3238.                 else
  3239.                 if (hitcoord != new Vector3(0, 0, 0))
  3240.                 {
  3241.                     if (RecieveOrder.IsInCombat)
  3242.                     {
  3243.                         RecieveOrder.Task.RunTo(hitcoord, false);
  3244.                         foreach (Ped enemy in World.GetNearbyPeds(hitcoord,10f))
  3245.                         {
  3246.                             Function.Call(Hash.REGISTER_TARGET, RecieveOrder,enemy);
  3247.                         }
  3248.                         UI.ShowSubtitle("Attack this area", 1000);
  3249.                     }
  3250.                     else
  3251.                     {
  3252.                         RecieveOrder.Task.RunTo(hitcoord, false);
  3253.                         UI.ShowSubtitle("Run there", 1000);
  3254.                     }
  3255.                 }
  3256.             }
  3257.             if (RecieveOrder.IsSittingInVehicle())
  3258.             {
  3259.                 if (CanWeUse(entitihit))
  3260.                 {
  3261.                     if (entitihit is Vehicle)
  3262.                     {
  3263.                         Vehicle entityveh = entitihit as Vehicle;
  3264.                         if (entityveh == RecieveOrder.CurrentVehicle)
  3265.                         {
  3266.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_HELI, RecieveOrder.CurrentVehicle.Model))
  3267.                             {
  3268.                                 if (RecieveOrder.CurrentVehicle.IsStopped)
  3269.                                 {
  3270.                                     UI.ShowSubtitle("Leave the " + entityveh.FriendlyName, 1000);
  3271.                                     RecieveOrder.Task.LeaveVehicle();
  3272.                                 }
  3273.                                 else
  3274.                                 {
  3275.                                     UI.ShowSubtitle("Land the " + entityveh.FriendlyName, 1000);
  3276.                                     Function.Call(Hash.TASK_HELI_MISSION, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, 0, 0, RecieveOrder.Position.X, RecieveOrder.Position.Y, RecieveOrder.Position.Z, 20, 40f, 1f, 36f, 15, 15, -1f, 1);
  3277.                                 }
  3278.                             }
  3279.                             else
  3280.                             {
  3281.                                 UI.ShowSubtitle("Leave the " + entityveh.FriendlyName, 1000);
  3282.                                 RecieveOrder.Task.LeaveVehicle();
  3283.                             }
  3284.                         }
  3285.                         if (entityveh != RecieveOrder.CurrentVehicle)
  3286.                         {
  3287.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_HELI, RecieveOrder.CurrentVehicle.Model))
  3288.                             {
  3289.                                 if (CanWeUse(entityveh.GetPedOnSeat(VehicleSeat.Driver)))
  3290.                                 {
  3291.                                     if (entityveh.GetPedOnSeat(VehicleSeat.Driver) == Squad1Leader || entityveh.GetPedOnSeat(VehicleSeat.Driver) == Squad2Leader || entityveh.GetPedOnSeat(VehicleSeat.Driver) == Game.Player.Character || entityveh.GetPedOnSeat(VehicleSeat.Driver) == Squad3Leader || entityveh.GetPedOnSeat(VehicleSeat.Driver) == Squad4Leader)
  3292.                                     {
  3293.                                         UI.ShowSubtitle("Protect that " + entityveh.FriendlyName, 1000);
  3294.                                         Function.Call(Hash.TASK_VEHICLE_HELI_PROTECT, RecieveOrder, RecieveOrder.CurrentVehicle, entityveh.GetPedOnSeat(VehicleSeat.Driver), 50f, 32, 25f, 35,1);
  3295.                                     }
  3296.                                     else
  3297.                                     {
  3298.                                         UI.ShowSubtitle("Chase that " + entityveh.FriendlyName, 1000);
  3299.                                         Function.Call(Hash.TASK_HELI_CHASE, RecieveOrder, entityveh, 20f, 20f, 80f);
  3300.                                     }
  3301.                                 }
  3302.                                 else
  3303.                                 {
  3304.                                     UI.ShowSubtitle("Protect that empty " + entityveh.FriendlyName, 1000);
  3305.                                     Function.Call(Hash.TASK_VEHICLE_HELI_PROTECT, RecieveOrder, RecieveOrder.CurrentVehicle, entityveh, 50f, 32, 25f, 35, 1);
  3306.  
  3307.                                 }
  3308.  
  3309.                             }
  3310.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_CAR, RecieveOrder.CurrentVehicle.Model) || GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_BIKE, RecieveOrder.CurrentVehicle.Model) || GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_QUADBIKE, RecieveOrder.CurrentVehicle.Model))
  3311.                             {
  3312.                                 if (CanWeUse(entityveh.GetPedOnSeat(VehicleSeat.Driver)))
  3313.                                 {
  3314.                                     if (!CanWeUse(entityveh.GetPedOnSeat(VehicleSeat.Driver)) || entityveh.GetPedOnSeat(VehicleSeat.Driver) == Squad1Leader || entityveh.GetPedOnSeat(VehicleSeat.Driver) == Squad2Leader || entityveh.GetPedOnSeat(VehicleSeat.Driver) == Game.Player.Character || entityveh.GetPedOnSeat(VehicleSeat.Driver) == Squad3Leader || entityveh.GetPedOnSeat(VehicleSeat.Driver) == Squad4Leader)
  3315.                                     {
  3316.                                         if (DrivingCareful.Contains(RecieveOrder))
  3317.                                         {
  3318.                                             UI.ShowSubtitle("Escort that " + entityveh.FriendlyName + ". Careful.", 1000);
  3319.                                             GTA.Native.Function.Call(GTA.Native.Hash.TASK_VEHICLE_ESCORT, RecieveOrder, RecieveOrder.CurrentVehicle, entityveh, -1, 40.0, 1 | 4 | 16 | 32 | 4194304, 20f, 1f, 5f);
  3320.                                         }
  3321.                                         if (DrivingNormal.Contains(RecieveOrder))
  3322.                                         {
  3323.                                             UI.ShowSubtitle("Escort that " + entityveh.FriendlyName + ".", 1000);
  3324.                                             GTA.Native.Function.Call(GTA.Native.Hash.TASK_VEHICLE_ESCORT, RecieveOrder, RecieveOrder.CurrentVehicle, entityveh, -1, 60.0, 1 | 4 | 16 | 32 | 4194304, 3f, 1f, 10f);
  3325.                                         }
  3326.                                         if (DrivingFurious.Contains(RecieveOrder))
  3327.                                         {
  3328.                                             UI.ShowSubtitle("Escort that " + entityveh.FriendlyName + ". Be with them no matter what.", 1000);
  3329.                                             GTA.Native.Function.Call(GTA.Native.Hash.TASK_VEHICLE_ESCORT, RecieveOrder, RecieveOrder.CurrentVehicle, entityveh, -1, 90.0, 1 | 4 | 16 | 32 | 4194304, 1f, 1f, 30f);
  3330.                                         }
  3331.                                     }
  3332.                                     else
  3333.                                     {
  3334.                                         RecieveOrder.Task.FightAgainst(entityveh.GetPedOnSeat(VehicleSeat.Driver), -1);
  3335.                                         UI.ShowSubtitle("Chase that" + entityveh.FriendlyName, 1000);
  3336.                                     }
  3337.                                 }
  3338.                             }
  3339.                         }
  3340.                     }
  3341.                     if (entitihit is Ped)
  3342.                     {
  3343.                         Ped entityped = entitihit as Ped;
  3344.                         if (entityped != RecieveOrder)
  3345.                         {
  3346.                             UI.ShowSubtitle("Attack that ped from your vehicle", 1000);
  3347.                             RecieveOrder.Task.FightAgainst(entityped, -1);
  3348.                         }
  3349.                     }
  3350.                 }
  3351.                 if (!CanWeUse(entitihit) && hitcoord != new Vector3(0, 0, 0))
  3352.                 {
  3353.                     if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_HELI, RecieveOrder.CurrentVehicle.Model))
  3354.                     {
  3355.                         if (RecieveOrder.CurrentVehicle.GetPedOnSeat(VehicleSeat.Driver) == RecieveOrder)
  3356.                         {
  3357.                             if (RecieveOrder.CurrentVehicle.Model == new Model(VehicleHash.Cargobob))
  3358.                             {
  3359.                                 if (RecieveOrder.Position.DistanceTo(hitcoord) < 60)
  3360.                                 {
  3361.                                     UI.ShowSubtitle("Fly the cargobob there (near).", 1000);
  3362.                                     Function.Call(Hash.TASK_HELI_MISSION, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, 0, 0, hitcoord.X, hitcoord.Y, hitcoord.Z, 6, 20f, 1f, 1f, 7, 8, -1f, 1);
  3363.                                 }
  3364.                                 else
  3365.                                 {
  3366.                                     UI.ShowSubtitle("Fly the cargobob there.", 1000);
  3367.                                     Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, hitcoord.X, hitcoord.Y, hitcoord.Z + 30, 10.0, 0, RecieveOrder.CurrentVehicle.Model, 6, 60, 10.0);
  3368.                                 }
  3369.                             }
  3370.                             else
  3371.                             {
  3372.                                 UI.ShowSubtitle("Fly there.", 1000);
  3373.                                 //Function.Call(Hash.TASK_HELI_MISSION, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, 0, 0, hitcoord.X, hitcoord.Y, hitcoord.Z, 6, 40f, 1f, 36f, 15, 15, -1f, 1); //makes armed helis shoot randomly
  3374.                                 //Function.Call(Hash.TASK_VEHICLE_SHOOT_AT_COORD, RecieveOrder.CurrentVehicle.Handle, hitcoord.X, hitcoord.Y, hitcoord.Z, 5000f);
  3375.                                 //Function.Call(Hash.ADD_VEHICLE_SUBTASK_ATTACK_COORD, RecieveOrder, hitcoord.X, hitcoord.Y, hitcoord.Z);
  3376.  
  3377.                                 Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, hitcoord.X, hitcoord.Y, hitcoord.Z + 20, 20.0, 0, RecieveOrder.CurrentVehicle.Model, 6, 60, 15.0);
  3378.                             }
  3379.                         }
  3380.                     }
  3381.                     if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_CAR, RecieveOrder.CurrentVehicle.Model) || GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_BIKE, RecieveOrder.CurrentVehicle.Model) || GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_QUADBIKE, RecieveOrder.CurrentVehicle.Model))
  3382.                     {
  3383.                         if (RecieveOrder.CurrentVehicle.GetPedOnSeat(VehicleSeat.Driver) == RecieveOrder)
  3384.                         {
  3385.                             if (RecieveOrder.Position.DistanceTo(hitcoord) < 200)
  3386.                             {
  3387.                                 if (RecieveOrder.Position.DistanceTo(hitcoord) < 20)
  3388.                                 {
  3389.                                     UI.ShowSubtitle("Drive directly there", 1000);
  3390.                                     Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, RecieveOrder.Handle, RecieveOrder.CurrentVehicle, hitcoord.X, hitcoord.Y, hitcoord.Z, 10f, 1, RecieveOrder.CurrentVehicle.Model,1|2|4|16|32, 1.0, 40.0);
  3391.                                 }
  3392.                                 else
  3393.                                 {
  3394.                                     UI.ShowSubtitle("Drive there (near)", 1000);
  3395.                                     if (DrivingCareful.Contains(RecieveOrder))
  3396.                                     {
  3397.                                        Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, hitcoord.X, hitcoord.Y, hitcoord.Z, 3f, 4194304 | 1 | 2 | 32, 1f);
  3398.                                     }
  3399.                                     if (DrivingNormal.Contains(RecieveOrder))
  3400.                                     {
  3401.                                         Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, hitcoord.X, hitcoord.Y, hitcoord.Z, 6f, 4194304 | 1 | 2 | 4 | 16 | 32, 1f);
  3402.                                     }
  3403.                                     if (DrivingFurious.Contains(RecieveOrder))
  3404.                                     {
  3405.                                         Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, RecieveOrder.Handle, RecieveOrder.CurrentVehicle.Handle, hitcoord.X, hitcoord.Y, hitcoord.Z, 90f, 16777264 | 1 | 2 | 4 | 16 | 32, 1f);
  3406.  
  3407.                                         //RecieveOrder.Task.ParkVehicle(RecieveOrder.CurrentVehicle, hitcoord, Game.Player.Character.Heading);
  3408.                                         //Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, RecieveOrder.Handle, RecieveOrder.CurrentVehicle, hitcoord.X, hitcoord.Y, hitcoord.Z, 10f, 1, RecieveOrder.CurrentVehicle.Model, 4194304 | 4 | 16 | 321, 0.5, 0.5);
  3409.                                     }
  3410.  
  3411.  
  3412.                                     //Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, RecieveOrder.Handle, RecieveOrder.CurrentVehicle, hitcoord.X, hitcoord.Y, hitcoord.Z, 10f, 1, RecieveOrder.CurrentVehicle.Model, 4194304| 32|2|1, 1.0, 2.0);
  3413.                                 }
  3414.                             }
  3415.                             else
  3416.                             {
  3417.                                 UI.ShowSubtitle("Drive there", 1000);
  3418.                                 DriveTo(RecieveOrder, hitcoord, 5);
  3419.                             }
  3420.                         }
  3421.                         else
  3422.                         {
  3423.                             RecieveOrder.Task.RunTo(hitcoord, false);
  3424.                             UI.ShowSubtitle("Get out of that " + RecieveOrder.CurrentVehicle.FriendlyName + " and run there", 1000);
  3425.                         }
  3426.                     }
  3427.                 }
  3428.             }
  3429.         }
  3430.         else
  3431.         {
  3432.             UI.ShowSubtitle("Squad Leader not found.");
  3433.         }
  3434.     }
  3435.    
  3436.  
  3437.     void FixSquadLeaders()
  3438.     {
  3439.         foreach (Ped ped in Squad2)
  3440.         {
  3441.             if (CanWeUse(ped))
  3442.             {
  3443.                 if (!ped.IsAlive && ped.CurrentBlip.Exists())
  3444.                 {
  3445.                     ped.CurrentBlip.Remove();
  3446.                 }
  3447.             }
  3448.         }
  3449.         foreach (Ped ped in Squad1)
  3450.         {
  3451.             if (CanWeUse(ped))
  3452.             {
  3453.                 if (!ped.IsAlive && ped.CurrentBlip.Exists())
  3454.                 {
  3455.                     ped.CurrentBlip.Remove();
  3456.                 }
  3457.             }
  3458.         }
  3459.         foreach (Ped ped in Squad3)
  3460.         {
  3461.             if (CanWeUse(ped))
  3462.             {
  3463.                 if (!ped.IsAlive && ped.CurrentBlip.Exists())
  3464.                 {
  3465.                     ped.CurrentBlip.Remove();
  3466.                 }
  3467.             }
  3468.         }
  3469.         foreach (Ped ped in Squad4)
  3470.         {
  3471.             if (CanWeUse(ped))
  3472.             {
  3473.                 if (!ped.IsAlive && ped.CurrentBlip.Exists())
  3474.                 {
  3475.                     ped.CurrentBlip.Remove();
  3476.                 }
  3477.             }
  3478.         }
  3479.         if (CanWeUse(Squad1Leader) && !Squad1Leader.IsAlive && Squad1.Count>0)
  3480.         {
  3481.             var alldead = 0;
  3482.             foreach (Ped ped in Squad1)
  3483.             {
  3484.                 if (CanWeUse(ped) && ped.IsAlive)
  3485.                 {
  3486.  
  3487.                     Squad1Leader = ped;
  3488.                     Function.Call(Hash.SET_PED_AS_GROUP_LEADER, Squad1Leader.Handle, Squad1Group);
  3489.                     PrepareSquadLeader(Squad1Leader,Squad1);
  3490.                     break;
  3491.                 }
  3492.                 else
  3493.                 {
  3494.                     alldead++;
  3495.                 }
  3496.             }
  3497.             if (alldead >= Squad1.Count)
  3498.             {
  3499.                 RemoveSquad1();
  3500.                 UI.Notify("~r~Squad 1 has been defeated.");
  3501.                 if (Squad1Autocall.Checked)
  3502.                 {
  3503.                     CreateSquad1();
  3504.                 }
  3505.             }
  3506.         }
  3507.  
  3508.         if (CanWeUse(Squad2Leader) && !Squad2Leader.IsAlive && Squad2.Count > 0)
  3509.         {
  3510.             var alldead = 0;
  3511.             foreach (Ped ped in Squad2)
  3512.             {
  3513.                 if (CanWeUse(ped) && ped.IsAlive)
  3514.                 {
  3515.  
  3516.                     Squad2Leader = ped;
  3517.                     Function.Call(Hash.SET_PED_AS_GROUP_LEADER, Squad2Leader.Handle, Squad2Group);
  3518.                     PrepareSquadLeader(Squad2Leader, Squad2);
  3519.                     break;
  3520.                 }
  3521.                 else
  3522.                 {
  3523.                     alldead++;
  3524.                 }
  3525.             }
  3526.             if (alldead >= Squad2.Count)
  3527.             {
  3528.                 RemoveSquad2();
  3529.                 UI.Notify("~r~Squad 2 has been defeated.");
  3530.                 if (Squad2Autocall.Checked)
  3531.                 {
  3532.                     CreateSquad2();
  3533.                 }
  3534.             }
  3535.         }
  3536.  
  3537.  
  3538.         if (CanWeUse(Squad3Leader) && !Squad3Leader.IsAlive && Squad3.Count > 0)
  3539.         {
  3540.             var alldead = 0;
  3541.             foreach (Ped ped in Squad3)
  3542.             {
  3543.                 if (CanWeUse(ped) && ped.IsAlive)
  3544.                 {
  3545.  
  3546.                     Squad3Leader = ped;
  3547.                     Function.Call(Hash.SET_PED_AS_GROUP_LEADER, Squad3Leader.Handle, Squad3Group);
  3548.                     PrepareSquadLeader(Squad3Leader, Squad3);
  3549.                     break;
  3550.                 }
  3551.                 else
  3552.                 {
  3553.                     alldead++;
  3554.                 }
  3555.             }
  3556.             if (alldead >= Squad3.Count)
  3557.             {
  3558.                 RemoveSquad3();
  3559.                 UI.Notify("~r~Squad 1 has been defeated.");
  3560.                 if (Squad3Autocall.Checked)
  3561.                 {
  3562.                     CreateSquad3();
  3563.                 }
  3564.             }
  3565.         }
  3566.         if (CanWeUse(Squad4Leader) && !Squad4Leader.IsAlive && Squad4.Count > 0)
  3567.         {
  3568.             var alldead = 0;
  3569.             foreach (Ped ped in Squad4)
  3570.             {
  3571.                 if (CanWeUse(ped) && ped.IsAlive)
  3572.                 {
  3573.  
  3574.                     Squad4Leader = ped;
  3575.                     Function.Call(Hash.SET_PED_AS_GROUP_LEADER, Squad4Leader.Handle, Squad4Group);
  3576.                     PrepareSquadLeader(Squad4Leader, Squad4);
  3577.                     break;
  3578.                 }
  3579.                 else
  3580.                 {
  3581.                     alldead++;
  3582.                 }
  3583.             }
  3584.             if (alldead >= Squad4.Count)
  3585.             {
  3586.                 RemoveSquad4();
  3587.                 UI.Notify("~r~Squad 1 has been defeated.");
  3588.                 if (Squad4Autocall.Checked)
  3589.                 {
  3590.                     CreateSquad4();
  3591.                 }
  3592.             }
  3593.         }
  3594.     }
  3595.  
  3596.     void OnTick(object sender, EventArgs e)
  3597.     {
  3598.         HandleAirCombat(Squad1Leader);
  3599.         HandleAirCombat(Squad2Leader);
  3600.         HandleAirCombat(Squad3Leader);
  3601.         HandleAirCombat(Squad4Leader);
  3602.  
  3603.         //DONE EVERY 2 SECONDS
  3604.         if (DateTime.Now.Subtract(interval2sec).TotalSeconds > 2f)
  3605.         {
  3606.             interval2sec = DateTime.Now;
  3607.         }
  3608.  
  3609.         //DONE EVERY SECOND
  3610.         if (DateTime.Now.Subtract(interval1sec).TotalSeconds > 1)
  3611.         {
  3612.             FixSquadLeaders();
  3613.             interval1sec = DateTime.Now;
  3614.         }
  3615.  
  3616.         var res = UIMenu.GetScreenResolutionMantainRatio();
  3617.         var safe = UIMenu.GetSafezoneBounds();
  3618.         _menuPool.ProcessMenus();
  3619.  
  3620.  
  3621.         if (SquadStatusOnScreen)
  3622.         {
  3623.             int pluszone = 0;
  3624.             if (CanWeUse(Squad1Leader) && Squad1.Count > 0)
  3625.             {
  3626.                 pluszone = pluszone + 35;
  3627.                 new Sprite("timerbars", "all_black_bg", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364), new Size(34, 250), 270f, Squad1Color).Draw();
  3628.                 if (Squad1Leader.IsInCombat)
  3629.                 {
  3630.                     new Sprite("mpinventory", "shooting_range", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 397), new Size(32, 32), 0f, Color.FromArgb(255, 255, 0, 0)).Draw();
  3631.                 }
  3632.                 int size = 32;
  3633.                 var number = 0;
  3634.                 foreach (Ped ped in Squad1)
  3635.                 {
  3636.                     if (ped.IsAlive)
  3637.                     {
  3638.                         if (ped.IsSittingInVehicle())
  3639.                         {
  3640.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_CAR, ped.CurrentVehicle.Model))
  3641.                             {
  3642.                                 new Sprite("mpinventory", "mp_specitem_car", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(size, size), 0f, Squad1Color).Draw();
  3643.                             }
  3644.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_BIKE, ped.CurrentVehicle.Model) || GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_QUADBIKE, ped.CurrentVehicle.Model))
  3645.                             {
  3646.                                 new Sprite("mpinventory", "mp_specitem_bike", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(size, size), 0f, Squad1Color).Draw();
  3647.                             }
  3648.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_HELI, ped.CurrentVehicle.Model))
  3649.                             {
  3650.                                 new Sprite("mpinventory", "mp_specitem_heli", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(size, size), 0f, Squad1Color).Draw();
  3651.                             }
  3652.                             if (ped.CurrentVehicle.GetPedOnSeat(VehicleSeat.Driver) == ped)
  3653.                             {
  3654.                                 new Sprite("mpinventory", "mp_specitem_steer_wheel", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number + size/2), new Size(16, 16), 0f, Squad1Color).Draw();
  3655.                             }
  3656.                         }
  3657.                         else
  3658.                         {
  3659.                             new Sprite("mpinventory", "mp_specitem_ped", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(size, size), 0f, Squad1Color).Draw();
  3660.                         }
  3661.  
  3662.                         if (ped.Health < 50)
  3663.                         {
  3664.                             new Sprite("helicopterhud", "targetlost", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone + 16, Convert.ToInt32(res.Height) - safe.Y - 364 + number + 16), new Size(16, 16), 0f, Color.Red).Draw();
  3665.                         }
  3666.                     }
  3667.                     else
  3668.                     {
  3669.                         new Sprite("mpinventory", "survival", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad1Color).Draw();
  3670.                     }
  3671.                     number = number + 32;
  3672.                 }
  3673.             }
  3674.  
  3675.             if (CanWeUse(Squad2Leader) && Squad2.Count > 0)
  3676.             {
  3677.                 pluszone = pluszone + 35;
  3678.  
  3679.                 new Sprite("timerbars", "all_black_bg", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364), new Size(34, 250), 270f, Squad2Color).Draw();
  3680.                 if (Squad2Leader.IsInCombat)
  3681.                 {
  3682.                     new Sprite("mpinventory", "shooting_range", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 397), new Size(32, 32), 0f, Color.FromArgb(255, 255, 0, 0)).Draw();
  3683.                 }
  3684.                 var number = 0;
  3685.                 foreach (Ped ped in Squad2)
  3686.                 {
  3687.  
  3688.                     if (ped.IsAlive)
  3689.                     {
  3690.                         if (ped.IsSittingInVehicle())
  3691.                         {
  3692.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_CAR, ped.CurrentVehicle.Model))
  3693.                             {
  3694.                                 new Sprite("mpinventory", "mp_specitem_car", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad2Color).Draw();
  3695.                             }
  3696.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_BIKE, ped.CurrentVehicle.Model)|| GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_QUADBIKE, ped.CurrentVehicle.Model))
  3697.                             {
  3698.                                 new Sprite("mpinventory", "mp_specitem_bike", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad2Color).Draw();
  3699.                             }
  3700.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_HELI, ped.CurrentVehicle.Model))
  3701.                             {
  3702.                                 new Sprite("mpinventory", "mp_specitem_heli", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad2Color).Draw();
  3703.                             }
  3704.                             if (ped.CurrentVehicle.GetPedOnSeat(VehicleSeat.Driver) == ped)
  3705.                             {
  3706.                                 new Sprite("mpinventory", "mp_specitem_steer_wheel", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number + 16), new Size(16, 16), 0f, Squad2Color).Draw();
  3707.                             }
  3708.                         }
  3709.                         else
  3710.                         {
  3711.                             new Sprite("mpinventory", "mp_specitem_ped", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad2Color).Draw();
  3712.                         }
  3713.                         if (ped.Health < 50)
  3714.                         {
  3715.                             new Sprite("helicopterhud", "targetlost", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone + 16, Convert.ToInt32(res.Height) - safe.Y - 364 + number + 16), new Size(16, 16), 0f, Color.Red).Draw();
  3716.                         }
  3717.                     }
  3718.                     else
  3719.                     {
  3720.                         new Sprite("mpinventory", "survival", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad2Color).Draw();
  3721.                     }
  3722.                     number = number + 32;
  3723.                 }
  3724.             }
  3725.  
  3726.             if (CanWeUse(Squad3Leader) && Squad3.Count > 0)
  3727.             {
  3728.                 pluszone = pluszone + 35;
  3729.  
  3730.                 new Sprite("timerbars", "all_black_bg", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364), new Size(34, 250), 270f, Squad3Color).Draw();
  3731.                 if (Squad3Leader.IsInCombat)
  3732.                 {
  3733.                     new Sprite("mpinventory", "shooting_range", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 397), new Size(32, 32), 0f, Color.FromArgb(255, 255, 0, 0)).Draw();
  3734.                 }
  3735.                 var number = 0;
  3736.                 foreach (Ped ped in Squad3)
  3737.                 {
  3738.  
  3739.                     if (ped.IsAlive)
  3740.                     {
  3741.                         if (ped.IsSittingInVehicle())
  3742.                         {
  3743.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_CAR, ped.CurrentVehicle.Model))
  3744.                             {
  3745.                                 new Sprite("mpinventory", "mp_specitem_car", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad3Color).Draw();
  3746.                             }
  3747.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_BIKE, ped.CurrentVehicle.Model) || GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_QUADBIKE, ped.CurrentVehicle.Model))
  3748.                             {
  3749.                                 new Sprite("mpinventory", "mp_specitem_bike", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad3Color).Draw();
  3750.                             }
  3751.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_HELI, ped.CurrentVehicle.Model))
  3752.                             {
  3753.                                 new Sprite("mpinventory", "mp_specitem_heli", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad3Color).Draw();
  3754.                             }
  3755.                             if (ped.CurrentVehicle.GetPedOnSeat(VehicleSeat.Driver) == ped)
  3756.                             {
  3757.                                 new Sprite("mpinventory", "mp_specitem_steer_wheel", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number + 16), new Size(16, 16), 0f, Squad3Color).Draw();
  3758.                             }
  3759.                         }
  3760.                         else
  3761.                         {
  3762.                             new Sprite("mpinventory", "mp_specitem_ped", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad3Color).Draw();
  3763.                         }
  3764.                         if (ped.Health < 50)
  3765.                         {
  3766.                             new Sprite("helicopterhud", "targetlost", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone + 16, Convert.ToInt32(res.Height) - safe.Y - 364 + number + 16), new Size(16, 16), 0f, Color.Red).Draw();
  3767.                         }
  3768.                     }
  3769.                     else
  3770.                     {
  3771.                         new Sprite("mpinventory", "survival", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad3Color).Draw();
  3772.                     }
  3773.                     number = number + 32;
  3774.                 }
  3775.             }
  3776.  
  3777.             if (CanWeUse(Squad4Leader) && Squad4.Count > 0)
  3778.             {
  3779.                 pluszone = pluszone + 35;
  3780.  
  3781.                 new Sprite("timerbars", "all_black_bg", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364), new Size(34, 250), 270f, Squad4Color).Draw();
  3782.                 if (Squad4Leader.IsInCombat)
  3783.                 {
  3784.                     new Sprite("mpinventory", "shooting_range", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 397), new Size(32, 32), 0f, Color.FromArgb(255, 255, 0, 0)).Draw();
  3785.                 }
  3786.                 var number = 0;
  3787.                 foreach (Ped ped in Squad4)
  3788.                 {
  3789.  
  3790.                     if (ped.IsAlive)
  3791.                     {
  3792.                         if (ped.IsSittingInVehicle())
  3793.                         {
  3794.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_CAR, ped.CurrentVehicle.Model))
  3795.                             {
  3796.                                 new Sprite("mpinventory", "mp_specitem_car", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad4Color).Draw();
  3797.                             }
  3798.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_BIKE, ped.CurrentVehicle.Model) || GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_QUADBIKE, ped.CurrentVehicle.Model))
  3799.                             {
  3800.                                 new Sprite("mpinventory", "mp_specitem_bike", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad4Color).Draw();
  3801.                             }
  3802.                             if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_THIS_MODEL_A_HELI, ped.CurrentVehicle.Model))
  3803.                             {
  3804.                                 new Sprite("mpinventory", "mp_specitem_heli", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad4Color).Draw();
  3805.                             }
  3806.                             if (ped.CurrentVehicle.GetPedOnSeat(VehicleSeat.Driver) == ped)
  3807.                             {
  3808.                                 new Sprite("mpinventory", "mp_specitem_steer_wheel", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number + 16), new Size(16, 16), 0f, Squad4Color).Draw();
  3809.                             }
  3810.                         }
  3811.                         else
  3812.                         {
  3813.                             new Sprite("mpinventory", "mp_specitem_ped", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad4Color).Draw();
  3814.                         }
  3815.                         if (ped.Health < 50)
  3816.                         {
  3817.                             new Sprite("helicopterhud", "targetlost", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone + 16, Convert.ToInt32(res.Height) - safe.Y - 364 + number + 16), new Size(16, 16), 0f, Color.Red).Draw();
  3818.                         }
  3819.                     }
  3820.                     else
  3821.                     {
  3822.                         new Sprite("mpinventory", "survival", new Point(Convert.ToInt32(res.Width) - safe.X - pluszone, Convert.ToInt32(res.Height) - safe.Y - 364 + number), new Size(32, 32), 0f, Squad4Color).Draw();
  3823.                     }
  3824.                     number = number + 32;
  3825.                 }
  3826.             }
  3827.         }
  3828.  
  3829.         if (ordersmode > 0)
  3830.         {
  3831.             if (ordersmode == 1 && Squad1.Count > 0)
  3832.             {
  3833.                 World.DrawMarker(MarkerType.UpsideDownCone, (hitcoord + new Vector3(0f, 0f,0.4f)), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0.5f,0.5f,0.5f), Color.Blue, false, false, 0, false, "", "", false);
  3834.                 if (Function.Call<bool>(Hash.IS_DISABLED_CONTROL_JUST_PRESSED, 0, (int)GTA.Control.Attack) || Function.Call<bool>(Hash.IS_DISABLED_CONTROL_JUST_PRESSED, 0, (int)GTA.Control.Attack2))
  3835.                 {
  3836.                     if (CanWeUse(Squad1Leader))
  3837.                     {
  3838.                         ApplyOrder(Squad1Leader);
  3839.                     }
  3840.                     else
  3841.                     {
  3842.                         UI.Notify("Squad 1 does not exist.");
  3843.                     }
  3844.                 }
  3845.                 foreach (Ped ped in Squad1)
  3846.                 {
  3847.                     if (CanWeUse(ped) && ped.IsAlive)
  3848.                     {
  3849.                         World.DrawMarker(MarkerType.UpsideDownCone, (ped.Position + new Vector3(0f, 0f, 1f)), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0.2f, 0.2f, 0.2f), Color.Blue, false, false, 0, false, "", "", false);
  3850.                     }
  3851.                 }
  3852.             }
  3853.             if (ordersmode == 2 && Squad2.Count > 0)
  3854.             {
  3855.                 World.DrawMarker(MarkerType.UpsideDownCone, (hitcoord + new Vector3(0f, 0f,0.4f)), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0.5f, 0.5f, 0.5f), Color.Yellow, false, false, 0, false, "", "", false);
  3856.                 if (Function.Call<bool>(Hash.IS_DISABLED_CONTROL_JUST_PRESSED, 0, (int)GTA.Control.Attack) || Function.Call<bool>(Hash.IS_DISABLED_CONTROL_JUST_PRESSED, 0, (int)GTA.Control.Attack2))
  3857.                 {
  3858.                     if (CanWeUse(Squad2Leader))
  3859.                     {
  3860.                         ApplyOrder(Squad2Leader);
  3861.                     }
  3862.                     else
  3863.                     {
  3864.                         UI.Notify("Squad 2 does not exist.");
  3865.                     }
  3866.                 }
  3867.                 foreach (Ped ped in Squad2)
  3868.                 {
  3869.                     if (CanWeUse(ped) && ped.IsAlive)
  3870.                     {
  3871.                         World.DrawMarker(MarkerType.UpsideDownCone, (ped.Position + new Vector3(0f, 0f, 1f)), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0.2f, 0.2f, 0.2f), Color.Yellow, false, false, 0, false, "", "", false);
  3872.                     }
  3873.                 }
  3874.             }
  3875.             if (ordersmode == 3 && Squad3.Count > 0)
  3876.             {
  3877.                 World.DrawMarker(MarkerType.UpsideDownCone, (hitcoord + new Vector3(0f, 0f, 0.4f)), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0.5f, 0.5f, 0.5f), Color.Green, false, false, 0, false, "", "", false);
  3878.                 if (Function.Call<bool>(Hash.IS_DISABLED_CONTROL_JUST_PRESSED, 0, (int)GTA.Control.Attack) || Function.Call<bool>(Hash.IS_DISABLED_CONTROL_JUST_PRESSED, 0, (int)GTA.Control.Attack2))
  3879.                 {
  3880.                     if (CanWeUse(Squad3Leader))
  3881.                     {
  3882.                         ApplyOrder(Squad3Leader);
  3883.                     }
  3884.                     else
  3885.                     {
  3886.                         UI.Notify("Squad 3 does not exist.");
  3887.                     }
  3888.                 }
  3889.                 foreach (Ped ped in Squad3)
  3890.                 {
  3891.                     if (CanWeUse(ped) && ped.IsAlive)
  3892.                     {
  3893.                         World.DrawMarker(MarkerType.UpsideDownCone, (ped.Position + new Vector3(0f, 0f, 1f)), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0.2f, 0.2f, 0.2f), Color.Green, false, false, 0, false, "", "", false);
  3894.                     }
  3895.                 }
  3896.             }
  3897.  
  3898.             if (ordersmode == 4 && Squad4.Count > 0)
  3899.             {
  3900.                 World.DrawMarker(MarkerType.UpsideDownCone, (hitcoord + new Vector3(0f, 0f, 0.4f)), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0.5f, 0.5f, 0.5f), Squad4Color, false, false, 0, false, "", "", false);
  3901.                 if (Function.Call<bool>(Hash.IS_DISABLED_CONTROL_JUST_PRESSED, 0, (int)GTA.Control.Attack) || Function.Call<bool>(Hash.IS_DISABLED_CONTROL_JUST_PRESSED, 0, (int)GTA.Control.Attack2))
  3902.                 {
  3903.                     if (CanWeUse(Squad4Leader))
  3904.                     {
  3905.                         ApplyOrder(Squad4Leader);
  3906.                     }
  3907.                     else
  3908.                     {
  3909.                         UI.Notify("Squad 3 does not exist.");
  3910.                     }
  3911.                 }
  3912.                 foreach (Ped ped in Squad4)
  3913.                 {
  3914.                     if (CanWeUse(ped) && ped.IsAlive)
  3915.                     {
  3916.                         World.DrawMarker(MarkerType.UpsideDownCone, (ped.Position + new Vector3(0f, 0f, 1f)), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0.2f, 0.2f, 0.2f), Squad4Color, false, false, 0, false, "", "", false);
  3917.                     }
  3918.                 }
  3919.             }
  3920.             Raycastshit();
  3921.             Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)GTA.Control.Attack2, true);
  3922.             Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)GTA.Control.Attack, true);
  3923.             Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)GTA.Control.VehicleAttack, true);
  3924.             Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)GTA.Control.VehicleAttack2, true);
  3925.             Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)GTA.Control.VehiclePassengerAttack, true);
  3926.         }
  3927.     }
  3928.  
  3929.  
  3930.  
  3931.     void OnKeyDown(object sender, KeyEventArgs e)
  3932.     {
  3933.         if (e.KeyCode == MenuKey && !_menuPool.IsAnyMenuOpen()) // Our menu on/off switch
  3934.         {
  3935.             if (SlowTimeWhenManaging || (WantedSlowsTime && Game.Player.WantedLevel !=0) || (CombatSlowsTime && (IsInCombat(Game.Player.Character) || IsAnySquadMemberInCombat())) || (HalfHealthSlowsTime && Game.Player.Character.Health < 50))
  3936.             {
  3937.                 Game.TimeScale = TimeScale;
  3938.             }
  3939.  
  3940.             mainMenu.Visible = !mainMenu.Visible;
  3941.         }
  3942.     }
  3943.  
  3944.     void OnKeyUp(object sender, KeyEventArgs e)
  3945.     {
  3946.  
  3947.         //ENTER AS PASSENGER
  3948.         if (e.KeyCode == EnterAsPassengerKey && Game.Player.Character.IsStopped && EnterAsPassengerEnabled)
  3949.         {
  3950.             var nearbymounts = World.GetClosestVehicle(Game.Player.Character.Position, 10);
  3951.             if (CanWeUse(nearbymounts) && (nearbymounts.GetPedOnSeat(VehicleSeat.Driver) == Squad1Leader || nearbymounts.GetPedOnSeat(VehicleSeat.Driver) == Squad2Leader || nearbymounts.GetPedOnSeat(VehicleSeat.Driver) == Squad3Leader || nearbymounts.GetPedOnSeat(VehicleSeat.Driver) == Squad3Leader))
  3952.             {
  3953.                 int max_seats = GTA.Native.Function.Call<int>(GTA.Native.Hash.GET_VEHICLE_MAX_NUMBER_OF_PASSENGERS, nearbymounts);
  3954.                 for (int i = -1; i < max_seats; i++)
  3955.                 {
  3956.                     if (GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_VEHICLE_SEAT_FREE, nearbymounts, i))
  3957.                     {
  3958.                         GTA.Native.Function.Call<bool>(GTA.Native.Hash.TASK_ENTER_VEHICLE, Game.Player.Character, nearbymounts, -1, i, 2.0, 1, 0);
  3959.                         break;
  3960.                     }
  3961.                 }
  3962.             }
  3963.         }
  3964.        
  3965.         //HANDLE ORDERS MODE
  3966.         if (e.KeyCode == OrdersModeKey)
  3967.         {
  3968.             if (SlowTimeWhenManaging || (WantedSlowsTime && Game.Player.WantedLevel>0 ) || (CombatSlowsTime && (IsInCombat(Game.Player.Character) || IsAnySquadMemberInCombat())) || (HalfHealthSlowsTime && Game.Player.Character.Health<50))
  3969.             {
  3970.                 Game.TimeScale = TimeScale;
  3971.             }
  3972.  
  3973.             ordersmode++;
  3974.  
  3975.             if ((ordersmode == 1 && Squad1.Count == 0))
  3976.             {
  3977.                 ordersmode++;
  3978.  
  3979.             }
  3980.             if ((ordersmode == 2 && Squad2.Count == 0))
  3981.             {
  3982.                 ordersmode++;
  3983.             }
  3984.             if ((ordersmode == 3 && Squad3.Count == 0))
  3985.             {
  3986.                 ordersmode++;
  3987.             }
  3988.             if ((ordersmode == 4 && Squad4.Count == 0))
  3989.             {
  3990.                 ordersmode++;
  3991.             }
  3992.             if ((!CanWeUse(Squad2Leader) && !CanWeUse(Squad1Leader) && !CanWeUse(Squad3Leader) && !CanWeUse(Squad4Leader)))
  3993.             {
  3994.                 Game.TimeScale = 1;
  3995.                 ordersmode = 0;
  3996.             }
  3997.             if (ordersmode > 4)
  3998.             {
  3999.                 Game.TimeScale = 1;
  4000.                 ordersmode = 0;
  4001.             }
  4002.         }
  4003.     }
  4004.  
  4005.  
  4006.    
  4007.     ////////////////////////////// UTILITY FUNCTIONS //////////////////////////////
  4008.  
  4009.     bool CanWeUse(Entity entity)
  4010.     {
  4011.         return entity != null && entity.Exists();
  4012.     }
  4013.     void SetDrivingStyleAndCruiseSpeed(Ped ped, int drivingstyle, float cruisespeed)
  4014.     {
  4015.         Function.Call(Hash.SET_DRIVE_TASK_CRUISE_SPEED, ped, cruisespeed);
  4016.         Function.Call(Hash.SET_DRIVE_TASK_DRIVING_STYLE, ped, drivingstyle);
  4017.     }
  4018.     bool IsAnySquadMemberInCombat()
  4019.     {
  4020.         if ((CanWeUse(Squad1Leader) && Squad1Leader.IsInCombat) || (CanWeUse(Squad2Leader) && Squad2Leader.IsInCombat) || (CanWeUse(Squad3Leader) && Squad3Leader.IsInCombat) || (CanWeUse(Squad4Leader) && Squad4Leader.IsInCombat))
  4021.         {
  4022.             return true;
  4023.         }
  4024.         return false;
  4025.     }
  4026.  
  4027.  
  4028.     bool IsInCombat(Ped ped)
  4029.     {
  4030.         foreach (Ped target in World.GetAllPeds())
  4031.         {
  4032.             if (target.IsAlive && GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_PED_IN_COMBAT, target, ped))
  4033.             {
  4034.                 return true;
  4035.             }
  4036.         }
  4037.         return false;
  4038.     }
  4039.     void HandleAirCombat(Ped RecieveOrder)
  4040.     {
  4041.         if (CanWeUse(RecieveOrder) && RecieveOrder.IsSittingInVehicle())
  4042.         {
  4043.             if (RecieveOrder.CurrentVehicle.Model == (Model)VehicleHash.Savage)
  4044.             {
  4045.                 if (RecieveOrder.IsInCombat && GetRandomInt(1, 30) == 1)
  4046.                 {
  4047.                     foreach (Ped target in World.GetAllPeds())
  4048.                     {
  4049.                         if (target.IsAlive && GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_PED_IN_COMBAT, RecieveOrder, target) && GTA.Native.Function.Call<Vector3>(GTA.Native.Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, RecieveOrder, target.Position.X, target.Position.Y, target.Position.Z).Y > -10)
  4050.                         {
  4051.                             Vector3 Velocity = new Vector3(GetRandomInt(-2, 2), GetRandomInt(-2, 2), 0);
  4052.                             if (target.Velocity.Length() > 10f)
  4053.                             {
  4054.                                 Velocity = Velocity + RecieveOrder.Velocity - target.Velocity;
  4055.                             }
  4056.                             GTA.Native.Function.Call(GTA.Native.Hash.SET_VEHICLE_SHOOT_AT_TARGET, RecieveOrder, 0, target.Position.X + Velocity.X, target.Position.Y + Velocity.Y, target.Position.Z);
  4057.                         }
  4058.                     }
  4059.                 }
  4060.             }
  4061.             if (RecieveOrder.CurrentVehicle.Model == (Model)VehicleHash.Annihilator)
  4062.             {
  4063.                 if (RecieveOrder.IsInCombat)
  4064.                 {
  4065.                     foreach (Ped target in World.GetAllPeds())
  4066.                     {
  4067.                         if (target.IsAlive && GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_PED_IN_COMBAT, RecieveOrder, target) && GTA.Native.Function.Call<Vector3>(GTA.Native.Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, RecieveOrder, target.Position.X, target.Position.Y, target.Position.Z).Y > 30)
  4068.                         {
  4069.                             Vector3 Velocity = new Vector3(GetRandomInt(-2, 2), GetRandomInt(-2, 2), 0);
  4070.                             if (target.Velocity.Length() > 10f)
  4071.                             {
  4072.                                 Velocity = Velocity + RecieveOrder.Velocity - target.Velocity;
  4073.                             }
  4074.                             GTA.Native.Function.Call(GTA.Native.Hash.SET_VEHICLE_SHOOT_AT_TARGET, RecieveOrder, 0, target.Position.X + Velocity.X, target.Position.Y + Velocity.Y, target.Position.Z);
  4075.                         }
  4076.                     }
  4077.                 }
  4078.             }
  4079.             if (RecieveOrder.CurrentVehicle.Model == (Model)VehicleHash.Buzzard)
  4080.             {
  4081.                 if (RecieveOrder.IsInCombat)
  4082.                 {
  4083.                     foreach (Ped target in World.GetAllPeds())
  4084.                     {
  4085.                         if (target.IsAlive && GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_PED_IN_COMBAT, RecieveOrder, target) && GTA.Native.Function.Call<Vector3>(GTA.Native.Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, RecieveOrder, target.Position.X, target.Position.Y, target.Position.Z).Y > 30)
  4086.                         {
  4087.                             Vector3 Velocity = new Vector3(GetRandomInt(-2, 2), GetRandomInt(-2, 2), 0);
  4088.                             if (target.Velocity.Length() > 10f)
  4089.                             {
  4090.                                 Velocity = Velocity + RecieveOrder.Velocity - target.Velocity;
  4091.                             }
  4092.                             GTA.Native.Function.Call(GTA.Native.Hash.SET_VEHICLE_SHOOT_AT_TARGET, RecieveOrder, 0, target.Position.X + Velocity.X, target.Position.Y + Velocity.Y, target.Position.Z);
  4093.                         }
  4094.                     }
  4095.                 }
  4096.             }
  4097.             if (RecieveOrder.CurrentVehicle.Model == (Model)VehicleHash.Valkyrie)
  4098.             {
  4099.                 if (RecieveOrder.IsInCombat && GetRandomInt(1, 30) == 1)
  4100.                 {
  4101.                     if (CanWeUse(RecieveOrder.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightFront)))
  4102.                     {
  4103.                         foreach (Ped target in World.GetAllPeds())
  4104.                         {
  4105.                             if (target.IsAlive && GTA.Native.Function.Call<bool>(GTA.Native.Hash.IS_PED_IN_COMBAT, RecieveOrder, target))
  4106.                             {
  4107.                                 Vector3 Velocity = new Vector3(GetRandomInt(-5, 5), GetRandomInt(-5, 5), 0);
  4108.                                 if (target.Velocity.Length() > 10f)
  4109.                                 {
  4110.                                     Velocity = Velocity + Squad1Leader.Velocity - target.Velocity;
  4111.                                 }
  4112.                                 GTA.Native.Function.Call(GTA.Native.Hash.SET_VEHICLE_SHOOT_AT_TARGET, RecieveOrder.CurrentVehicle.GetPedOnSeat(VehicleSeat.RightFront), 0, target.Position.X + Velocity.X, target.Position.Y + Velocity.Y, target.Position.Z);
  4113.                             }
  4114.                         }
  4115.                     }
  4116.                 }
  4117.             }
  4118.         }
  4119.     }
  4120.  
  4121.  
  4122.     void Squad1GroupFix()
  4123.     {
  4124.         Squad1Group = Function.Call<int>(Hash.CREATE_GROUP);
  4125.         foreach (Ped ped in Squad1)
  4126.         {
  4127.             //UI.Notify(Squad1.Count.ToString());
  4128.             Function.Call(Hash.REMOVE_PED_FROM_GROUP, ped.Handle);
  4129.             Function.Call(Hash.SET_PED_NEVER_LEAVES_GROUP, ped.Handle, 1);
  4130.             if (ped == Squad1Leader)
  4131.             {
  4132.                 Function.Call(Hash.SET_PED_AS_GROUP_LEADER, ped.Handle, Squad1Group);
  4133.             }
  4134.             else
  4135.             {
  4136.                 Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, ped, Squad1Group);
  4137.             }
  4138.         }
  4139.     }
  4140.  
  4141.     void Squad2GroupFix()
  4142.     {
  4143.         Squad2Group = Function.Call<int>(Hash.CREATE_GROUP);
  4144.         foreach (Ped ped in Squad2)
  4145.         {
  4146.             Function.Call(Hash.REMOVE_PED_FROM_GROUP, ped.Handle);
  4147.             Function.Call(Hash.SET_PED_NEVER_LEAVES_GROUP, ped.Handle, 1);
  4148.             if (ped == Squad2Leader)
  4149.             {
  4150.                 Function.Call(Hash.SET_PED_AS_GROUP_LEADER, ped.Handle, Squad2Group);
  4151.             }
  4152.             else
  4153.             {
  4154.                 Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, ped, Squad2Group);
  4155.             }
  4156.         }
  4157.     }
  4158.  
  4159.  
  4160.     void Squad3GroupFix()
  4161.     {
  4162.         Squad3Group = Function.Call<int>(Hash.CREATE_GROUP);
  4163.         foreach (Ped ped in Squad3)
  4164.         {
  4165.             Function.Call(Hash.REMOVE_PED_FROM_GROUP, ped.Handle);
  4166.             Function.Call(Hash.SET_PED_NEVER_LEAVES_GROUP, ped.Handle, 1);
  4167.             if (ped == Squad3Leader)
  4168.             {
  4169.                 Function.Call(Hash.SET_PED_AS_GROUP_LEADER, ped.Handle, Squad3Group);
  4170.             }
  4171.             else
  4172.             {
  4173.                 Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, ped, Squad3Group);
  4174.             }
  4175.         }
  4176.     }
  4177.  
  4178.     void Squad4GroupFix()
  4179.     {
  4180.         Squad4Group = Function.Call<int>(Hash.CREATE_GROUP);
  4181.         foreach (Ped ped in Squad4)
  4182.         {
  4183.             Function.Call(Hash.REMOVE_PED_FROM_GROUP, ped.Handle);
  4184.             Function.Call(Hash.SET_PED_NEVER_LEAVES_GROUP, ped.Handle, 1);
  4185.             if (ped == Squad4Leader)
  4186.             {
  4187.                 Function.Call(Hash.SET_PED_AS_GROUP_LEADER, ped.Handle, Squad4Group);
  4188.             }
  4189.             else
  4190.             {
  4191.                 Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, ped, Squad4Group);
  4192.             }
  4193.         }
  4194.     }
  4195.     void PrepareSquadLeader(Ped Squadleader, List<Entity> Squad)
  4196.     {
  4197.         string Style = "";
  4198.  
  4199.         if (Squad == Squad1)
  4200.         {
  4201.             Style = DrivingStyleSquad1.IndexToItem(DrivingStyleSquad1.Index).ToString();
  4202.         }
  4203.         if (Squad == Squad2)
  4204.         {
  4205.             Style = DrivingStyleSquad2.IndexToItem(DrivingStyleSquad2.Index).ToString();
  4206.         }
  4207.         if (Squad == Squad3)
  4208.         {
  4209.             Style = DrivingStyleSquad3.IndexToItem(DrivingStyleSquad3.Index).ToString();
  4210.         }
  4211.         if (Squad == Squad4)
  4212.         {
  4213.             Style = DrivingStyleSquad4.IndexToItem(DrivingStyleSquad4.Index).ToString();
  4214.         }
  4215.         if (Style == "Careful")
  4216.         {
  4217.             DrivingCareful.Add(Squadleader);
  4218.             Function.Call(Hash.SET_DRIVE_TASK_CRUISE_SPEED, Squadleader, 30f);
  4219.             Function.Call(Hash.SET_DRIVE_TASK_DRIVING_STYLE, Squadleader, 1 | 2 | 4 | 16 | 32);
  4220.  
  4221.         }
  4222.         if (Style == "Normal")
  4223.         {
  4224.  
  4225.             DrivingNormal.Add(Squadleader);
  4226.             Function.Call(Hash.SET_DRIVE_TASK_CRUISE_SPEED, Squadleader, 40f);
  4227.             Function.Call(Hash.SET_DRIVE_TASK_DRIVING_STYLE, Squadleader, 1 | 2 | 4 | 16 | 32);
  4228.         }
  4229.         if (Style == "Fast & Furious")
  4230.         {
  4231.             DrivingFurious.Add(Squadleader);
  4232.             Function.Call(Hash.SET_DRIVE_TASK_CRUISE_SPEED, Squadleader, 80f);
  4233.             Function.Call(Hash.SET_DRIVE_TASK_DRIVING_STYLE, Squadleader, 4 | 16 | 32);
  4234.         }
  4235.     }
  4236.  
  4237.  
  4238.     void Raycastshit()
  4239.     {
  4240.         {
  4241.             RaycastResult RayCast;
  4242.  
  4243.             RayCast = this.Cam_Raycast_Forward();
  4244.             if (RayCast.DitHitAnything)
  4245.             {
  4246.                 hitcoord = RayCast.HitCoords;
  4247.                 entitihit = RayCast.HitEntity;
  4248.             }
  4249.             else
  4250.             {
  4251.                 Vector3 camrot = Function.Call<Vector3>(Hash.GET_GAMEPLAY_CAM_ROT, 0);
  4252.                 Vector3 campos = Function.Call<Vector3>(Hash.GET_GAMEPLAY_CAM_COORD);
  4253.                 hitcoord = camrot + new Vector3(RotToDir(camrot).X * 1000.0f, RotToDir(camrot).Y * 1000.0f, RotToDir(camrot).Z * 1000.0f);
  4254.             }