Linux_Shines Posted July 31, 2014 Share Posted July 31, 2014 Hello. I want to change speedometer colour by speed (for testing), but... I don't know, how to do this. I did it in the following way (I have this lines in function UpdateDisplay()): speedx, speedy, speedz = getElementVelocity(localPlayer) g_GuiLabel.Speed:color(255 - math.ceil(speedx * speedy), math.ceil(speedx * speedy), 255) But... from what I see, displayed color is ... pink. How can I dynamically change colour, from white (or something else, like green) to red, when white (or green) is 0 km/h and red is more than 200 km/h? @edit: Oh, I just solved this, but I want to share my code with other peoples, who will also have this problem function UpdateDisplay() if not getPedOccupiedVehicle(localPlayer) then hideSpeedometer() end g_GuiLabel.Speed:postGUI(true) g_GuiLabel.Speed:text(tostring(GetVehicleSpeed())) local x, y, z = getElementVelocity(getPedOccupiedVehicle(localPlayer)) local speed = math.floor(math.sqrt(x ^ 2 + y ^ 2 + z ^ 2) * kph_multiplayer) if speed < 254 then g_GuiLabel.Speed:color(255, 255 - speed, 255 - speed) else g_GuiLabel.Speed:color(255, 0, 0) end end 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