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

Unmovable item with actionid in TFS 1.2

hucke.ducke

Tibia the real rpg. <3
Joined
Jul 28, 2019
Messages
37
Reaction score
1
Location
Chile
Hello, i need to make some items unmovable by using an action id so i can mark them in the RME map editor.

I had that system in 0.36 but im super noob with programming, so i know it should be done in the player.lua, and i find something in the forum but doesn't work for my TFS 1.2.

Please can someone help me to make it work on my distro. Thanks !

Lua:
function Player:onMoveItem(item, count, fromPosition, toPosition)
    if blockTeleportTrashing and toPosition.x ~= CONTAINER_POSITION then
        local thing = Tile(toPosition):getItemByType(ITEM_TYPE_TELEPORT)
        if thing then
            self:sendCancelMessage('Sorry, not possible.')
            self:getPosition():sendMagicEffect(CONST_ME_POFF)
            return false
        end
    end

    if isInArray({1714, 1715, 1716, 1717, 1738, 1740, 1741, 1747, 1748, 1749}, item.itemid) and item.actionid > 0 or item.actionid == 5640 then
        self:sendCancelMessage('You cannot move this object.')
        return false
    elseif item.itemid == 7466 then
        self:sendCancelMessage('You cannot move this object.')
        return false
    end
 
I use this for 1.3, Should work for 1.2
Lua:
BLOCK_ITEM_WITH_ACTION = 8000
if item:getActionId() == BLOCK_ITEM_WITH_ACTION then
        self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return false
    end
 
I use this for 1.3, Should work for 1.2
Lua:
BLOCK_ITEM_WITH_ACTION = 8000
if item:getActionId() == BLOCK_ITEM_WITH_ACTION then
        self:sendCancelMessage('You cannot move this object.')
        self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return false
    end
Couple of problems with this though.

Can trade the item.
If the item has the 'Use With' option, the player can 'use with' on a far-away destination, while being 2 sqm away from object, and source will walk the character towards the item, pick it up into inventory, and then attempt to use it on the target destination.

Both methods above cause the item to be stuck in the player inventory forever.

--
So if you block trading of the item, and only use it on items that don't have a use with option, then it's fine.

Otherwise requires a source edit.
 
I use onTradeRequest block too but didn't know if he'll need it or not so I didn't add it on my above reply.
Lua:
function Player:onTradeRequest(target, item)
    if item:getActionId() == BLOCK_ITEM_WITH_ACTION then
        return false
    end
If the item has the 'Use With' option, the player can 'use with' on a far-away destination, while being 2 sqm away from object, and source will walk the character towards the item, pick it up into inventory, and then attempt to use it on the target destination.
Never thought of this, I will have to re-check my items although I think none is useable.
 
Those ones are on player.lua
data\events\scripts\player.lua
Just don't forget to enable
XML:
<event class="Player" method="onMoveItem" enabled="1" />
<event class="Player" method="onTradeRequest" enabled="1" />
 
Couple of problems with this though.

Can trade the item.
If the item has the 'Use With' option, the player can 'use with' on a far-away destination, while being 2 sqm away from object, and source will walk the character towards the item, pick it up into inventory, and then attempt to use it on the target destination.

Both methods above cause the item to be stuck in the player inventory forever.

--
So if you block trading of the item, and only use it on items that don't have a use with option, then it's fine.

Otherwise requires a source edit.
onTradeRequest/accept for trading
use with situation is probably a bug in sources

edit: it's tfs 1.2 bug, in 1.3 it works fine so you have to find a commit that fixed it and apply it manually + compile or use 1.3
 
Last edited:
so which is the script that works for tfs 1.4 to block items with AID from move / use / trade
This is a example for TFS 1.5, it will probably work fine for TFS 1.3+ and 1.4+
 
This is a example for TFS 1.5, it will probably work fine for TFS 1.3+ and 1.4+
thank bro atleast this worked for me, thank you though
Lua:
   if item.actionid == 9502 then
     self:sendCancelMessage('You cannot trade this object.')
     return false
   end
   return true
end
and did the same ontrade request in data/events/player.lua and enabled the code in events.xml
 
Back
Top