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

Lua items block

T

Tibia Demon

Guest
i had this script in data/events and was working and now don't work in events or when i try to move it to data/scripts
what i have wrong on it? tfs 1.4.2
Lua:
local BLOCK_ITEM_WITH_ACTION = 8000
local blockedActions = {4373, 4374, 4375, 4376, 4377, 4378, 4379, 4340, 4342, 4344, 4355, 4361, 4363, 4364, 4366, 4367, 4368, 4369, 4370, 4380}

local ec = EventCallback

function ec.onMoveItem(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if item:getActionId() == BLOCK_ITEM_WITH_ACTION then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            return false
    end
    local tile = Tile(toPosition)
    if tile then
    local ground = tile:getGround()
    if table.contains(blockedActions, ground:getActionId()) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return false
    end
        return true
    end
end
ec:register()
 
Last edited by a moderator:
it show (test msg.) but it never return false idk why
Lua:
local blockedActions = {4373, 4374, 4375, 4376, 4377, 4378, 4379, 4340, 4342, 4344, 4355, 4361, 4363, 4364, 4366, 4367, 4368, 4369, 4370, 4380}

local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if item:getActionId() == actionIds.blockAction then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
            return false
    end
    local tile = Tile(toPosition)
    if tile then
    local ground = tile:getGround()
    if table.contains(blockedActions, ground:getActionId()) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
        return false
        end
    end
    return true
end
ec:register()
i tried 4 other scripts from otland and all no work too
this is my onMoveItem
Lua:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if hasEventCallback(EVENT_CALLBACK_ONMOVEITEM) then
        return EventCallback(EVENT_CALLBACK_ONMOVEITEM, self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    end
    return RETURNVALUE_NOERROR
end
and i have onMoveItem on in xml
 
Lua:
local blockedActions = {4373, 4374, 4375, 4376, 4377, 4378, 4379, 4340, 4342, 4344, 4355, 4361, 4363, 4364, 4366, 4367, 4368, 4369, 4370, 4380}

local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if item:getActionId() == actionIds.blockAction then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
            return RETURNVALUE_NOTPOSSIBLE
    end
    local tile = Tile(toPosition)
    if tile then
    local ground = tile:getGround()
    if table.contains(blockedActions, ground:getActionId()) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
        return RETURNVALUE_NOTPOSSIBLE
        end
    end
    return true
end
ec:register()

try.
 
What about using a classic method, same result?

Code:
function ec.onMoveItem(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
same. not working too
Lua:
local blockedActions = {4373, 4374, 4375, 4376, 4377, 4378, 4379, 4340, 4342, 4344, 4355, 4361, 4363, 4364, 4366, 4367, 4368, 4369, 4370, 4380}

local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if item:getActionId() == actionIds.blockAction then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
            return RETURNVALUE_NOTPOSSIBLE
    end
    local tile = Tile(toPosition)
    if tile then
    local ground = tile:getGround()
    if table.contains(blockedActions, ground:getActionId()) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
        return RETURNVALUE_NOTPOSSIBLE
        end
    end
    return true
end
ec:register()

try.
doesnt work. show test msg and show not possible msg but don't return false. items still move.
 
i downloaded new 1.4.2 and 0 edits
and i tried this 2 scripts and the 2 no work. so it's bug in 1.4.2 or my on my 2 scripts?
Lua:
local blockActionitems = 8000
local blockedActions = {4373, 4374, 4375, 4376, 4377, 4378, 4379, 4340, 4342, 4344, 4355, 4361, 4363, 4364, 4366, 4367, 4368, 4369, 4370, 4380}

local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if (item:getActionId() == blockActionitems) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
            return false
    end
    local tile = Tile(toPosition)
    if tile then
    local ground = tile:getGround()
    if table.contains(blockedActions, ground:getActionId()) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
        return false
        end
    end
    return true
end
ec:register()local blockActionitems = 8000
local blockedActions = {4373, 4374, 4375, 4376, 4377, 4378, 4379, 4340, 4342, 4344, 4355, 4361, 4363, 4364, 4366, 4367, 4368, 4369, 4370, 4380}

local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if (item:getActionId() == blockActionitems) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
            return false
    end
    local tile = Tile(toPosition)
    if tile then
    local ground = tile:getGround()
    if table.contains(blockedActions, ground:getActionId()) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
        return false
        end
    end
    return true
end
ec:register()
Lua:
local blockActionitems = 8000
local blockedActions = {4373, 4374, 4375, 4376, 4377, 4378, 4379, 4340, 4342, 4344, 4355, 4361, 4363, 4364, 4366, 4367, 4368, 4369, 4370, 4380}

local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if (item:getActionId() == blockActionitems) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
            return RETURNVALUE_NOERROR
    end
    local tile = Tile(toPosition)
    if tile then
    local ground = tile:getGround()
    if table.contains(blockedActions, ground:getActionId()) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
        return RETURNVALUE_NOERROR
        end
    end
    return true
end
ec:register()
 
Use return RETURNVALUE_NOTPOSSIBLE to block the move.
i tried and no work
Lua:
local blockActionitems = 8000
local blockedActions = {4373, 4374, 4375, 4376, 4377, 4378, 4379, 4340, 4342, 4344, 4355, 4361, 4363, 4364, 4366, 4367, 4368, 4369, 4370, 4380}

local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if (item:getActionId() == blockActionitems) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
            return RETURNVALUE_NOTPOSSIBLE
    end
    local tile = Tile(toPosition)
    if tile then
    local ground = tile:getGround()
    if table.contains(blockedActions, ground:getActionId()) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
        return RETURNVALUE_NOTPOSSIBLE
        end
    end
    return true
end
ec:register()
 
looks like problem its in callback, just move the whole code straight into player.lua in data/events/
i tried this in data/events/player.lua and it don't work i add there like this
Lua:
local blockedActions = {4373, 4374, 4375, 4376, 4377, 4378, 4379, 4340, 4342, 4344, 4355, 4361, 4363, 4364, 4366, 4367, 4368, 4369, 4370, 4380}
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if (item:getActionId() == 8000) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
            return false
    end
    local tile = Tile(toPosition)
    if tile then
    local ground = tile:getGround()
    if table.contains(blockedActions, ground:getActionId()) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
        return false
        end
    end
    if hasEventCallback(EVENT_CALLBACK_ONMOVEITEM) then
        return EventCallback(EVENT_CALLBACK_ONMOVEITEM, self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    end
    return RETURNVALUE_NOERROR
end
 
change the return false to return RETURNVALUE_NOTPOSSIBLE
Lua:
local blockedActions = {4373, 4374, 4375, 4376, 4377, 4378, 4379, 4340, 4342, 4344, 4355, 4361, 4363, 4364, 4366, 4367, 4368, 4369, 4370, 4380}
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if (item:getActionId() == 8000) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
            return RETURNVALUE_NOTPOSSIBLE
    end
    local tile = Tile(toPosition)
    if tile then
    local ground = tile:getGround()
    if table.contains(blockedActions, ground:getActionId()) then
            self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            self:sendTextMessage(MESSAGE_INFO_DESCR, 'test msg.')
        return RETURNVALUE_NOTPOSSIBLE
        end
    end
    if hasEventCallback(EVENT_CALLBACK_ONMOVEITEM) then
        return EventCallback(EVENT_CALLBACK_ONMOVEITEM, self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    end
    return RETURNVALUE_NOERROR
end
this work. problem was in callback. any idea how to fix it?
i use tfs 1.4.2 no edits downloaded now its bug in tfs 1.4.2
 
Last edited by a moderator:
Back
Top