Jump to content

Attempt to compare number with nil


Recommended Posts

Posted

Im having an error ( attempt to compare number with nil ), i need some help to fix it! Thanks for all help ❤️

 

local vehFuel = dbPoll(dbQuery(database, "SELECT * FROM playersConce WHERE Account = ?", getAccountName(getPlayerAccount(source))), -1)

if vehFuel["Fuel"] > 0 then <<---- Line with the error
	setElementData(vehicleConces[source], "DNL:Combustivel", vehFuel)
else
    setElementData(vehicleConces[source], "DNL:Combustivel", 100) 
end

 

  • Other Languages Moderators
Posted

Hello.

I guess you should get the index before the column name. Try changing from

vehFuel["Fuel"]

to

vehFuel[1]["Fuel"]

 

  • Like 1
  • Other Languages Moderators
Posted

Whaaaa.

Use iprint function to debug the value of vehFuel[1]["Fuel"]

  • Other Languages Moderators
Posted

Oh, my bad. I didn't explain where the iprint function outputs. It outputs on /debugscript 3. The only thing you need to do is run the command which you are having problems, then you will see on Debugger, some green message.

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