Jump to content

Car Hud (Fuel)


Best-Killer

Recommended Posts

Posted

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
)

 

Posted (edited)
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

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

The error means that element data with key "fuel" wasn't set. You must set it. If you didn't even make fuel system, well it won't work by itself...

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted (edited)

You need a fuel-system. :)

Edited by Zsoltisz
function Zsoltisz(thePlayer)
  if isPlayerZsoltisz(thePlayer) then
    outputChatBox("Scripter")
  end
end

 

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