ralke
(҂ ͠❛ ෴ ͡❛)ᕤ
Hi again! I use TFS 1.4 downgraded by nekiro. I did this simple script and I wonder how can I add a reward with action id (specifically a key) with inside a bag with other items. I know that doing something like this will auto-assing the aid to the key:
And this will generate a table for the other items that the bag will hold:
The thing is. How can I add the key inside the bag with cfgItems and make the setActionId work?
This is the sample script I made for this, the key is given outside the bag and that's what I need to solve.
Regards!
Lua:
local key = player:addItem(2091, 1)
if key then
key:setActionId(6010)
end
And this will generate a table for the other items that the bag will hold:
Lua:
local cfgItems = {{2229, 1}, {2151, 2}, {2165, 1}, {2230, 1}}
local bag = player:addItem(1987) -- Bag id
for i = 1, #cfgItems do
bag:addItem(cfgItems[i][1], cfgItems[i][2])
end
The thing is. How can I add the key inside the bag with cfgItems and make the setActionId work?
This is the sample script I made for this, the key is given outside the bag and that's what I need to solve.
Lua:
local cfgItems = {{2229, 1}, {2151, 2}, {2165, 1}, {2230, 1}}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local parchmentStorage = PlayerStorageKeys.ParchmentRoomQuest
local player = Player(cid)
if player:getStorageValue(parchmentStorage) > 0 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The coffin is empty.")
return true
end
local bag = player:addItem(1987) -- Bag id
for i = 1, #cfgItems do
bag:addItem(cfgItems[i][1], cfgItems[i][2])
end
local key = player:addItem(2091, 1)
if key then
key:setActionId(6010)
end
player:setStorageValue(parchmentStorage, 1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a bag.")
toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
return true
end
Regards!
Last edited: