Tokio Posted November 22, 2017 Posted November 22, 2017 i want change the needle color if speed >= 240, but does not working how to fix this? Spoiler function drawSpeedometer() if isPedInVehicle(self) and getElementHealth(self) > 0 and enableSpeed ~= false and getElementData(getLocalPlayer(),"userpanelOpen") ~= true then local alap = tocolor(255,117,0,178) function szinvaltas(speed) speed = tonumber(speed) if speed >= 240 then alap = tocolor(255,0,0,178) else alap = tocolor(255,117,0,178) end end dxDrawImage(screenW * 0.7882, screenH * 0.6800, screenW * 0.1785, screenH * 0.2344, discImg, 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(screenW * 0.7862, screenH * 0.7210, screenW * 0.1785, screenH * 0.2344, needleImg, needleRotation, 0, 0, alap, false) end end what wrong? no error(s)/warning(s) My servers: Fun: Derby(DD):
Moderators IIYAMA Posted November 22, 2017 Moderators Posted November 22, 2017 You aren't executing the function `szinvaltas`. And I have also no clue why you put a function there. Also I do not understand where the variable `speed`/ speed value comes from. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Simple0x47 Posted November 23, 2017 Posted November 23, 2017 function drawSpeedometer() if isPedInVehicle(self) and getElementHealth(self) > 0 and enableSpeed ~= false and getElementData(getLocalPlayer(),"userpanelOpen") ~= true then speedx, speedy, speedz = getElementVelocity ( getPedOccupiedVehicle( localPlayer ) ) actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5) speed = actualspeed * 180 local alap = tocolor(255,117,0,178) if speed >= 240 then alap = tocolor(255,0,0,178) else alap = tocolor(255,117,0,178) end dxDrawImage(screenW * 0.7882, screenH * 0.6800, screenW * 0.1785, screenH * 0.2344, discImg, 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(screenW * 0.7862, screenH * 0.7210, screenW * 0.1785, screenH * 0.2344, needleImg, needleRotation, 0, 0, alap, false) end end 1 "Keep making it simplex."
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