Jump to content

Recommended Posts

Posted (edited)

Hey,

So when i turn of the vehicles engine with my key bind and then push 'W' for drive forward this tends to happen
 Video
Here is the client side code
 

mp.keys.bind(0x26, true, function() {
    const vehicle = mp.players.local.vehicle;
    if (vehicle)
       vehicle.setEngineOn(true, true, true);
  });

  mp.keys.bind(0x28, false, function() {
    mp.events.callRemote('keypress:DOWN ARROW');
    mp.game.vehicle.defaultEngineBehaviour = false;
    const vehicle = mp.players.local.vehicle;
    if (vehicle)
       vehicle.setEngineOn(false, true, true);
  });

i did not set anything up on server side since i have no clue how to do that server side.
Any help is appreciated 

Edited by Sirmittens
made the link blue, harder to miss
Posted

Don't do anything on client-side related to the vehicle, simply detect what the player pressed. Then call a remote function (basically, you're telling the server: player X is trying to turn the engine of vehicle Y); then do the rest there.

  • Like 1
Posted
1 hour ago, Heathen said:

Don't do anything on client-side related to the vehicle, simply detect what the player pressed. Then call a remote function (basically, you're telling the server: player X is trying to turn the engine of vehicle Y); then do the rest there.

i looked around but could not find anything on how to turn off the engine server side using java script. any tips? 

Posted (edited)

I dont know if i understand the problem but if it is that the engine turns back on try putting this:

mp.game.vehicle.defaultEngineBehaviour = false;

somewhere outside of all functions so that it gets called on loading.

Btw it's not a good idea to call a remote event everytime a player trys to turn on/off his vehicle engine or in general presses a key.
At least add some sort of cooldown.

Edited by Flashrex

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