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

Tibia 12 store - Casks and Kegs not working.

d0gw4r

New Member
Joined
Jun 6, 2019
Messages
55
Solutions
1
Reaction score
4
Location
Brazil
Hello there,

I'm using TFS 1.3 and the problem is that when I buy a keg or cask in the shop, it's delivered, but when I use them, it just don't work.

Here is the following files:

/data/actions/others/variables/CaskKegs.lua

Lua:
local targetIdList = {
     --health potions casks
    [28555] = {itemId = 7636, transform = 7618}, [28579] = {itemId = 7636, transform = 7618}, -- Health Potion --
     [28556] = {itemId = 7634, transform = 7588}, [28580] = {itemId = 7634, transform = 7588}, -- Strong Health --
     [28557] = {itemId = 7635, transform = 7591}, [28581] = {itemId = 7635, transform = 7591}, -- Great Health --
     [28558] = {itemId = 7635, transform = 8473}, [28582] = {itemId = 7635, transform = 8473}, -- Ultimate Health --
     [28559] = {itemId = 7635, transform = 26031}, [28583] = {itemId = 7635, transform = 26031}, -- Supreme Health --
     --mana potions casks
     [28565] = {itemId = 7636, transform = 7620}, [28584] = {itemId = 7636, transform = 7620}, -- Mana Potion --
     [28566] = {itemId = 7634, transform = 7589}, [28585] = {itemId = 7634, transform = 7589}, -- Strong Mana --
     [28567] = {itemId = 7635, transform = 7590}, [28586] = {itemId = 7635, transform = 7590}, -- Great Mana --
     [28568] = {itemId = 7635, transform = 26029}, [28587] = {itemId = 7635, transform = 26029}, -- Ultimate Mana --
     --spirit potions caks
     [28575] = {itemId = 7635, transform = 8472}, [28589] = {itemId = 7635, transform = 8472}, -- Great Spirit --
     [28576] = {itemId = 7635, transform = 26030}, [28590] = {itemId = 7635, transform = 26030}, --Ultimate Spirit --
 }

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target:getId() >= 28535 and target:getId() <= 28590 then
    local house = player:getTile():getHouse()
    if house and house:canEditAccessList(SUBOWNER_LIST, player) and house:canEditAccessList(doorId, player) or target:getId() >= 28579 then
    elseif target:getId() >= 28535 and target:getId() < 28579 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Sorry, casks only can be useds inside house.')
        return false
    else
        return false
    end

    if target then
        local charges = target:getCharges()
         if item:getCount() > charges then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('Sorry, only Remaining %s charges.', charges))
            return false
        end

         local targetId = targetIdList[target:getId()]
         if targetId then
             if item:getId() == targetId.itemId then
                item:transform(targetId.transform)
                charges = charges - item:getCount()
                target:transform(target:getId(), charges)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('Remaining %s charges.', charges))

                if charges == 0 then
                    target:remove()
                end
             end
         end
    end
    return true
end
end

/data/actions/actions.xml

XML:
<action fromid="7634" toid="7636" script="others/variables/caskKegs.lua"/>
 
Solution
Hello there,

I'm using TFS 1.3 and the problem is that when I buy a keg or cask in the shop, it's delivered, but when I use them, it just don't work.

Here is the following files:

/data/actions/others/variables/CaskKegs.lua

