Jump to content

Tokio

Recommended Posts

i want change the needle color if speed >= 240, but does not working :S 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) :/ 

Link to comment
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

 

  • Like 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...