Sign in to follow this  
Lukkas2201

Erro com HUD

Recommended Posts

Boa noite, alguem pode me ajudar? 

o HUD é de veículos, estava funcionando normalmente, e de um dia pro outro parou de funcionar e ficou dando este erro.

 

ERROR: HudVeh\client.Lua:28: attempt to compare boolean with number

ja tentei de tudo e não consegui, se alguem puder me dizer onde estou errando, ou oque tenho que fazer.

 

local sZ = { guiGetScreenSize() }
local color = {}
details = {
	{"Tire_inVehicle"},
	{"Engine_inVehicle"},
	{"Parts_inVehicle"},
}

color.fuel = {80,190,80,135}
color.engine = {80,190,80,135}
color.parts = {80,190,80,135}
color.tire = {80,190,80,135}
color.armor = {255,0,0,255}
color.health = {80,190,80,135}

addEventHandler("onClientRender",getRootElement(),
function()
	local inVehicle = getPedOccupiedVehicle(getLocalPlayer())
	if inVehicle and isPedInVehicle(localPlayer) and getVehicleController(inVehicle) then
		if parent and fuel and armor then
			if fuel > 150/2 then 
				color.fuel = {80,190,80,135}
			elseif fuel <= 150/2 and fuel > 150/3 then 
				color.fuel = {80,190,80,135} 
			elseif fuel <= 150/3 then 
				color.fuel = {80,190,80,135}	
			end
			if getElementData(parent,"Engine_inVehicle_HP") <= 400 and getElementData(parent,"Engine_inVehicle_HP") > 300 and getElementData(parent,"Engine_inVehicle") == getElementData(inVehicle,"needengine") then--by XaskeL
				color.engine = {95,146,85,255}
			elseif getElementData(parent,"Engine_inVehicle_HP") <= 300 and getElementData(parent,"Engine_inVehicle_HP") > 150 and getElementData(parent,"Engine_inVehicle") == getElementData(inVehicle,"needengine") then
				color.engine = {180,180,114,135}
			elseif getElementData(parent,"Engine_inVehicle_HP") <= 150 and getElementData(parent,"Engine_inVehicle") == getElementData(inVehicle,"needengine") then
				color.engine = {244,122,42,255}
			else
				color.engine = {199,40,40,255}
			end
			if getElementData(parent,"Parts_inVehicle_HP") <= 400 and getElementData(parent,"Parts_inVehicle_HP") > 300 and getElementData(parent,"Parts_inVehicle") == getElementData(inVehicle,"needparts") then
				color.parts = {80,190,80,135}
			elseif getElementData(parent,"Parts_inVehicle_HP") <= 300 and getElementData(parent,"Parts_inVehicle_HP") > 150 and getElementData(parent,"Parts_inVehicle") == getElementData(inVehicle,"needparts") then
				color.parts = {180,180,114,135}
			elseif getElementData(parent,"Parts_inVehicle_HP") <= 150 and getElementData(parent,"Parts_inVehicle") == getElementData(inVehicle,"needparts") then
				color.parts = {244,122,42,255}
			else
				color.parts = {199,40,40,255}
			end
			if getElementData(parent,"Tire_inVehicle_HP") <= 400 and getElementData(parent,"Tire_inVehicle_HP") > 300 and getElementData(parent,"Tire_inVehicle") == getElementData(inVehicle,"needtires") then
				color.tire = {80,190,80,135}
			elseif getElementData(parent,"Tire_inVehicle_HP") <= 300 and getElementData(parent,"Tire_inVehicle_HP") > 150 and getElementData(parent,"Tire_inVehicle") == getElementData(inVehicle,"needtires") then
				color.tire = {180,180,114,135}
			elseif getElementData(parent,"Tire_inVehicle_HP") <= 150 and getElementData(parent,"Tire_inVehicle") == getElementData(inVehicle,"needtires") then
				color.tire = {244,122,42,255}
			else
				color.tire = {199,40,40,255}
			end
			
			if getElementHealth(inVehicle) > 500 then
                color.health = {95,146,85,255}
			elseif getElementHealth(inVehicle) < 500 and getElementHealth(inVehicle) > 350 then
                color.health = {180,180,114,135}
			elseif getElementHealth(inVehicle) <= 350 then
                color.health = {200,30,30,135}
			else
				color.tire = {199,40,40,255}
			end
			-- fuel
			dxDrawBoxFon(sZ[1] * 0.010,sZ[2] * 0.450,10,-150,tocolor(0,0,0,135),tocolor(0,0,0,255))
			dxDrawBoxFon(sZ[1] * 0.010,sZ[2] * 0.450,10,-fuel,tocolor(unpack(color.fuel)),tocolor(0,0,0,0))
			-- armor points
			if armor > 0 then
				dxDrawBoxFon(sZ[1] * 0.070,sZ[2] * 0.450,10,-150,tocolor(0,0,0,255),tocolor(0,0,0,255))
				dxDrawBoxFon(sZ[1] * 0.070,sZ[2] * 0.450,10,-armor,tocolor(unpack(color.armor)),tocolor(0,0,0,0))
			end	
			-- engine
			dxDrawBoxFon(sZ[1] * 0.025,sZ[2] * 0.331,37,17,tocolor(unpack(color.engine)),tocolor(0,0,0,255))
			--dxDrawText("ENG",sZ[1] * 0.029,sZ[2] * 0.340,40,20,tocolor(255,255,255,255),1,"default-bold")
			dxDrawText("ENG",sZ[1] * 0.029,sZ[2] * 0.333,40,20,tocolor(0,0,0,255),0.85,"default-bold")
			
			
			-- dxDrawText("ENG", (screenW * 0.0266) + 1, (screenH * 0.3369) + 1, (screenW * 0.0578) + 1, (screenH * 0.3574) + 1, tocolor(0, 0, 0, 255), 1.10, "default-bold", "center", "center", false, false, false, false, false)
       -- dxDrawText("ENG", screenW * 0.0266, screenH * 0.3369, screenW * 0.0578, screenH * 0.3574, tocolor(255, 255, 255, 255), 1.10, "default-bold", "center", "center", false, false, false, false, false)
			-- Parts
			dxDrawBoxFon(sZ[1] * 0.025,sZ[2] * 0.355,37,17,tocolor(unpack(color.parts)),tocolor(0,0,0,255))
			dxDrawText("PARTS",sZ[1] * 0.029,sZ[2] * 0.357,40,20,tocolor(0,0,0,255),0.85,"default-bold")
			-- Whl
			dxDrawBoxFon(sZ[1] * 0.025,sZ[2] * 0.383,37,17,tocolor(unpack(color.tire)),tocolor(0,0,0,255))
			dxDrawText("WHL",sZ[1] * 0.029,sZ[2] * 0.383,40,20,tocolor(0,0,0,255),1,"default-bold")
			-- HULL
			dxDrawBoxFon(sZ[1] * 0.025,sZ[2] * 0.305,37,17,tocolor(unpack(color.health)),tocolor(0,0,0,255))
			dxDrawText("HULL",sZ[1] * 0.029,sZ[2] * 0.306,40,20,tocolor(0,0,0,255),0.85,"default-bold")
			checkVehicleMovable(inVehicle)
		end	
	end	
end)

