• 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!

TFS 1.X+ getUniqueId on door item does not work

overdriven

Active Member
Joined
Mar 10, 2020
Messages
70
Solutions
1
Reaction score
42
I just want to get Unique ID of an item (the same Unique ID you set in Remere, not uid because it's not the same thing, right?).

I'm doing everything according to the scripting documentation:
I have a closed door which is technically an item (right?), so I should be able to use getUniqueId on these door, but I can't, it returns:
"attempt to call method 'getUniqueId' (a nil value))"

When I look at these door in client I see they have assigned Unique ID properly. So why can't I get them with getUniqueId?

Lua:
local doorLeftPos = {x = 32598, y = 31939, z = 3}
local leftDoor = getTileItemById(doorLeftPos, 1212)

player:say(tostring(leftDoor), TALKTYPE_MONSTER_SAY) -- returns a table
player:say(tostring(leftDoor:getUniqueId()), TALKTYPE_MONSTER_SAY) -- throws error (attempt to call method 'getUniqueId' (a nil value))
Post automatically merged:

I think I understand what's wrong.

I'm getting door of type 1212, but actually I should be getting 1213.
Old syntax (getTileItemById) bamboozled me, it made me think I'm getting something (since it returns a table), but actually I'm not getting shit, with new syntax (tile:getItemById) it's clearer: I'm getting nil, which helped me notice that item type ID I was trying to get was incorrect.
 
Last edited:
Lua:
local doorLeftPos = {x = 32598, y = 31939, z = 3}
local leftDoor = getTileItemById(doorLeftPos, 1212)
local uniqueid = leftDoor:getAttribute(ITEM_ATTRIBUTE_UNIQUEID)


player:say(tostring(leftDoor), TALKTYPE_MONSTER_SAY) -- returns a table
--player:say(tostring(leftDoor:getUniqueId()), TALKTYPE_MONSTER_SAY) -- throws error (attempt to call method 'getUniqueId' (a nil value))
player:say("Unique Id : " .. uniqueid)
 
Back
Top