LabiVila Posted September 10, 2014 Posted September 10, 2014 function speed () if isPedInVehicle (localPlayer) then speedX, speedY, speedZ = getElementVelocity (getPedOccupiedVehicle (localPlayer)) speed = math.ceil (((speedX^2 + speedY^2 + speedZ^2)^(0.5))*180) dxDrawText (speed.." km/h", x/1.20, y/2.8, x, y, tocolor (255, 255, 255)) end end addEventHandler ("onClientRender", root, speed) WARNING: test\client:73: Bad argument @ 'getElementVelocity' ERROR: test\client:74: attempt to perform arithmetic on global "speedX" (a boolean value) It works but why do these message appear? and how can I fix them?
Moderators IIYAMA Posted September 10, 2014 Moderators Posted September 10, 2014 I have no idea why the getPedOccupiedVehicle or isPedInVehicle function failed, very strange. I hardly use the isPedInVehicle function, because I always need to know the vehicle element userdata. But this is how I would write it. function speed () local vehicle = getPedOccupiedVehicle (localPlayer) if vehicle then local speedX, speedY, speedZ = getElementVelocity (vehicle) local speed = math.ceil (((speedX^2 + speedY^2 + speedZ^2)^(0.5))*180) dxDrawText (speed.." km/h", x/1.20, y/2.8, x, y, tocolor (255, 255, 255)) end end addEventHandler ("onClientRender", root, speed)
LabiVila Posted September 10, 2014 Author Posted September 10, 2014 Cool, thanks mate, now there's no error
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