• 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+ lua item in chest do unique id

bemol

New Member
Joined
Dec 4, 2019
Messages
7
Reaction score
0
local config = {
storage = 30005,
item = 2217,
count = 1,
itemname = "You have found a 1 crystal coin!",
itemcallback = "You can not take the prize twice.",
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, config.itemname)
doPlayerAddItem(cid, config.item, config.count)
end

item:setAttribute(ITEM_ATTRIBUTE_ACTIONID, 50501) - when i use this get action id only on chest

<quest />
<action uniqueid="30005" script="quests/crafts.lua" />
P.s thank you
 
Last edited:
Solution
try changing
Lua:
local item_handler = Player(cid):AddItem(config.item, config.count)
to
Lua:
local item_handler = Player(cid):addItem(config.item, config.count)
(replace capital 'A' in AddItem to lower case 'a')
I assume that u want to add actionid "50501" to your item so you have to replace this:
Lua:
doPlayerAddItem(cid, config.item, config.count)
with this:
Lua:
local item_handler = Player(cid):AddItem(config.item, config.count)
item_handler:setAttribute(ITEM_ATTRIBUTE_ACTIONID, 50501)
in your script item refers to chest so item:setAttribute(ITEM_ATTRIBUTE_ACTIONID, 50501) assinged actionid to chest, not the item
 
local config = {
storage = 30005,
item = 2217,
count = 1,
itemname = "You have found a 1 crystal coin!",
itemcallback = "You can not take the prize twice.",
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, config.itemname)
local item_handler = Player(cid):AddItem(config.item, config.count)
item_handler:setAttribute(ITEM_ATTRIBUTE_ACTIONID, 50501)
end

how it work ??
 
Not sure what do you want to know but:
AddItem() returns "handler" for item (1 cc), in this case item which were given to player.
Then you can use functions on this item (in this case setAttribute used to set actionid to 50501)
 
local config = {
storage = 30005,
item = 2217,
count = 1,
itemname = "You have found a 1 crystal coin!",
itemcallback = "You can not take the prize twice.",
}
function
onUse(cid, item, fromPosition, itemEx, toPosition)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, config.itemname)
local item_handler = Player(cid):AddItem(config.item, config.count)
item_handler:setAttribute(ITEM_ATTRIBUTE_ACTIONID, 50501)
end

i dont get item only get message you have found a 1 crystal coin.
bad.png
 
Last edited:
What exactly is or isn't happening? We need more info to help you (console logs, detailed description of problem)
 
try changing
Lua:
local item_handler = Player(cid):AddItem(config.item, config.count)
to
Lua:
local item_handler = Player(cid):addItem(config.item, config.count)
(replace capital 'A' in AddItem to lower case 'a')
 
Solution
Back
Top