Sande Posted May 18, 2013 Share Posted May 18, 2013 Hey, i started to make little digital speedo meter addon to my big speedometer. Im starter in script so i dont know what i need to do now. No errors. Only the KM/h text not opening when are inside car. Thanks if you help addEventHandler("onClientResourceStart", resourceRoot, function() end ) function autonTila ( ) if isPedInVehicle (localPlayer) then sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer) speed = math.floor(((sx^2 + sy^2 + sz^2)^(0.5))*180) dxDrawText("Speed: "..tostring(speed).."KM/h", 1493, 839, 1550, 856, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) end function StopTheRender ( ) removeEventHandler ( "onClientRender", root, autonTila ) end addEventHandler("onClientVehicleExit", root, StopTheRender) addEventHandler("onClientRender", root, function() dxDrawText("Speed: "..tostring(speed).."KM/h", 1493, 839, 1550, 856, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) end ) Link to comment
Castillo Posted May 18, 2013 Share Posted May 18, 2013 function autonTila ( ) if isPedInVehicle ( localPlayer ) then local sx, sy, sz = getElementVelocity ( getPedOccupiedVehicle ( localPlayer ) ) speed = math.floor ( ( ( sx ^ 2 + sy ^ 2 + sz ^ 2 ) ^ ( 0.5 ) ) * 180 ) dxDrawText ( "Speed: ".. tostring ( speed ) .."KM/h", 1493, 839, 1550, 856, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false ) end end function onEnterOrExit ( thePlayer, seat ) if ( thePlayer == localPlayer and seat == 0 ) then if ( eventName == "onClientVehicleEnter" ) then addEventHandler ( "onClientRender", root, autonTila ) else removeEventHandler ( "onClientRender", root, autonTila ) end end end addEventHandler ( "onClientVehicleEnter", root, onEnterOrExit ) addEventHandler ( "onClientVehicleExit", root, onEnterOrExit ) 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