public void prepareVehicle(Vehicle vehicle)
 {
     if (vehicle.Exists())
     {
         vehicle.EngineRunning = true;
         vehicle.InteriorLightOn = true;
         vehicle.HazardLightsOn = true;
         vehicle.Repair();
     }
 }
Esempio n. 2
0
        public static Vehicle[] GetNearbyVehicles(Ped ped, float radius, params Model[] models)
        {
            List <Vehicle> list           = new List <Vehicle>();
            Vehicle        currentVehicle = ped.CurrentVehicle;
            int            num3           = Vehicle.Exists(currentVehicle) ? currentVehicle.Handle : 0;

            foreach (int num2 in MemoryAccess.GetVehicleHandles(ped.Position, radius, ModelListToHashList(models)))
            {
                if (num2 != num3)
                {
                    list.Add(new Vehicle(num2));
                }
            }
            return(list.ToArray());
        }
Esempio n. 3
0
		public static Vehicle[] GetNearbyVehicles(Ped ped, float radius, params Model[] models)
		{
			int[] handles = MemoryAccess.GetVehicleHandles(ped.Position, radius, ModelListToHashList(models));

			var result = new List<Vehicle>();
			Vehicle ignore = ped.CurrentVehicle;
			int ignoreHandle = Vehicle.Exists(ignore) ? ignore.Handle : 0;

			foreach (int handle in handles)
			{
				if (handle == ignoreHandle)
				{
					continue;
				}

				result.Add(new Vehicle(handle));
			}

			return result.ToArray();
		}
Esempio n. 4
0
        /// <summary>
        /// Called every tick to process all plugin logic.
        /// </summary>
        public override void Process()
        {
            // If on duty and Z is down
            if (LPlayer.LocalPlayer.IsOnDuty && (Functions.IsKeyDown(Keys.Z) || (Functions.IsControllerInUse() && Functions.IsControllerKeyDown(GamepadButtonFlags.DPadRight))))
            {
                DelayedCaller.Call(
                    delegate
                {
                    LPlayer.LocalPlayer.Ped.DrawTextAboveHead("Test", 500);
                },
                    this,
                    500);

                if (this.lcpdfrPed == null || this.lcpdfrPed.Exists() || this.lcpdfrPed.IsAliveAndWell)
                {
                    // Create a ped
                    this.lcpdfrPed = new LPed(LPlayer.LocalPlayer.Ped.Position, "F_Y_HOOKER_01");
                    this.lcpdfrPed.NoLongerNeeded();
                    this.lcpdfrPed.AttachBlip();
                    this.lcpdfrPed.ItemsCarried = LPed.EPedItem.Drugs;
                    LPed.EPedItem item = this.lcpdfrPed.ItemsCarried;
                    this.lcpdfrPed.PersonaData = new PersonaData(DateTime.Now, 0, "Sam", "T", false, 1337, true);
                }
            }

            // If our ped exists and has been arrested, kill it
            if (this.lcpdfrPed != null && this.lcpdfrPed.Exists())
            {
                if (this.lcpdfrPed.HasBeenArrested && this.lcpdfrPed.IsAliveAndWell)
                {
                    this.lcpdfrPed.Die();
                }
            }

            if (Functions.IsKeyDown(Keys.B))
            {
                if (Functions.IsPlayerPerformingPullover())
                {
                    LHandle pullover = Functions.GetCurrentPullover();
                    if (pullover != null)
                    {
                        LVehicle vehicle = Functions.GetPulloverVehicle(pullover);
                        if (vehicle != null && vehicle.Exists())
                        {
                            vehicle.AttachBlip().Color = BlipColor.Cyan;
                            if (vehicle.HasDriver)
                            {
                                // Change name of driver to Sam T.
                                LPed driver = vehicle.GetPedOnSeat(VehicleSeat.Driver);
                                if (driver != null && driver.Exists())
                                {
                                    // Modify name.
                                    driver.PersonaData = new PersonaData(DateTime.Now, 0, "Sam", "T", true, 0, false);

                                    string name = driver.PersonaData.FullName;
                                    Functions.PrintText("--- Pulling over: " + name + " ---", 10000);

                                    // Looking up the driver will make the vehicle explode.
                                    Functions.PedLookedUpInPoliceComputer += delegate(PersonaData data)
                                    {
                                        if (data.FullName == name)
                                        {
                                            DelayedCaller.Call(delegate { if (vehicle.Exists())
                                                                          {
                                                                              vehicle.Explode();
                                                                          }
                                                               }, this, Common.GetRandomValue(5000, 10000));
                                        }
                                    };
                                }
                            }
                        }
                    }
                }
                else
                {
                    // Disable pullovers for vehicle in front.
                    GTA.Vehicle vehicle = World.GetClosestVehicle(LPlayer.LocalPlayer.Ped.GetOffsetPosition(new Vector3(0, 10, 0)), 5f);
                    if (vehicle != null && vehicle.Exists())
                    {
                        LVehicle veh = LVehicle.FromGTAVehicle(vehicle);
                        if (veh != null)
                        {
                            veh.DisablePullover = true;
                            veh.AttachBlip();
                        }
                    }
                }
            }

            // Kill all partners.
            if (Functions.IsKeyDown(Keys.N))
            {
                LHandle partnerManger = Functions.GetCurrentPartner();
                LPed[]  peds          = Functions.GetPartnerPeds(partnerManger);
                if (peds != null)
                {
                    foreach (LPed partner in peds)
                    {
                        if (partner.Exists())
                        {
                            partner.Die();
                        }
                    }
                }
            }

            // Send RequestBackup message in network game.
            if (Functions.IsKeyDown(Keys.X))
            {
                if (Networking.IsInSession && Networking.IsConnected)
                {
                    if (Networking.IsHost)
                    {
                        Vector3 position = LPlayer.LocalPlayer.Ped.Position;

                        // Tell client we need backup.
                        DynamicData dynamicData = new DynamicData(Networking.GetServerInstance());
                        dynamicData.Write(position);
                        Networking.GetServerInstance().Send("API_Example", ENetworkMessages.RequestBackup, dynamicData);
                    }
                }
            }
        }
