Jump to content

Car Hud (Fuel)


Best-Killer

Recommended Posts

error : bad argement to #1 'ceil' number (expected , got boolean) Line 9

function carhud()
    local sWidth,sHeight = guiGetScreenSize()
	if isPedInVehicle(localPlayer) then
        vehicle = getPedOccupiedVehicle(localPlayer)
        health = math.ceil ( getElementHealth ( vehicle ) / 10 )
        speedx, speedy, speedz = getElementVelocity ( vehicle)
        actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)
        kmh = math.ceil(actualspeed * 180)
		fuel = math.ceil(getElementData ( vehicle, "fuel" ))

		dxDrawImage((400/1024)*sWidth, (550/768)*sHeight, (250/1024)*sWidth, (200/768)*sHeight, "outras/background.png",0,250,10,tocolor(0,0,0,255))
		dxDrawImage((570/1024)*sWidth, (575/768)*sHeight, (25/1024)*sWidth, (150/768)*sHeight, "outras/line.png",0,0,0,tocolor(255,255,255,255))
		dxDrawImage((595/1024)*sWidth, (570/768)*sHeight, (19/1024)*sWidth, (45/768)*sHeight, "outras/lock.png",0,0,0,tocolor(255,255,255,255))
		dxDrawImage((595/1024)*sWidth, (620/768)*sHeight, (19/1024)*sWidth, (45/768)*sHeight, "outras/engine.png",0,0,0,tocolor(255,255,255,255))
		dxDrawImage((595/1024)*sWidth, (670/768)*sHeight, (19/1024)*sWidth, (45/768)*sHeight, "outras/light.png",0,0,0,tocolor(255,255,255,255))
		dxDrawText(tostring (kmh).."  Km/H",(470/1024)*sWidth, (585/768)*sHeight, (20/1024)*sWidth, (40/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*0.65, newFont3,"left","top",false,false,false)
		dxDrawImage((430/1024)*sWidth, (575/768)*sHeight, (30/1024)*sWidth, (50/768)*sHeight, "outras/speed.png",0,0,0,tocolor(255,255,255,255))
		dxDrawText(tostring (fuel).."%",(470/1024)*sWidth, (635/768)*sHeight, (20/1024)*sWidth, (50/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*0.75, newFont3,"left","top",false,false,false)
        dxDrawImage((430/1024)*sWidth, (625/768)*sHeight, (30/1024)*sWidth, (50/768)*sHeight, "outras/fuel.png",0,0,0,tocolor(255,255,255,255))		
		dxDrawText(tostring (health).."%",(470/1024)*sWidth, (680/768)*sHeight, (20/1024)*sWidth, (50/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*0.75, newFont3,"left","top",false,false,false)
		dxDrawImage((430/1024)*sWidth, (675/768)*sHeight, (30/1024)*sWidth, (50/768)*sHeight, "outras/wrench.png",0,0,0,tocolor(255,255,255,255))
    end
end

addEventHandler("onClientVehicleEnter", getRootElement(),
	function(thePlayer)
		if thePlayer == getLocalPlayer() then
			addEventHandler("onClientRender", getRootElement(), carhud)
		end
	end
)


addEventHandler("onClientVehicleStartExit", getRootElement(),
	function(thePlayer)
		if thePlayer == getLocalPlayer() then
			removeEventHandler("onClientRender", getRootElement(), carhud)
		end
	end
)

 

Link to comment
function carhud()
    local sWidth,sHeight = guiGetScreenSize()
    if isPedInVehicle(localPlayer) then
        local vehicle = getPedOccupiedVehicle(localPlayer)
        local health = math.ceil ( getElementHealth ( vehicle ) / 10 )
        local speedx, speedy, speedz = getElementVelocity ( vehicle)
        local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)
        local kmh = math.ceil(actualspeed * 180)
        local fuel = math.ceil(tonumber(getElementData ( vehicle, "fuel" )) or 0)
         
        dxDrawImage((400/1024)*sWidth, (550/768)*sHeight, (250/1024)*sWidth, (200/768)*sHeight, "outras/background.png",0,250,10,tocolor(0,0,0,255))
        dxDrawImage((570/1024)*sWidth, (575/768)*sHeight, (25/1024)*sWidth, (150/768)*sHeight, "outras/line.png",0,0,0,tocolor(255,255,255,255))
        dxDrawImage((595/1024)*sWidth, (570/768)*sHeight, (19/1024)*sWidth, (45/768)*sHeight, "outras/lock.png",0,0,0,tocolor(255,255,255,255))
        dxDrawImage((595/1024)*sWidth, (620/768)*sHeight, (19/1024)*sWidth, (45/768)*sHeight, "outras/engine.png",0,0,0,tocolor(255,255,255,255))
        dxDrawImage((595/1024)*sWidth, (670/768)*sHeight, (19/1024)*sWidth, (45/768)*sHeight, "outras/light.png",0,0,0,tocolor(255,255,255,255))
        dxDrawText(tostring (kmh).."  Km/H",(470/1024)*sWidth, (585/768)*sHeight, (20/1024)*sWidth, (40/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*0.65, newFont3,"left","top",false,false,false)
        dxDrawImage((430/1024)*sWidth, (575/768)*sHeight, (30/1024)*sWidth, (50/768)*sHeight, "outras/speed.png",0,0,0,tocolor(255,255,255,255))
        dxDrawText(tostring (fuel).."%",(470/1024)*sWidth, (635/768)*sHeight, (20/1024)*sWidth, (50/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*0.75, newFont3,"left","top",false,false,false)
        dxDrawImage((430/1024)*sWidth, (625/768)*sHeight, (30/1024)*sWidth, (50/768)*sHeight, "outras/fuel.png",0,0,0,tocolor(255,255,255,255))		
        dxDrawText(tostring (health).."%",(470/1024)*sWidth, (680/768)*sHeight, (20/1024)*sWidth, (50/768)*sHeight, tocolor(255,255,255,255), (sWidth/1024)*0.75, newFont3,"left","top",false,false,false)
        dxDrawImage((430/1024)*sWidth, (675/768)*sHeight, (30/1024)*sWidth, (50/768)*sHeight, "outras/wrench.png",0,0,0,tocolor(255,255,255,255))
    end
end

addEventHandler("onClientVehicleEnter", getRootElement(),
    function(thePlayer)
        if thePlayer == getLocalPlayer() then
           addEventHandler("onClientRender", getRootElement(), carhud)
        end
    end
)


addEventHandler("onClientVehicleStartExit", getRootElement(),
    function(thePlayer)
        if thePlayer == getLocalPlayer() then
           removeEventHandler("onClientRender", getRootElement(), carhud)
        end
    end
)

 

Edited by Walid
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...