• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Compare with boolean

New_Age

FoxWorld New Age
Joined
Jan 27, 2016
Messages
24
Reaction score
0
Hello guys can someone help me with this error:
Attempt to compare number with boolean
Code:
elseif exhaustion.get (cid, 898)> 0 then
 
It worked perfectly but now appears an error in addEvent
luaAddEvent<>. Argument #3 is unsafe

addEvent(Test, 1000, cid)
 
No @Volrath, I could solve the solution here
Code:
local player = Player (cid) if player == nil then return false end
and at the addEvent (Test, 1000, player.uid)
got the solution on github (forgottenserver) issue addEvent

thank you :)
 
Is it no issue with addEvent, you are just not supposed to pass item / creature userdata as an argument.
Doing this might crash your server if the creature does no longer exist, therefore you receive a warning when doing so.
Hope this helps understanding what happened.
 
No @Volrath, I could solve the solution here
Code:
local player = Player (cid) if player == nil then return false end
and at the addEvent (Test, 1000, player.uid)
got the solution on github (forgottenserver) issue addEvent

thank you :)
What you want to do is not pass the userdata (cid) directly to addEvent, a simple solution would be to pass cid in a table or variable
Code:
-- as a variable
local pid = cid
addEvent(Test, 1000, pid)
-- or as a table
local p = {id = cid}
addEvent(Test, 1000, p.id)

-- hypothetic Test function
function Test(playerId)
     if isPlayer(playerId) then
         -- do something
     end
end

When you pass cid to a table or variable, you are not passing the userdata directly, you are
storing the return value of the userdata in the table or variable and passing it to the addEvent,
this is what makes the difference as being safe.
 
Back
Top