Lulz Posted February 21, 2016 Share Posted February 21, 2016 Im creating speedometer and i have problem why event handler with getRootElement works but with localPlayer doesn't work addEventHandler("onClientVehicleEnter", getRootElement(), showSpeedometer) Link to comment
tosfera Posted February 21, 2016 Share Posted February 21, 2016 Why do you want to bind it to the localPlayer if getRootElement() does the same trick. all you have to do is check if the first parameter equals to localPlayer. Link to comment
Lulz Posted February 21, 2016 Author Share Posted February 21, 2016 When i use getRootElement() players that are not drivers see speedometer too even if i check that function showSpeedometer(player, seat) if seat == 0 then addEventHandler("onClientPreRender", getRootElement(), Speedometer) end end Link to comment
tosfera Posted February 21, 2016 Share Posted February 21, 2016 When i use getRootElement() players that are not drivers see speedometer too even if i check that function showSpeedometer(player, seat) if seat == 0 then addEventHandler("onClientPreRender", getRootElement(), Speedometer) end end try this; addEventHandler ( "onClientVehicleEnter", getRootElement(), function ( thePlayer, seat ) if ( thePlayer == getLocalPlayer() and seat == 0 ) then addEventHandler ( "onClientPreRender", getRootElement(), Speedometer ); end end ); Make sure to make the same one for onClientVehicleExit but then with removeEventHandler. Link to comment
Lulz Posted February 21, 2016 Author Share Posted February 21, 2016 Yap it works thank you 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