redditing Posted March 11, 2020 Posted March 11, 2020 function healthCar() HEALTHcaringXD = tonumber(getElementHealth(getPedOccupiedVehicle(getLocalPlayer()))) IknowU = tostring(getVehicleName(getPedOccupiedVehicle(getLocalPlayer()))) dxDrawText(IknowU.." : "..math.floor(HEALTHcaringXD/10) , 416, 267, 684, 329, tocolor(255, 0, 0, 255), 2.00, "default", "center", "center", false, false, false, false, false) end function entering() addEventHandler("onClientRender", root, healthCar) end function exiting() removeEventHandler("onClientRender", root, healthCar) end addEventHandler("onClientVehicleEnter", root, entering) addEventHandler("onClientVehicleExit", root, exiting) I do not know why but I have errors that the variables are true / false (boolean) despite this script works for me but it annoys me that I debugscript these spam errors. Is there anything to fix these errors? ERROR line 2,3,4 has boolean
Moderators Patrick Posted March 11, 2020 Moderators Posted March 11, 2020 (edited) Because `onClientVehicleEnter` triggered if someone entered to a vehicle. (not only localPlayer) If this player is not you (localPlayer), getPedOccupiedVehicle(getLocalPlayer()) returns `false`. (because the event started the render) You need to check, who enter the vehicle is the localPlayer. function entering(player) if player == localPlayer then addEventHandler("onClientRender", root, healthCar) end end function exiting(player) if player == localPlayer then removeEventHandler("onClientRender", root, healthCar) end end addEventHandler("onClientVehicleEnter", root, entering) addEventHandler("onClientVehicleExit", root, exiting) Edited March 11, 2020 by Patrick 1
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