Jump to content

attempt to compare boolean with number


Robis

Recommended Posts

This looks like dayz.

You should make a check to see if getElementData(veh,"parent") is an element and if its "fuel" data is a number.

local parent = getElementData(veh,"parent")
if isElement(parent) and tonumber(getElementData(parent,"fuel"))then
  if getElementData(parent,"fuel") <= 0 then
    -- code

 

Link to comment
Just now, loki2143 said:

This looks like dayz.

You should make a check to see if getElementData(veh,"parent") is an element and if its "fuel" data is a number.


local parent = getElementData(veh,"parent")
if isElement(parent) and tonumber(getElementData(parent,"fuel"))then
  if getElementData(parent,"fuel") <= 0 then
    -- code

 

I cant understand?

Heres my function - how should i replace with it?

function setEngineStateByPlayer (playersource)
	if getElementData(getElementData(veh,"parent"),"fuel") <= 0 then
		outputChatBox("This vehicle tank is empty!", playersource, 255, 22, 0)
		return
	end
	local veh = getPedOccupiedVehicle (playersource)
	setVehicleEngineState (veh, not getVehicleEngineState(veh))
	if getVehicleEngineState(veh) == true then
		triggerClientEvent (playersource, "displayClientInfo", playersource,"Vehicle","You started the Engine.",22,255,0)
	else
		triggerClientEvent (playersource, "displayClientInfo", playersource,"Vehicle","You stopped the Engine. ",255,22,0)
	end
end

 

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