Drakath Posted March 31, 2015 Posted March 31, 2015 Can someone tell me why do I get this error: ERROR: rotation_check\server.lua:6: attempt to compare number with boolean local x, y, z = getElementPosition(thePlayer) local px, py, pz = getElementPosition(ped) local rx,ry,rz = getElementRotation( ped ) local formula = tonumber((360 - math.deg(math.atan2((x - px), (y - py)))) % 360)+1 if rz and formula then if not tonumber(rz) > tonumber(formula) then outputChatBox("Looking", root) else outputChatBox("Not looking", root) end end thePlayer and ped do exist.
WhoAmI Posted March 31, 2015 Posted March 31, 2015 local x, y, z = getElementPosition(thePlayer) local px, py, pz = getElementPosition(ped) local rx,ry,rz = getElementRotation( ped ) local formula = tonumber((360 - math.deg(math.atan2((x - px), (y - py)))) % 360)+1 outputChatBox ( type ( rz ) .. type ( formula ) ) if rz and formula then if not tonumber(rz) > tonumber(formula) then outputChatBox("Looking", root) else outputChatBox("Not looking", root) end end Check what it outptuts on chatbox.
Castillo Posted March 31, 2015 Posted March 31, 2015 if not tonumber(rz) > tonumber(formula) then The error is because when you do this: not tonumber(rz), you are converting it to a boolean. You need to use parentheses, like this: if not ( tonumber ( rz ) > tonumber ( formula ) ) then
Drakath Posted March 31, 2015 Author Posted March 31, 2015 if not tonumber(rz) > tonumber(formula) then The error is because when you do this: not tonumber(rz), you are converting it to a boolean. You need to use parentheses, like this: if not ( tonumber ( rz ) > tonumber ( formula ) ) then Thanks
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