lolman Posted June 23, 2015 Share Posted June 23, 2015 Hello, I've a problem with my script. function engine() local vehicle = getPedOccupiedVehicle ( getLocalPlayer() ) local health = getElementHealth ( vehicle ) if vehicle and ( health == 250 ) then outputChatBox ("Worked!",255,0,0,thePlayer) setVehicleEngineState ( vehicle, false ) end end addEventHandler ("onPlayerVehicleEnter", getRootElement(), engine) --addCommandHandler("123", engine) Here in this script I want that you can't drive the car (setengine false) when you enter the car if it has 25% health (as you can see there is (health == 250). everything works fine with the command if I use it but if i want it on playervehicleenter, it doesnt work, please help needed ! Link to comment
iMr.Dawix~# Posted June 23, 2015 Share Posted June 23, 2015 try this .. function engine() local vehicle = getPedOccupiedVehicle(source) local health = getElementHealth ( vehicle ) if vehicle and ( health == 250 ) then outputChatBox ("Worked!",source,255,0,0,true) setVehicleEngineState ( vehicle, false ) end end addEventHandler ("onPlayerVehicleEnter", getRootElement(), engine) --addCommandHandler("123", engine) Link to comment
lolman Posted June 23, 2015 Author Share Posted June 23, 2015 Nop... didn't work.... btw my server is client sided... Link to comment
iMr.Dawix~# Posted June 23, 2015 Share Posted June 23, 2015 Nop... didn't work.... btw my server is client sided... ah, ok .. use this function engine() local vehicle = getPedOccupiedVehicle(source) local health = getElementHealth (vehicle) if vehicle and ( health == 250 ) then outputChatBox ("Worked!",255,0,0,true) setVehicleEngineState (vehicle, false ) end end addEventHandler ("onClientPlayerVehicleEnter",root, engine) --addCommandHandler("123", engine) Link to comment
lolman Posted June 23, 2015 Author Share Posted June 23, 2015 dude... YOU'RE AMAZING ! thank you so much !! Link to comment
iMr.Dawix~# Posted June 23, 2015 Share Posted June 23, 2015 dude... YOU'RE AMAZING ! thank you so much !! You're Welcome ^ ^ Link to comment
lolman Posted June 23, 2015 Author Share Posted June 23, 2015 btw how can you set the engine off while driving the car and the car gets 25% health? Link to comment
iMr.Dawix~# Posted June 23, 2015 Share Posted June 23, 2015 btw how can you set the engine off while driving the car and the car gets 25% health? try .. function Ecollision() local vehicle = getPedOccupiedVehicle(localPlayer) if source == vehicle then local health = getElementHealth (vehicle) if health <= 250 then setVehicleEngineState (vehicle, false ) end end end addEventHandler ("onClientVehicleCollision",root,Ecollision) Link to comment
lolman Posted June 23, 2015 Author Share Posted June 23, 2015 Man, really, thank you for your time for helping me out ! It worked !! Link to comment
iMr.Dawix~# Posted June 24, 2015 Share Posted June 24, 2015 Man, really, thank you for your time for helping me out ! It worked !! Any Time <3 Link to comment
tosfera Posted June 24, 2015 Share Posted June 24, 2015 Why would you handle the engine on the client side..? That'll cause desync at a certain point. Link to comment
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