Lua:
local targetIdList = {
     --health potions casks
    [28555] = {itemId = 7636, transform = 7618}, [28579] = {itemId = 7636, transform = 7618}, -- Health Potion --
     [28556] = {itemId = 7634, transform = 7588}, [28580] = {itemId = 7634, transform = 7588}, -- Strong Health --
     [28557] = {itemId = 7635, transform = 7591}, [28581] = {itemId = 7635, transform = 7591}, -- Great Health --
     [28558] = {itemId = 7635, transform = 8473}, [28582] = {itemId = 7635, transform = 8473}, -- Ultimate Health --
     [28559] = {itemId =...
Hello there,

I'm using TFS 1.3 and the problem is that when I buy a keg or cask in the shop, it's delivered, but when I use them, it just don't work.

Here is the following files:

/data/actions/others/variables/CaskKegs.lua

Lua:
local targetIdList = {
     --health potions casks
    [28555] = {itemId = 7636, transform = 7618}, [28579] = {itemId = 7636, transform = 7618}, -- Health Potion --
     [28556] = {itemId = 7634, transform = 7588}, [28580] = {itemId = 7634, transform = 7588}, -- Strong Health --
     [28557] = {itemId = 7635, transform = 7591}, [28581] = {itemId = 7635, transform = 7591}, -- Great Health --
     [28558] = {itemId = 7635, transform = 8473}, [28582] = {itemId = 7635, transform = 8473}, -- Ultimate Health --
     [28559] = {itemId = 7635, transform = 26031}, [28583] = {itemId = 7635, transform = 26031}, -- Supreme Health --
     --mana potions casks
     [28565] = {itemId = 7636, transform = 7620}, [28584] = {itemId = 7636, transform = 7620}, -- Mana Potion --
     [28566] = {itemId = 7634, transform = 7589}, [28585] = {itemId = 7634, transform = 7589}, -- Strong Mana --
     [28567] = {itemId = 7635, transform = 7590}, [28586] = {itemId = 7635, transform = 7590}, -- Great Mana --
     [28568] = {itemId = 7635, transform = 26029}, [28587] = {itemId = 7635, transform = 26029}, -- Ultimate Mana --
     --spirit potions caks
     [28575] = {itemId = 7635, transform = 8472}, [28589] = {itemId = 7635, transform = 8472}, -- Great Spirit --
     [28576] = {itemId = 7635, transform = 26030}, [28590] = {itemId = 7635, transform = 26030}, --Ultimate Spirit --
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target:getId() >= 28535 and target:getId() <= 28590 then
    local house = player:getTile():getHouse()
    if house and house:canEditAccessList(SUBOWNER_LIST, player) and house:canEditAccessList(doorId, player) or target:getId() >= 28579 then
    elseif target:getId() >= 28535 and target:getId() < 28579 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Sorry, casks only can be useds inside house.')
        return false
    else
        return false
    end

    if target then
        local charges = target:getCharges()
         if item:getCount() > charges then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('Sorry, only Remaining %s charges.', charges))
            return false
        end

         local targetId = targetIdList[target:getId()]
         if targetId then
             if item:getId() == targetId.itemId then
                item:transform(targetId.transform)
                charges = charges - item:getCount()
                target:transform(target:getId(), charges)
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('Remaining %s charges.', charges))

                if charges == 0 then
                    target:remove()
                end
             end
         end
    end
    return true
end
end

/data/actions/actions.xml

XML:
<action fromid="7634" toid="7636" script="others/variables/caskKegs.lua"/>
well, I can share you the one we use

Lua:
local targetIdList = {
     --health potions casks                       -- health potion kegs
    [28553] = {itemId = 7636, transform = 7618}, [28577] = {itemId = 7636, transform = 7618}, -- Health Potion --
     [28554] = {itemId = 7634, transform = 7588}, [28578] = {itemId = 7634, transform = 7588}, -- Strong Health --
     [28555] = {itemId = 7635, transform = 7591}, [28579] = {itemId = 7635, transform = 7591}, -- Great Health --
     [28556] = {itemId = 7635, transform = 8473}, [28580] = {itemId = 7635, transform = 8473}, -- Ultimate Health --
     [28557] = {itemId = 7635, transform = 26031}, [28581] = {itemId = 7635, transform = 26031}, -- Supreme Health --
     --mana potions casks                         -- mana potion kegs
     [28563] = {itemId = 7636, transform = 7620}, [28582] = {itemId = 7636, transform = 7620}, -- Mana Potion --
     [28564] = {itemId = 7634, transform = 7589}, [28583] = {itemId = 7634, transform = 7589}, -- Strong Mana --
     [28565] = {itemId = 7635, transform = 7590}, [28584] = {itemId = 7635, transform = 7590}, -- Great Mana --
     [28566] = {itemId = 7635, transform = 26029}, [28585] = {itemId = 7635, transform = 26029}, -- Ultimate Mana --
     --spirit potions caks                        -- spirit potion kegs
     [28573] = {itemId = 7635, transform = 8472}, [28587] = {itemId = 7635, transform = 8472}, -- Great Spirit --
     [28574] = {itemId = 7635, transform = 26030}, [28588] = {itemId = 7635, transform = 26030} --Ultimate Spirit --
 }

 function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    local targetId = targetIdList[item.itemid]
    local targetItem = Item(target.uid)
    local exItem
    
    if not targetId and targetItem then
        targetId = targetIdList[targetItem.itemid]
        if targetId and item.itemid ~= targetId.itemId then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to use the correct flask.")
            return true
        end
        exItem = item
        item = targetItem
    end

    if targetId then
        if isCaskItem(item.itemid) then
            local house = item:getTile():getHouse()
            if house and not house:hasAccessToItems(player) then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This action is not permitted, if you do not have access to the house.")
                return true
            end
        end

        local charges = item:getCharges()
        local total = exItem and exItem.type or player:getItemCount(targetId.itemId)
        if total == 0 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Make sure you have enough free vials.")
            return true
        end

        local toAdd = 0
        local capacity = player:getFreeCapacity()
        local newcap
        for _ = 1, math.min(charges, total) do
            newcap = capacity + (exItem and 0 or ItemType(targetId.itemId):getWeight()) - ItemType(targetId.transform):getWeight()
            if newcap < 0 then
                break
            end
            toAdd = toAdd + 1
            capacity = newcap
        end
        if toAdd == 0 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Make sure you have enough free capacity.")
            return true
        end
        
        local inbox = player:getSlotItem(CONST_SLOT_STORE_INBOX)
        local num = math.ceil(toAdd / 100)
        if not inbox or inbox:getEmptySlots() < num then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Make sure you have enough free slots at your store inbox.")
            return true
        end
        local totalAdded = 0
        for _ = 1, num do
            local toRest = math.min(toAdd, 100)
            if exItem then exItem:remove(toRest) else player:removeItem(targetId.itemId, toRest) end
            local addedItem = inbox:addItem(targetId.transform, toRest)
            if not addedItem then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Cannot refill more potions.")
                break
            end
            totalAdded = totalAdded + toRest
            toAdd = toAdd - toRest
        end
        local set = math.max(0, charges - totalAdded)
        if set == 0 then
            item:remove()
        else
            item:setCharges(set)
        end
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, totalAdded > 0 and string.format('%s %s refilled, %s charges remaining.', totalAdded, totalAdded > 1 and 'vials' or 'vial', item:getCharges()) or string.format('%s %s refilled.', totalAdded, totalAdded > 1 and 'vials' or 'vial'))
    end
    return true   
