Sign in to follow this  
DiEeR

Prevent player from toggling engine state on enter

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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 1

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
В 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

Share this post


Link to post
Share on other sites
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;
  }
});

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.