Пример #1
0
        public static async Task PocceCompanion()
        {
            int ped;
            int player = Game.Player.Character.Handle;

            if (API.IsPedInAnyVehicle(player, false))
            {
                var vehicle = API.GetVehiclePedIsIn(player, false);
                if (Vehicles.GetFreeSeat(vehicle, out int seat))
                {
                    var pocce = Config.PocceList[API.GetRandomIntInRange(0, Config.PocceList.Length)];
                    await Common.RequestModel(pocce);

                    ped = API.CreatePedInsideVehicle(vehicle, 26, pocce, seat, true, false);
                }
                else if (API.GetEntitySpeed(vehicle) > 0.1f)
                {
                    Hud.Notification("Player is in a moving vehicle and there are no free seats");
                    return;
                }
                else
                {
                    ped = await Peds.Spawn(Config.PocceList);
                }
            }
            else
            {
                ped = await Peds.Spawn(Config.PocceList);
            }

            Companions.Add(ped);
            await Peds.Arm(ped, Config.WeaponList);

            API.SetEntityAsNoLongerNeeded(ref ped);
        }
Пример #2
0
        public static void TeleportToClosestVehicle(bool forcePassenger = false)
        {
            var vehicles = Vehicles.Get();

            if (Common.GetClosestEntity(vehicles, out int vehicle))
            {
                if (Vehicles.GetFreeSeat(vehicle, out int seat, forcePassenger))
                {
                    var player = API.GetPlayerPed(-1);
                    API.SetPedIntoVehicle(player, vehicle, seat);
                }
                else
                {
                    if (!forcePassenger)
                    {
                        var driver = API.GetPedInVehicleSeat(vehicle, -1);
                        if (Autopilot.IsOwnedAutopilot(driver))
                        {
                            API.DeletePed(ref driver);

                            var player = API.GetPlayerPed(-1);
                            API.SetPedIntoVehicle(player, vehicle, -1);
                            return;
                        }
                    }

                    Common.Notification("Closest vehicle doesn't have a free seat");
                }
            }
Пример #3
0
        public static void TeleportToClosestVehicle(bool forcePassenger = false)
        {
            var vehicles = Vehicles.Get();

            if (Common.GetClosestEntity(vehicles, out int vehicle))
            {
                if (Vehicles.GetFreeSeat(vehicle, out int seat, forcePassenger))
                {
                    var player = Game.Player.Character.Handle;
                    API.SetPedIntoVehicle(player, vehicle, seat);
                }
                else
                {
                    Hud.Notification("Closest vehicle doesn't have a free seat");
                }
            }
Пример #4
0
        public static async Task PoccePassengers()
        {
            if (!Common.EnsurePlayerIsInVehicle(out int player, out int vehicle))
            {
                return;
            }

            while (Vehicles.GetFreeSeat(vehicle, out int seat))
            {
                var pocce = Config.PocceList[API.GetRandomIntInRange(0, Config.PocceList.Length)];
                await Common.RequestModel(pocce);

                var ped = API.CreatePedInsideVehicle(vehicle, 26, pocce, seat, true, false);
                API.SetModelAsNoLongerNeeded(pocce);
                API.SetEntityAsNoLongerNeeded(ref ped);
            }
        }
Пример #5
0
        public static async Task RappelFromHeli()
        {
            var player = API.GetPlayerPed(-1);

            if (API.IsPedInAnyHeli(player))
            {
                var heli = API.GetVehiclePedIsIn(player, false);
                if (!Vehicles.GetPedSeat(heli, player, out int seat))
                {
                    return;
                }

                switch (seat)
                {
                case -1:
                    if (API.AreAnyVehicleSeatsFree(heli))
                    {
                        await Autopilot.Activate();

                        API.TaskRappelFromHeli(player, 0);
                    }
                    break;

                case 0:
                    if (Vehicles.GetFreeSeat(heli, out int goodSeat, true))
                    {
                        API.SetPedIntoVehicle(player, heli, goodSeat);
                        API.TaskRappelFromHeli(player, 0);
                    }
                    break;

                default:
                    API.TaskRappelFromHeli(player, 0);
                    break;
                }
            }
            else
            {
                Common.Notification("Player is not in a heli");
            }
        }
Пример #6
0
        public static async Task PoccePassengers()
        {
            int player = Game.Player.Character.Handle;

            if (!API.IsPedInAnyVehicle(player, true))
            {
                Hud.Notification("Player is not in a vehicle");
                return;
            }

            var vehicle = API.GetVehiclePedIsIn(player, false);

            while (Vehicles.GetFreeSeat(vehicle, out int seat))
            {
                var pocce = Config.PocceList[API.GetRandomIntInRange(0, Config.PocceList.Length)];
                await Common.RequestModel(pocce);

                var ped = API.CreatePedInsideVehicle(vehicle, 26, pocce, seat, true, false);
                API.SetEntityAsNoLongerNeeded(ref ped);
            }
        }