Jump to content

Expecting elements, got boolean.


Recommended Posts

Hello! I have the following problem:
Fx1SgJ5.png
It is really annoying, because i don't know why is this happening.
Whether i am in the car or not, it is spamming the debugscript, and starts, after i sat in the vehicle.

function getJarmuElet()
	local jatekosVehicle = getPedOccupiedVehicle ( localPlayer )
	local jarmuHealth = getElementHealth ( jatekosVehicle ) / 10
	if jatekosVehicle and jarmuHealth then
		return jarmuHealth
	else
		return nil
	end
end
if jarmuHealth > 80 then
	dxDrawText ("Jármű: #42f448OK!", 1480/devX*jatekosX, 802.5/devY*jatekosY, _, _, _, _, "default-bold", _, _, _, _, _, true)
elseif jarmuHealth  <= 79 and jarmuHealth >= 51 then
	dxDrawText ("Jármű: #f49141STOP!", 1475/devX*jatekosX, 802.5/devY*jatekosY, _, _, _, _, "default-bold", _, _, _, _, _, true)
elseif jarmuHealth <= 50 then
	dxDrawText ("Jármű: #f45241SERV!", 1475/devX*jatekosX, 802.5/devY*jatekosY, _, _, _, _, "default-bold", _, _, _, _, _, true)
end

jarmuHealth's definition in the other function:

local jatekosVehicle = getPedOccupiedVehicle (localPlayer) --this one is defined as well, because later there are some things that need the vehicle element
local jarmuHealth = getJarmuElet()


Line 23 is the 3d line of function getJarmuElet. Sorry for hungarian namings, i already got used to it, but trying to use mixed languages in production code, and trying to use full english next time. :D But please help, i really don't know what the problem is.

Link to comment
function getJarmuElet()
	local jatekosVehicle = getPedOccupiedVehicle ( localPlayer )
	if not jatekosVehicle then return end
	local jarmuHealth = getElementHealth ( jatekosVehicle ) / 10
	if jatekosVehicle and jarmuHealth then
		return jarmuHealth
	else
		return nil
	end
end

try this

  • Like 1
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...