K4stic Posted March 10, 2013 Share Posted March 10, 2013 (edited) function blablabla (hitPlayer) local vehicle = getPedOccupiedVehicle(hitPlayer) local speed = getElementSpeed(vehicle,1) if speed < 30 then function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else return false end end on first 5 lines is the one part of all code so i just no add end to this 5 lines the error at line 5: attempt to compare boolean with number Edited March 10, 2013 by Guest Link to comment
Anderl Posted March 10, 2013 Share Posted March 10, 2013 (edited) You need to add 'end's. And it's giving that error because "hitPlayer" is either not an element (but that would give the error 'Bad ped pointer' @ 'getPedOccupiedVehicle' function) or "hitPlayer" is not inside a vehicle, so you're comparing a boolean value with a number. Edited March 10, 2013 by Guest Link to comment
K4stic Posted March 10, 2013 Author Share Posted March 10, 2013 (edited) on first 5 lines is the one part of all code so i just no add end to this 5 lines Edited March 10, 2013 by Guest Link to comment
Anderl Posted March 10, 2013 Share Posted March 10, 2013 Talk in a proper english then. Link to comment
K4stic Posted March 10, 2013 Author Share Posted March 10, 2013 so you can help me yes or no Community PLS HELP me Link to comment
K4stic Posted March 10, 2013 Author Share Posted March 10, 2013 if need full code just say Link to comment
Anderl Posted March 10, 2013 Share Posted March 10, 2013 I already explained you the possible problems, it's up to you to check, I don't guess things.. Link to comment
HunT Posted March 10, 2013 Share Posted March 10, 2013 addEventHandler("onClientVehicleEnter",root, function () addEventHandler ( "onClientRender", getRootElement(), getPlayerSpeed ) end ) addEventHandler("onClientVehicleExit",root, function () removeEventHandler ( "onClientRender", getRootElement(), getPlayerSpeed ) end ) function getPlayerSpeed ( ) local sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) return (sx^2 + sy^2 + sz^2)^0.5*180 end Now u can get the speed example : if(tonumber( math.floor( getPlayerSpeed() ) ) < 30 ) then 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