alienwave Posted April 27, 2020 Posted April 27, 2020 (edited) While I'm not sitting in the car, the script is running in the browser, how do I fix it? I don't want the script to run in the browser until I get in the car. Please help me! https://jsfiddle.net/zk2qofuj/ Edited April 27, 2020 by alienwave
Division Posted April 27, 2020 Posted April 27, 2020 If you always wanna show the browser try player.isInVehicle(vehicle, atGetIn); if the condition is true, run the script or set a flag -> browser.execute(js) if you just show wanna show the browser, if player is in a car, open and destory your cef (browser) in vehicle events mp.events.add("playerEnterVehicle", playerEnterVehicleHandler); mp.events.add("playerLeaveVehicle", (vehicle, seat)...
alienwave Posted April 27, 2020 Author Posted April 27, 2020 1 минуту назад, Division сказал: If you always wanna show the browser try player.isInVehicle(vehicle, atGetIn); if the condition is true, run the script or set a flag -> browser.execute(js) if you just show wanna show the browser, if player is in a car, open and destory your cef (browser) in vehicle events mp.events.add("playerEnterVehicle", playerEnterVehicleHandler); mp.events.add("playerLeaveVehicle", (vehicle, seat)... I have a key binder, mp.keys.bind(CarTuning.keyCode, false, () => { // f6 if (player.vehicle) { if (CarTuning.windowOpen) { CarTuning.browser.active = false; mp.gui.cursor.show(false, false); CarTuning.windowOpen = !CarTuning.windowOpen; } else { mp.events.call("startTun") && mp.events.call("List"); CarTuning.browser.active = true; mp.gui.cursor.show(true, true); CarTuning.windowOpen = !CarTuning.windowOpen; } } else { mp.gui.chat.push("NEED A CAR!"); } })
alienwave Posted April 27, 2020 Author Posted April 27, 2020 (edited) i have a key binder mp.keys.bind(CarTuning.keyCode, false, () => { if (player.vehicle) { if (CarTuning.windowOpen) { CarTuning.browser.active = false; mp.gui.cursor.show(false, false); CarTuning.windowOpen = !CarTuning.windowOpen; } else { mp.events.call("List"); CarTuning.browser.active = true; mp.gui.cursor.show(true, true); CarTuning.windowOpen = !CarTuning.windowOpen; } } else { mp.gui.chat.push("CAR ONLY!"); } }); Edited April 27, 2020 by alienwave
Division Posted April 27, 2020 Posted April 27, 2020 if you're setting CarTuning.windowOpen in both conditions, please just use true/false, it's much better reading So your problem is, that when leaving the car, the window stays open? Than destroy the window, when event is triggered: playerLeaveVehicle
alienwave Posted April 27, 2020 Author Posted April 27, 2020 My problem is that the browser code starts immediately when you log in to the server. As a result, I completely wrapped the browser code in a function Now I need to somehow run this function via execute ('function ();'), but it doesn't start https://pastebin.com/xNLZxGTE
Division Posted April 27, 2020 Posted April 27, 2020 (edited) It's difficult to read what you want tbh But I tried, hope that's what you're looking for: https://pastebin.com/nnFMC2Cs Edited April 27, 2020 by Division
alienwave Posted April 27, 2020 Author Posted April 27, 2020 Ok, I'll try it later and let you know 1
alienwave Posted April 27, 2020 Author Posted April 27, 2020 For some reason, CarTuning.browser.execute(`getTuning();`); doesn't want to work. I'm tired, I'll try it tomorrow. My ds: alligatorBlood#6719
LT.Steiner Posted November 9, 2022 Posted November 9, 2022 Hello after almost 2 years. I have a question, How can I check Player is in vehicle on client-side js?! I tried this: if (mp.players.local.isInVehicle()){ // Do something } is it true?!
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