Jump to content

Prevent player from toggling engine state on enter


Recommended Posts

Posted

Greetings.

I need to prevent player from automatically turning on vehicle engine on enter. I saw another thread with similar issue and tried suggested solution:

Цитата

It's not a bug since it's expected GTA V behavior. However you can prevent player from starting the engine by using vehicle.setUndriveable clientside.

Seems like vehicle.setUndriveable does nothing. I tried setting it on events like playerStartEnterVehicle, playerEnterVehicle and even on playerSpawn for every vehicle but player still turns the engine on.

Also I've found out that if player uses command /en (toggles engine state for occupied vehicle on server side) and leaves vehicle with engine off, next time he enters that vehicle he (the player) will play the animation of switching engine but the engine will stay turned off.

Any ideas on how to solve this issue? Thanks.

Posted

Guys on discord helped me to find out the solution.

To solve the issue you need to add this code to clientside:

mp.events.add({
  'playerEnterVehicle': (vehicle, seat) => {
    if (mp.players.local.getSeatIsTryingToEnter() !== -1 || vehicle.getIsEngineRunning()) {
      return;
    }
    vehicle.setEngineOn(false, true, true);
  }
});

Hope this helps!

  • Like 2
Posted
7 hours ago, DiEeR said:

Guys on discord helped me to find out the solution.

To solve the issue you need to add this code to clientside:


mp.events.add({
  'playerEnterVehicle': (vehicle, seat) => {
    if (mp.players.local.getSeatIsTryingToEnter() !== -1 || vehicle.getIsEngineRunning()) {
      return;
    }
    vehicle.setEngineOn(false, true, true);
  }
});

Hope this helps!

awsome men,, enjoy)

  • 2 weeks later...
Posted
В 29.09.2018 в 18:30, DiEeR сказал:

Guys on discord helped me to find out the solution.

To solve the issue you need to add this code to clientside:


mp.events.add({
  'playerEnterVehicle': (vehicle, seat) => {
    if (mp.players.local.getSeatIsTryingToEnter() !== -1 || vehicle.getIsEngineRunning()) {
      return;
    }
    vehicle.setEngineOn(false, true, true);
  }
});

Hope this helps!

how about getting out of the car so that the engine doesn't turn off? maybe there is a general command that turns off engine control

Posted
1 час назад, John_Miller сказал:

how about getting out of the car so that the engine doesn't turn off? maybe there is a general command that turns off engine control

mp.events.add({
  'playerStartExitVehicle': (player) => {
    if (player.vehicle.engine) player.vehicle.engine = true;
  }
});

 

  • Like 2
  • 1 year later...
Posted

Methods above do not work at 1.1 version.
If came here like me, try this method to write normal engine system:

 

mp.events.add("playerEnterVehicle", (vehicle, seat) => {
    mp.game.vehicle.defaultEngineBehaviour = false; // stop starts engine when player press 'W' or enter vehicle(because we using it in event)
    mp.players.local.setConfigFlag(429, true); // stop problems with animations
});

 

  • Like 4
  • 2 years later...
Posted

Hey Community,

the engines no longer switch off for me - as desired - when a player leaves a vehicle.
However, as soon as I move too far away from the vehicle (which is still switched on) and approach it again, it looks as if the engine is switched off.
Even if you sit in the vehicle, it cannot be moved. However, to switch it on, I have to switch the motor twice, since it is still switched on - as desired.

How can I ensure that the vehicles (after a player has moved away and approached again) are still optically switched on (lamps, engine, etc. on)

Thank you dear

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...