Jump to content

HELP! Speedo meter


T.P

Recommended Posts

Hello everyone! a little help would be needed. there is a speedometer for me, but vainly rehearse to write the needle does not display it. Just line...

function drawSpeedo() 
    if active and not isPlayerMapVisible() then 
        local vehicle = getPedOccupiedVehicle(getLocalPlayer()) 
        if (vehicle) then 
  
            speed = exports.global:getVehicleVelocity(vehicle) 
            local width, height = guiGetScreenSize() 
            local x = width 
            local y = height 
             
            -- street names 
            local streetname = getElementData(getLocalPlayer(), "speedo:street" ) 
            if streetname then 
                local width = dxGetTextWidth( streetname ) 
                local x = width < 200 and ( x - 110 - width / 2 ) or ( x - 10 - width ) 
                dxDrawRectangle( x - 8, y - 296, width + 17, 24, tocolor( 5, 5, 5, 220 ) ) 
                dxDrawText( streetname, x, y - 292 ) 
            end 
             
            dxDrawImage(x-210, y-275, 200, 200, "disc.png", 0, 0, 0, tocolor(255, 255, 255, 200), false) 
             
            local speedlimit = getElementData(getLocalPlayer(), "speedo:limit") 
            if speedlimit and getElementType(vehicle) ~= "Boat" and getElementType(vehicle) ~= "Helicopter" and getElementType(vehicle) ~= "Plane" then 
                local ax, ay = x - 243, y - 202 
                 
                dxDrawImage(ax,ay,32,37,"images/speed" .. speedlimit .. ".png") 
                ay = ay - 32 
                 
                if speedlimit >= 120 then 
                    dxDrawImage(ax,ay,32,37,"images/highway.png") 
                    ay = ay - 32 
                end 
                 
                if speed > speedlimit then 
                    dxDrawImage(ax,ay,32,37,"images/accident.png") 
                end 
            end 
             
            speed = speed - 100 
            nx = x + math.sin(math.rad(-(speed)-150)) * 90 
            ny = y + math.cos(math.rad(-(speed)-150)) * 90 
            dxDrawLine(x-110, y-175, nx-110, ny-175, tocolor(255, 0, 0, 255), 2, true) 
        end 
    end 
end 

I know it...But is bad :S

dxDrawImage(x-110, y-175, nx-110, ny-175, "needle.png"(255, 0, 0, 255),  true) 

What should I exchange?

Thanks a lot

(sry my bad eng)

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...