Sirmittens Posted May 18, 2020 Posted May 18, 2020 (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 May 18, 2020 by Sirmittens made the link blue, harder to miss
Heathen Posted May 18, 2020 Posted May 18, 2020 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. 1
Sirmittens Posted May 18, 2020 Author Posted May 18, 2020 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?
Flashrex Posted May 19, 2020 Posted May 19, 2020 (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 May 19, 2020 by Flashrex
trolovecro Posted May 19, 2020 Posted May 19, 2020 There is vehicle engine on server side. https://wiki.rage.mp/index.php?title=Vehicle::engine its a property of vehicle.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now