LabiVila Posted September 10, 2014 Share 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? Link to comment
Moderators IIYAMA Posted September 10, 2014 Moderators Share 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) Link to comment
LabiVila Posted September 10, 2014 Author Share Posted September 10, 2014 Cool, thanks mate, now there's no error Link to comment
Moderators IIYAMA Posted September 10, 2014 Moderators Share Posted September 10, 2014 np. 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