player:getItemById tfs 1x

theduck

Member
Joined
Dec 6, 2018
Messages
157
Best answers
0
Reaction score
16
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:

zxmatzx

Well-Known Member
Joined
Dec 1, 2010
Messages
194
Best answers
10
Reaction score
54
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())
 
OP
T

theduck

Member
Joined
Dec 6, 2018
Messages
157
Best answers
0
Reaction score
16
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
 

zxmatzx

Well-Known Member
Joined
Dec 1, 2010
Messages
194
Best answers
10
Reaction score
54
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.
 
Top