Advertisement
Guest User

Simple Passenger Mod V1.2 Source

a guest
May 16th, 2015
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.89 KB | None | 0 0
  1. // https://www.gta5-mods.com/scripts/simple-passenger-mod
  2. // By: Rooft0p
  3.  
  4. using GTA;
  5. using GTA.Math;
  6. using GTA.Native;
  7. using System;
  8. using System.Windows.Forms;
  9.  
  10. namespace Moochaka
  11. {
  12.   public class Passenger : Script
  13.   {
  14.     private bool ModOn;
  15.     private bool driving;
  16.     private bool WPactive;
  17.     private bool MH;
  18.     private bool Speed;
  19.     private Keys EnterVehicle;
  20.     private Keys ExitVehicle;
  21.     private Keys Drive;
  22.     private Keys Mayhem;
  23.     private Keys skipRadio;
  24.  
  25.     public Passenger()
  26.     {
  27.       base.\u002Ector();
  28.       this.EnterVehicle = Keys.E;
  29.       this.ExitVehicle = Keys.F;
  30.       this.Drive = Keys.Space;
  31.       this.Mayhem = Keys.Delete;
  32.       this.skipRadio = Keys.Q;
  33.       this.add_KeyDown(new KeyEventHandler(this.Passenger_KeyDown));
  34.       this.add_Tick(new EventHandler(this.Passenger_Tick));
  35.     }
  36.  
  37.     private void Passenger_Tick(object sender, EventArgs e)
  38.     {
  39.       Ped character = Game.get_Player().get_Character();
  40.       character.get_CurrentVehicle();
  41.       this.WPactive = Function.Call<bool>((Hash) 2148768492990438821, new InputArgument[0]) != null;
  42.       if (this.ModOn && this.driving && !this.WPactive)
  43.         this.EndRoute();
  44.       if (!character.IsInVehicle())
  45.       {
  46.         this.ModOn = false;
  47.         this.driving = false;
  48.         this.MH = false;
  49.         this.Speed = false;
  50.       }
  51.       if (!((Entity) character).get_IsDead())
  52.         return;
  53.       this.ModOn = false;
  54.       this.driving = false;
  55.       this.MH = false;
  56.       this.Speed = false;
  57.     }
  58.  
  59.     private void Passenger_KeyDown(object sender, KeyEventArgs e)
  60.     {
  61.       if (e.KeyCode == this.EnterVehicle)
  62.       {
  63.         Ped character = Game.get_Player().get_Character();
  64.         Vehicle closestVehicle = World.GetClosestVehicle(((Entity) character).get_Position(), 12f);
  65.         Vehicle currentVehicle = character.get_CurrentVehicle();
  66.         if (!character.IsInVehicle() && ((Entity) closestVehicle).Exists())
  67.         {
  68.           character.get_Task().EnterVehicle(closestVehicle, (VehicleSeat) 0);
  69.           character.set_CanBeDraggedOutOfVehicle(false);
  70.           this.Print("Enter Vehicle as Passenger", 7000);
  71.           Script.Wait(5000);
  72.           this.Print(closestVehicle.get_DisplayName(), 3000);
  73.           this.ModOn = true;
  74.         }
  75.         else
  76.         {
  77.           if (!this.ModOn || !((Entity) currentVehicle).Exists())
  78.             return;
  79.           character.get_Task().ShuffleToNextVehicleSeat(currentVehicle);
  80.           character.set_CanBeDraggedOutOfVehicle(false);
  81.           this.Print("Switch Seats", 5000);
  82.           this.ModOn = false;
  83.           this.driving = false;
  84.           this.MH = false;
  85.           this.Speed = false;
  86.         }
  87.       }
  88.       else if (e.KeyCode == this.ExitVehicle)
  89.       {
  90.         Ped character = Game.get_Player().get_Character();
  91.         Vehicle currentVehicle = character.get_CurrentVehicle();
  92.         if (!((Entity) currentVehicle).Exists() || !character.IsInVehicle(currentVehicle) || !this.ModOn)
  93.           return;
  94.         this.ModOn = false;
  95.         this.driving = false;
  96.         this.MH = false;
  97.         this.Speed = false;
  98.       }
  99.       else if (e.KeyCode == this.Drive)
  100.       {
  101.         Ped character = Game.get_Player().get_Character();
  102.         Vehicle currentVehicle = character.get_CurrentVehicle();
  103.         if (this.ModOn && character.IsInVehicle() && (Function.Call<bool>((Hash) 2148768492990438821, new InputArgument[0]) != null && !this.Speed))
  104.         {
  105.           Vector3 vector3 = (Vector3) Function.Call<Vector3>((Hash) 6371184173552343406, new InputArgument[1]
  106.           {
  107.             InputArgument.op_Implicit((int) Function.Call<int>((Hash) 2012513321047894559, new InputArgument[1]
  108.             {
  109.               InputArgument.op_Implicit((int) Function.Call<int>((Hash) 1760446918642962045, new InputArgument[1]
  110.               {
  111.                 InputArgument.op_Implicit(true)
  112.               }))
  113.             }))
  114.           });
  115.           Ped[] nearbyPeds = World.GetNearbyPeds(Game.get_Player().get_Character(), 10f);
  116.           for (int index = 0; index <= 0; ++index)
  117.           {
  118.             if (((Entity) nearbyPeds[index]).Exists() && nearbyPeds[index].IsInVehicle(currentVehicle))
  119.             {
  120.               nearbyPeds[index].get_Task().ParkVehicle(currentVehicle, vector3, ((Entity) character).get_Heading());
  121.               this.Print("Drive To Waypoint", 4000);
  122.               Function.Call((Hash) 7477453855356397301, new InputArgument[4]
  123.               {
  124.                 InputArgument.op_Implicit(-1),
  125.                 InputArgument.op_Implicit("NAV_UP_DOWN"),
  126.                 InputArgument.op_Implicit("HUD_FRONTEND_DEFAULT_SOUNDSET"),
  127.                 InputArgument.op_Implicit(0)
  128.               });
  129.               this.driving = true;
  130.               this.Speed = true;
  131.             }
  132.           }
  133.         }
  134.         else
  135.         {
  136.           if (!this.ModOn || !character.IsInVehicle() || (Function.Call<bool>((Hash) 2148768492990438821, new InputArgument[0]) == null || !this.Speed))
  137.             return;
  138.           Vector3 vector3 = (Vector3) Function.Call<Vector3>((Hash) 6371184173552343406, new InputArgument[1]
  139.           {
  140.             InputArgument.op_Implicit((int) Function.Call<int>((Hash) 2012513321047894559, new InputArgument[1]
  141.             {
  142.               InputArgument.op_Implicit((int) Function.Call<int>((Hash) 1760446918642962045, new InputArgument[1]
  143.               {
  144.                 InputArgument.op_Implicit(true)
  145.               }))
  146.             }))
  147.           });
  148.           Ped[] nearbyPeds = World.GetNearbyPeds(Game.get_Player().get_Character(), 10f);
  149.           for (int index = 0; index <= 0; ++index)
  150.           {
  151.             if (((Entity) nearbyPeds[index]).Exists() && nearbyPeds[index].IsInVehicle(currentVehicle))
  152.             {
  153.               nearbyPeds[index].get_Task().DriveTo(currentVehicle, vector3, 10f, 23f, 7);
  154.               this.Print("Drive To Waypoint (Fast)", 4000);
  155.               Function.Call((Hash) 7477453855356397301, new InputArgument[4]
  156.               {
  157.                 InputArgument.op_Implicit(-1),
  158.                 InputArgument.op_Implicit("NAV_UP_DOWN"),
  159.                 InputArgument.op_Implicit("HUD_FRONTEND_DEFAULT_SOUNDSET"),
  160.                 InputArgument.op_Implicit(0)
  161.               });
  162.               this.driving = true;
  163.               this.Speed = false;
  164.             }
  165.           }
  166.         }
  167.       }
  168.       else if (e.KeyCode == this.Mayhem)
  169.       {
  170.         Vehicle currentVehicle = Game.get_Player().get_Character().get_CurrentVehicle();
  171.         Ped[] nearbyPeds = World.GetNearbyPeds(Game.get_Player().get_Character(), 10f);
  172.         for (int index = 0; index <= 0; ++index)
  173.         {
  174.           if (((Entity) currentVehicle).Exists() && nearbyPeds[index].IsInVehicle(currentVehicle) && (this.ModOn && !this.MH))
  175.           {
  176.             nearbyPeds[index].set_BlockPermanentEvents(true);
  177.             nearbyPeds[index].get_Task().CruiseWithVehicle(currentVehicle, 38f, 6);
  178.             this.MH = true;
  179.             this.driving = false;
  180.             this.Speed = false;
  181.             Function.Call((Hash) 7477453855356397301, new InputArgument[4]
  182.             {
  183.               InputArgument.op_Implicit(-1),
  184.               InputArgument.op_Implicit("NAV_UP_DOWN"),
  185.               InputArgument.op_Implicit("HUD_FRONTEND_DEFAULT_SOUNDSET"),
  186.               InputArgument.op_Implicit(0)
  187.             });
  188.             this.Print("Drive By Enabled", 4000);
  189.           }
  190.           else if (((Entity) currentVehicle).Exists() && nearbyPeds[index].IsInVehicle(currentVehicle) && (this.ModOn && this.MH))
  191.           {
  192.             nearbyPeds[index].set_BlockPermanentEvents(false);
  193.             nearbyPeds[index].get_Task().CruiseWithVehicle(currentVehicle, 16f, 1);
  194.             this.MH = false;
  195.             this.driving = false;
  196.             this.Speed = false;
  197.             Function.Call((Hash) 7477453855356397301, new InputArgument[4]
  198.             {
  199.               InputArgument.op_Implicit(-1),
  200.               InputArgument.op_Implicit("NAV_UP_DOWN"),
  201.               InputArgument.op_Implicit("HUD_FRONTEND_DEFAULT_SOUNDSET"),
  202.               InputArgument.op_Implicit(0)
  203.             });
  204.             this.Print("Drive By Disabled", 4000);
  205.           }
  206.         }
  207.       }
  208.       else
  209.       {
  210.         if (e.KeyCode != this.skipRadio)
  211.           return;
  212.         Vehicle currentVehicle = Game.get_Player().get_Character().get_CurrentVehicle();
  213.         Ped[] nearbyPeds = World.GetNearbyPeds(Game.get_Player().get_Character(), 4f);
  214.         for (int index = 0; index <= 0; ++index)
  215.         {
  216.           if (this.ModOn && ((Entity) nearbyPeds[index]).Exists() && nearbyPeds[index].IsInVehicle(currentVehicle))
  217.           {
  218.             Function.Call((Hash) 7916129512124750885, new InputArgument[0]);
  219.             this.Print("Skip Radio", 2000);
  220.           }
  221.         }
  222.       }
  223.     }
  224.  
  225.     private void EndRoute()
  226.     {
  227.       Vehicle currentVehicle = Game.get_Player().get_Character().get_CurrentVehicle();
  228.       Ped[] nearbyPeds = World.GetNearbyPeds(Game.get_Player().get_Character(), 4f);
  229.       for (int index = 0; index <= 0; ++index)
  230.       {
  231.         if (((Entity) nearbyPeds[index]).Exists() && nearbyPeds[index].IsInVehicle(currentVehicle))
  232.         {
  233.           this.driving = false;
  234.           this.MH = false;
  235.           this.Speed = false;
  236.           Script.Wait(10000);
  237.           nearbyPeds[index].get_Task().CruiseWithVehicle(currentVehicle, 16f, 1);
  238.         }
  239.       }
  240.     }
  241.  
  242.     private void Print(string text, int time = 2000)
  243.     {
  244.       Function.Call((Hash) -5153745325143710083, new InputArgument[1]
  245.       {
  246.         InputArgument.op_Implicit("STRING")
  247.       });
  248.       Function.Call((Hash) 7789129354908300458, new InputArgument[1]
  249.       {
  250.         InputArgument.op_Implicit(text)
  251.       });
  252.       Function.Call((Hash) -7100200333308705802, new InputArgument[2]
  253.       {
  254.         InputArgument.op_Implicit(time),
  255.         InputArgument.op_Implicit(1)
  256.       });
  257.     }
  258.   }
  259. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement