Jump to content

how to prevent player automaticly turn on the engine


Recommended Posts

Posted

so, i had trouble when i get inside a vehicle, the player turn on the engine automaticly, i want to prevent that by making some script when my player get into vehicle

 

        [ServerEvent(Event.PlayerEnterVehicle)]
        public void OnPlayerEnterVehicle(Player player, Vehicle vehicle, sbyte seatId)
        {
            player.TriggerEvent("disableDefaultEngineBehaviour");

            if (seatId == -1)
            {
                bool engineStatus = vehicle.HasData("engine_status") ? vehicle.GetData<bool>("engine_status") : false;

                if (!engineStatus)
                {
                    vehicle.EngineStatus = false;
                    player.SendChatMessage("engine is off");
                }
                else
                {
                    player.SendChatMessage("engine is on.");
                }
            }
        }

but, it didn;t work. so, i hope you can help me, thank you...

 

for disableDefaultEngineBehaviour events

mp.events.add('disableDefaultEngineBehaviour', () => {
    mp.game.vehicle.defaultEngineBehaviour = false;
});
 

Posted (edited)

This needs to be applied each time player spawns: 

const PED_FLAG_STOP_ENGINE_TURNING = 429;
mp.players.local.setConfigFlag(PED_FLAG_STOP_ENGINE_TURNING , true);

This needs to be applied once in playerReady event:

mp.game1.vehicle.defaultEngineBehaviour = false;
mp.game.vehicle.defaultEngineBehaviour = false;

 

Edited by Kopra

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...