Jump to content

Attempt to compare number with boolean


Pirulax

Recommended Posts

  • Discord Moderators

Hello guys, for some reason debugscript is saying this..Heres my script piece:

	setElementData(p, "acc:admin", 7)
	if not getElementData(p, "acc:admin") > 0 then return end

Nothing else changes acc:admin.

Edit: Found the solution:

	setElementData(p, "acc:admin", 7)
	if not (getElementData(p, "acc:admin") > 0) then return end

But, i still don't understand, so can someone explain me whats the difference between those code blocks?

Edited by Pirulax
Link to comment
  • Moderators
getElementData(p, "acc:admin") > 0

 

if not getElementData(p, "acc:admin") > 0 then return end

local numberValue = getElementData(p, "acc:admin") -- 7

outputDebugString(not numberValue) -- false

false > 0 = Attempt to compare number with boolean

 


(getElementData(p, "acc:admin") > 0)

if not (getElementData(p, "acc:admin") > 0) then return end

local numberValue = getElementData(p, "acc:admin") -- 7

outputDebugString(numberValue > 0) -- true

local result = numberValue > 0 -- true

outputDebugString(not result) -- false

 

 


 

( ) <<< priority!

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