function dxDrawBoxFon(x, y, w, h, rcolor, lcolor)
	dxDrawRectangle(x, y, w, h, rcolor)
	dxDrawLine(x - 1, y - 1, x - 1, y + h, lcolor, 1)
	dxDrawLine(x + w, y - 1, x + w, y + h, lcolor, 1)
	dxDrawLine(x - 1, y + h, x + w, y + h, lcolor, 1)
	dxDrawLine(x - 1, y - 1, x + w, y - 1, lcolor, 1)
end

function drawLine(x,y,w,h,lcolor)
	dxDrawLine(x - 1, y + h, x + w, y + h, lcolor, 1)
end

function checkVehicleMovable(veh)
	if isElement(veh) then
		local parent = getElementData(veh,"parent") 
		if parent then
			if ((getElementData(parent,"Tire_inVehicle") or 0) ~= getElementData(veh,"needtires")) then
				setVehicleEngineState(veh,false)
				return	
			end
			if ((getElementData(parent,"Engine_inVehicle") or 0) ~= getElementData(veh,"needengine")) then
				setVehicleEngineState(veh,false)
				return
			end
			if ((getElementData(parent,"Parts_inVehicle") or 0) ~= getElementData(veh,"needparts")) then 
				setVehicleEngineState (veh,false) 
				return 
			end
		end	
	end	
end

 

Share this post


Link to post
addEventHandler("onClientRender",getRootElement(),
function()
	local inVehicle = getPedOccupiedVehicle(getLocalPlayer())
	if inVehicle and isPedInVehicle(localPlayer) and getVehicleController(inVehicle) then
	   local parent = getElementData(inVehicle,"parent")  --/> Adicionado
		if parent and fuel and armor then
        ---/> Adicione o resto do script 

Tente isso

  • Thanks 1

Share this post


Link to post
On 11/02/2020 at 00:17, Angelo Pereira said:

addEventHandler("onClientRender",getRootElement(),function()	local inVehicle = getPedOccupiedVehicle(getLocalPlayer())	if inVehicle and isPedInVehicle(localPlayer) and getVehicleController(inVehicle) then	   local parent = getElementData(inVehicle,"parent")  --/> Adicionado		if parent and fuel and armor then        ---/> Adicione o resto do script 

Tente isso

Eu havia tentado isto também, porém sem resultado, mas valeu pela tentativa de ajudar

Share this post


Link to post
19 minutes ago, Lukkas2201 said:

Eu havia tentado isto também, porém sem resultado, mas valeu pela tentativa de ajudar

Oque você já tentou?

if parent and fuel and armor then

Provavelmente esteja faltando algo no scritp "fuel" e "armor"

Você precisará enviar o server-side para nós ter uma ideia do que esteja errado.

details = {
	{"Tire_inVehicle"},
	{"Engine_inVehicle"},
	{"Parts_inVehicle"},
}

Existe uma tabela que não esta sendo utilizada, para o que ela serviria neste script?

Edited by Angelo Pereira
  • Thanks 1

Share this post


Link to post
On 12/02/2020 at 00:30, Angelo Pereira said:

Oque você já tentou?


if parent and fuel and armor then

Provavelmente esteja faltando algo no scritp "fuel" e "armor"

Você precisará enviar o server-side para nós ter uma ideia do que esteja errado.


details = {
	{"Tire_inVehicle"},
	{"Engine_inVehicle"},
	{"Parts_inVehicle"},
}

Existe uma tabela que não esta sendo utilizada, para o que ela serviria neste script?

consegui já irmão, na verdade o bug era na propria gm, onde estava alterado a tabela, por isso não estava batendo, mas mesmo assim agradeço novamente

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.