Esempio n. 5
0
 void OnKeyDown(object sender, KeyEventArgs e)
 {
     Keys activateKeyVal = (Keys)Enum.Parse(typeof(Keys), activate);
     if (e.KeyCode == activateKeyVal)
     {
         if (showGUI)
         {
             showGUI = false;
         }
         if (active)
         {
             active = false;
         }
         else
         {
             rectWidth = 0.1268f;
             Random rnd = new Random();
             int r = rnd.Next(Flags.allFlags.Count);
             flag = Flags.allFlags[r];
             closestVeh = World.GetClosestVehicle(player.GetOffsetInWorldCoords(new Vector3(0, 4, 0)), 5);
             pedDriver = closestVeh.GetPedOnSeat(VehicleSeat.Driver);
             vehModel = closestVeh.DisplayName;
             //vehModel = closestVeh.Model.ToString();
             vehID = closestVeh.Handle.ToString();
             if (Function.Call<bool>(Hash._IS_HEADLIGHT_R_BROKEN, closestVeh))
             {
                 flag = flag + "\n~b~Right Headlight Broke";
                 rectWidth = 0.1568f;
             }
             if (Function.Call<bool>(Hash._IS_HEADLIGHT_L_BROKEN, closestVeh))
             {
                 flag = flag + "\n~b~Left Headlight Broke";
                 rectWidth = 0.1568f;
             }
             if (Function.Call<bool>(Hash._IS_HEADLIGHT_L_BROKEN, closestVeh) && Function.Call<bool>(Hash._IS_HEADLIGHT_R_BROKEN, closestVeh))
             {
                 rectWidth = 0.1868f;
             }
             if (closestVeh.Exists())
             {
                 UI.Notify("~b~" + name + ": ~s~" + "Dispatch, can I get a vehicle check on \n" + "~b~Model: " + vehModel + "\n" + "PLATE: " + closestVeh.NumberPlate);
                 Wait(2000);
                 UI.Notify("~b~Dispatch: ~s~Affirmitive, standby.");
                 Wait(4000);
                 UI.Notify("~b~Dispatch: ~s~Information sent to you.");
                 Wait(100);
                 active = true;
                 showGUI = true;
                 Wait(1000);
                 UI.Notify("~b~" + name + ": ~s~Thank you.");
             }
             else
             {
                 UI.Notify("No vehicle found, get closer!");
             }
         }
     }
 }