Jump to content

Weird problem with speedometer


Sande

Recommended Posts

Somereason i can only see the speedometer :o. If someone can give a solution how to fix that, then i am happy.

function speedoCreate() 
 if isPedInVehicle (localPlayer) == false then return end 
        sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) 
        local kmhs = math.floor(((sx^2 + sy^2 + sz^2)^(0.5))*180) 
        local x, y, z = getElementPosition(localPlayer) 
        vehicle = getVehicleName (getPedOccupiedVehicle(localPlayer)) 
        health = getElementHealth (getPedOccupiedVehicle(localPlayer)) 
        currenthealth = math.floor(health/10) 
        dxDrawText("Speed: "..tostring(kmhs).."km/h", 1701, 956, 1924, 977, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, true, false, false) 
        dxDrawText("Health: "..tostring(currenthealth).."%", 1701, 987, 1924, 1008, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, true, false, false) 
        dxDrawRectangle(1700, 924, 191, 95, tocolor(0, 0, 0, 255), false) 
        dxDrawRectangle(1701, 925, 189, 93, tocolor(27, 27, 27, 254), false) 
        dxDrawText(""..tostring(vehicle).."", 1701, 925, 1855, 956, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, true, false, false) 
    end 
    addEventHandler("onClientRender",getRootElement(),speedoCreate) 
    
    function show ( player ) 
if ( player == localPlayer ) then 
    addEventHandler ( "onClientRender", getRootElement(), speedoCreate ) 
end 
end 
addEventHandler ("onClientVehicleEnter", getRootElement(), show) 
  
    function hide ( player ) 
if ( player == localPlayer ) then 
    removeEventHandler ( "onClientRender", getRootElement(), speedoCreate ) 
end 
end 
addEventHandler ("onClientVehicleExit", getRootElement(), hide) 

Link to comment

Should work with all resolutions now

function speedoCreate() 
 if isPedInVehicle (localPlayer) == false then return end 
        sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) 
        local kmhs = math.floor(((sx^2 + sy^2 + sz^2)^(0.5))*180) 
        local x, y, z = getElementPosition(localPlayer) 
        local sH, sW = guiGetScreenSize() 
        vehicle = getVehicleName (getPedOccupiedVehicle(localPlayer)) 
        health = getElementHealth (getPedOccupiedVehicle(localPlayer)) 
        currenthealth = math.floor(health/10) 
        dxDrawText("Speed: "..tostring(kmhs).."km/h", sH*1701/1920, sW*956/1080, sH*1924/1920, sW*977/1080, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, true, false, false) 
        dxDrawText("Health: "..tostring(currenthealth).."%", sH*1701/1920, sW*987/1080, sH*1924/1920, sW*1008/1080, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, true, false, false) 
        dxDrawRectangle(sH*1700/1920, sW*924/1080, sH*191/1920, sW*95/1080, tocolor(0, 0, 0, 255), false) 
        dxDrawRectangle(sH*1701/1920, sW*925/1080, sH*189/1920, sW*93/1080, tocolor(27, 27, 27, 254), false) 
        dxDrawText(""..tostring(vehicle).."", sH*1701/1920, sW*925/1080, sH*1855/1920, sW*956/1080, tocolor(255, 255, 255, 255), 2.00, "default", "left", "top", false, false, true, false, false) 
    end 
    addEventHandler("onClientRender",getRootElement(),speedoCreate) 
    
    function show ( player ) 
if ( player == localPlayer ) then 
    addEventHandler ( "onClientRender", getRootElement(), speedoCreate ) 
end 
end 
addEventHandler ("onClientVehicleEnter", getRootElement(), show) 
  
    function hide ( player ) 
if ( player == localPlayer ) then 
    removeEventHandler ( "onClientRender", getRootElement(), speedoCreate ) 
end 
end 
addEventHandler ("onClientVehicleExit", getRootElement(), hide) 

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