end

btw you need to fix the part where I check the house, because thats an internal function we added.
Also add this to actions

XML:
    <action fromid="7634" toid="7636" script="other/caskkegs.lua" allowfaruse="1"/>
    <action fromid="28553" toid="28588" script="other/caskkegs.lua"/>

it should work as cipbia does.
 
Solution
well, I can share you the one we use

Lua:
local targetIdList = {
     --health potions casks                       -- health potion kegs
    [28553] = {itemId = 7636, transform = 7618}, [28577] = {itemId = 7636, transform = 7618}, -- Health Potion --
     [28554] = {itemId = 7634, transform = 7588}, [28578] = {itemId = 7634, transform = 7588}, -- Strong Health --
     [28555] = {itemId = 7635, transform = 7591}, [28579] = {itemId = 7635, transform = 7591}, -- Great Health --
     [28556] = {itemId = 7635, transform = 8473}, [28580] = {itemId = 7635, transform = 8473}, -- Ultimate Health --
     [28557] = {itemId = 7635, transform = 26031}, [28581] = {itemId = 7635, transform = 26031}, -- Supreme Health --
     --mana potions casks                         -- mana potion kegs
     [28563] = {itemId = 7636, transform = 7620}, [28582] = {itemId = 7636, transform = 7620}, -- Mana Potion --
     [28564] = {itemId = 7634, transform = 7589}, [28583] = {itemId = 7634, transform = 7589}, -- Strong Mana --
     [28565] = {itemId = 7635, transform = 7590}, [28584] = {itemId = 7635, transform = 7590}, -- Great Mana --
     [28566] = {itemId = 7635, transform = 26029}, [28585] = {itemId = 7635, transform = 26029}, -- Ultimate Mana --
     --spirit potions caks                        -- spirit potion kegs
     [28573] = {itemId = 7635, transform = 8472}, [28587] = {itemId = 7635, transform = 8472}, -- Great Spirit --
     [28574] = {itemId = 7635, transform = 26030}, [28588] = {itemId = 7635, transform = 26030} --Ultimate Spirit --
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    local targetId = targetIdList[item.itemid]
    local targetItem = Item(target.uid)
    local exItem
  
    if not targetId and targetItem then
        targetId = targetIdList[targetItem.itemid]
        if targetId and item.itemid ~= targetId.itemId then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to use the correct flask.")
            return true
        end
        exItem = item
        item = targetItem
    end

    if targetId then
        if isCaskItem(item.itemid) then
            local house = item:getTile():getHouse()
            if house and not house:hasAccessToItems(player) then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This action is not permitted, if you do not have access to the house.")
                return true
            end
        end

        local charges = item:getCharges()
        local total = exItem and exItem.type or player:getItemCount(targetId.itemId)
        if total == 0 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Make sure you have enough free vials.")
            return true
        end

        local toAdd = 0
        local capacity = player:getFreeCapacity()
        local newcap
        for _ = 1, math.min(charges, total) do
            newcap = capacity + (exItem and 0 or ItemType(targetId.itemId):getWeight()) - ItemType(targetId.transform):getWeight()
            if newcap < 0 then
                break
            end
            toAdd = toAdd + 1
            capacity = newcap
        end
        if toAdd == 0 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Make sure you have enough free capacity.")
            return true
        end
      
        local inbox = player:getSlotItem(CONST_SLOT_STORE_INBOX)
        local num = math.ceil(toAdd / 100)
        if not inbox or inbox:getEmptySlots() < num then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Make sure you have enough free slots at your store inbox.")
            return true
        end
        local totalAdded = 0
        for _ = 1, num do
            local toRest = math.min(toAdd, 100)
            if exItem then exItem:remove(toRest) else player:removeItem(targetId.itemId, toRest) end
            local addedItem = inbox:addItem(targetId.transform, toRest)
            if not addedItem then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Cannot refill more potions.")
                break
            end
            totalAdded = totalAdded + toRest
            toAdd = toAdd - toRest
        end
        local set = math.max(0, charges - totalAdded)
        if set == 0 then
            item:remove()
        else
            item:setCharges(set)
        end
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, totalAdded > 0 and string.format('%s %s refilled, %s charges remaining.', totalAdded, totalAdded > 1 and 'vials' or 'vial', item:getCharges()) or string.format('%s %s refilled.', totalAdded, totalAdded > 1 and 'vials' or 'vial'))
    end
    return true 
end

btw you need to fix the part where I check the house, because thats an internal function we added.
Also add this to actions

XML:
    <action fromid="7634" toid="7636" script="other/caskkegs.lua" allowfaruse="1"/>
    <action fromid="28553" toid="28588" script="other/caskkegs.lua"/>

it should work as cipbia does.

Now it says:

"You cannot use this object."

How do I fix that part which you said where you check the house?

And thank you for helping me!
 
What you mean with you cannot use this object?
Maybe you set the wrong ids (opentibiabr changed some ids idk why), try to change the ids and just remove the part of the house check just to test.
 
What you mean with you cannot use this object?
Maybe you set the wrong ids (opentibiabr changed some ids idk why), try to change the ids and just remove the part of the house check just to test.

I mean, when I click on the casks I get this message in game console.

I gonna test your suggestion and soon as I can I gonna edit this post with the results. Thanks!
 
I changed the ids of casks and kegs and I'm still getting the message: "You cannot use this item", when I try to refill empty potions.
 
Now it worked, I was missing the script path in actions.xml. Thanks!

But now when I'm purchasing kegs, it don't gives me a box (like parcel) with the keg inside to be used inside a house. Only an empty shop bag. Can you help me with this? 😬
 
Back
Top