• 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+ Cask unwrap Issue & Charges [Tibia Shop+TFS1.3]

Elvarion

Member
Joined
Apr 14, 2010
Messages
99
Reaction score
13
  • Bought casks not getting assigned actionID for unwrap script
  • When unwrapped it only has 1 charge
When you buy a Cask from the Tibia shop it wont get the needed actionID, so it wont know what to unwrap into.
I did manage to somehow make it unwrap to the correct id, but Ive been tinkering with the script so much and had to revert back to an older version and lost that progress. When I managed to make it unwrap correct I ran into another issue. The charges for the cask was not assigned and it was always giving a cask with 1 charge instead of the 1000 charges it should get when bought from the store.
Added 2 prints and both prints in console, so the code is being called for those sections atleast.

If Ive missed any script you need, just let me know.

Using this Distro, [TFS1.3]

Here is the code snip for buying a cask. And here is the full init.lua script.
Lua:
function GameStore.processHouseRelatedPurchase(player, offerId, offerCount)
    local function isCaskItem(itemId)
        return (itemId >= ITEM_HEALTH_CASK_START and itemId <= ITEM_HEALTH_CASK_END) or
        (itemId >= ITEM_MANA_CASK_START and itemId <= ITEM_MANA_CASK_END) or
        (itemId >= ITEM_SPIRIT_CASK_START and itemId <= ITEM_SPIRIT_CASK_END)
    end

    local inbox = player:getSlotItem(CONST_SLOT_STORE_INBOX)
    if inbox and inbox:getEmptySlots() > 0 then
        local decoKit = inbox:addItem(26054, 1)
        local function changeKit(kit)
            local decoItemName = ItemType(offerId):getName()
            if kit then
                kit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a <" .. decoItemName .. ">.")
                kit:setCustomAttribute("unWrapId", offerId)
                print(1)
            
                if isCaskItem(offerId) then
                    kit:setAttribute(ITEM_ATTRIBUTE_DATE, offerCount)
                    print(2)
                end
            end
        end
        addEvent(function() changeKit(decoKit) end, 250)
    else
    return error({code = 0, message = "Please make sure you have free slots in your store inbox."})
    end
end

This part here is a code snip from the values when buying said cask, in this case the normal mana potion cask (yes the code is missing brackets, this is more to show the values that the script above uses.) Full gamestore.lua script can be found here.
Lua:
    {
    icons = { "Category_Potions.png" },
    name = "Casks",
      offers = {
            {
                icons = { "Mana_Cask.png" },
                name = "Mana Cask",
                price = 26,
                id = 28565,
                count = 1000,
                number = 1,
                description = "Desc removed to condense code for easier reading.",
                type = GameStore.OfferTypes.OFFER_TYPE_HOUSE,
            },
 
Back
Top