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

player:getItemById tfs 1x

theduck

Member
Joined
Dec 6, 2018
Messages
246
Reaction score
20
Code:
   local nameitem= player:getItemById(item_id , true)

local resultId = db.storeQuery('SELECT `itemname` FROM `teste_list` WHERE `id` = ' .. player:getAccountId() ..  '')
        
local item_id = result.getNumber(resultId, 'itemname')
 
print(itemname)
print(nameitem)

well I'm trying to pull the id of an item and use it in a script
more when i put it inside the player: getItemById it pulls a null value
more when I pull out of function it pulls the correct id that is inside the database
 
Last edited:
Hi,
I don't know what u are trying to do, but to get a name of a item and id, just use this:

Lua:
local item = player:getItemById(2160, true) --Check if player have item with id 2160
if item then --if item exist print item name and item id
    print("Item Name = "..item:getName())
    print("Item Id = "..item:getId())
end

--get info about item of id 2160 and print item name and item id
local item2 = ItemType(2160)
print("Item2 Name = "..item2:getName())
print("Item2 Id = "..item2:getId())
 
Hi,
I don't know what u are trying to do, but to get a name of a item and id, just use this:

Lua:
local item = player:getItemById(2160, true) --Check if player have item with id 2160
if item then --if item exist print item name and item id
    print("Item Name = "..item:getName())
    print("Item Id = "..item:getId())
end

--get info about item of id 2160 and print item name and item id
local item2 = ItemType(2160)
print("Item2 Name = "..item2:getName())
print("Item2 Id = "..item2:getId())
in my database has the id of the item i am trying to pull the id of this item and use it inside the function more when i do this i have the null value


local nameitem= player:getItemById(item_id , true)

local resultId = db.storeQuery('SELECT itemname FROM teste_list WHERE id = ' .. player:getAccountId() .. '')
local item_id = result.getNumber(resultId, 'itemname')


local nameitem= player:getItemById(item_id , true) -- > nill
 
in my database has the id of the item i am trying to pull the id of this item and use it inside the function more when i do this i have the null value


local nameitem= player:getItemById(item_id , true)

local resultId = db.storeQuery('SELECT itemname FROM teste_list WHERE id = ' .. player:getAccountId() .. '')
local item_id = result.getNumber(resultId, 'itemname')


local nameitem= player:getItemById(item_id , true) -- > nill
Send your table schema please.
 
Back
Top