Exemple #1
0
        public static async Task Activate()
        {
            var player = Game.Player.Character.Handle;

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

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

            if (API.IsVehicleSeatFree(vehicle, -1))
            {
                await Spawn(vehicle);

                return;
            }

            if (API.GetPedInVehicleSeat(vehicle, -1) != player)
            {
                Hud.Notification("You are not the driver of this vehicle");
                return;
            }

            if (Vehicles.GetFreeSeat(vehicle, out int seat, true))
            {
                var driver = API.GetPedInVehicleSeat(vehicle, -1);
                API.SetPedIntoVehicle(driver, vehicle, seat);

                await Spawn(vehicle);
            }
Exemple #2
0
        public static async Task <int> Spawn(string model)
        {
            var pos  = Game.Player.Character.Position;
            var hash = (uint)API.GetHashKey(model);

            if (!API.IsModelValid(hash))
            {
                Hud.Notification(string.Format("Invalid model hash: 0x{0:X8} ({1})", hash, model));
                return(-1);
            }

            if (API.IsPedInAnyVehicle(Game.Player.Character.Handle, false))
            {
                Hud.Notification("Player is in a vehicle");
                return(-1);
            }

            await Common.RequestModel(hash);

            var vehicle = API.CreateVehicle(hash, pos.X, pos.Y, pos.Z + 1.0f, Game.Player.Character.Heading, true, false);

            Game.Player.Character.SetIntoVehicle(new Vehicle(vehicle), VehicleSeat.Driver);

            if (API.IsThisModelAHeli(hash) && API.GetEntityHeightAboveGround(vehicle) > 10.0f)
            {
                API.SetHeliBladesFullSpeed(vehicle);
            }

            return(vehicle);
        }
Exemple #3
0
        public static Task <int> Spawn(string model)
        {
            var player = Game.Player.Character.Handle;
            var hash   = (uint)API.GetHashKey(model);

            if (!API.IsModelValid(hash))
            {
                Hud.Notification(string.Format("Invalid model hash: 0x{0:X8} ({1})", hash, model));
                return(Task.FromResult(-1));
            }

            if (API.IsPedInAnyVehicle(player, false))
            {
                var vehicle = API.GetVehiclePedIsIn(player, false);
                return(SpawnOnEntity(vehicle, hash));
            }
            else
            {
                return(SpawnInFrontOfPed(player, hash));
            }
        }