• 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+ [1.4.2] Block Item On Map.

OTcreator

Active Member
Joined
Feb 14, 2022
Messages
425
Solutions
1
Reaction score
44
Hello!
When i put nothing special in rme can move items.
When i add action ID in rme can move items.
How i can block items on map on tfs 1.4.2?
 
you can just create a simple script which blocks people from moving items
here something like this:

Lua:
local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if item:getActionId() == 9999 then
        return RETURNVALUE_NOTPOSSIBLE
    end
    return true
end

ec:register()

local ec = EventCallback

ec.onTradeRequest = function(self, target, item)
    if item:getActionId() == 9999 then
        return RETURNVALUE_NOTPOSSIBLE
    end
    return true
end

ec:register()

ActionID on item 9999
Idk where else u must block it to make sure people can not take it somehow

I added on Trade Request aswell so they can not take the item by trading
or use 8047 id
 
Last edited by a moderator:
you can just create a simple script which blocks people from moving items
here something like this:

Lua:
local ids = {9999, 6000}

local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if table.contains(ids, item:getActionId()) then
        self:sendTextMessage(MESSAGE_STATUS_DEFAULT, 'Sorry but you can not move this object.')
        return false
    end
    return true
end

ec:register()

local ids = {9999, 6000}

local ec = EventCallback

ec.onTradeRequest = function(self, target, item)
    if table.contains(ids, item:getActionId()) then
        self:sendTextMessage(MESSAGE_STATUS_DEFAULT, 'Sorry but you can not move this object.')
        return false
    end
    return true
end

ec:register()

ActionID on item 9999
Idk where else u must block it to make sure people can not take it somehow

I added on Trade Request aswell so they can not take the item by trading
or use 8047 id

I change 9999 to 2600 (this is my actionID) and not working.
I can move items. Have a text - "Sorry but you can not...." but items still move.
 
Last edited:
Lua:
local ids = {9999, 6000}

local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if table.contains(ids, item:getActionId()) then
        self:sendTextMessage(MESSAGE_STATUS_DEFAULT, 'Sorry but you can not move this object.')
        return RETURNVALUE_NOERROR
    end
    return true
end

ec:register()

local ids = {9999, 6000}

local ec = EventCallback

ec.onTradeRequest = function(self, target, item)
    if table.contains(ids, item:getActionId()) then
        self:sendTextMessage(MESSAGE_STATUS_DEFAULT, 'Sorry but you can not move this object.')
        return RETURNVALUE_NOERROR
    end
    return true
end

ec:register()

Make sure u enabled onMoveItem in events.xml aswell
if that doesn't work then idk
TFS Team does some changes which are not required and makes really hard to help at a point since everything is working different but everything looks the same at that point

I can still move items with an action ID of 2600.
It receives a text that I can't do it but I move them.

I pasted these scripts into a new file in the scripts/eventcallbacks folder.
 
edited my last post try again
NOT WORKING.
Maybe it's me doing something wrong?

I have onMoveItem enabled in events.xml.
I created a new file in data/scripts/eventcallbacks/onBlockItem.lua
and put your script.
I restart server but not working.
 
Take a clear look on rme if you even saved and change this :
Lua:
ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if table.contains(ids, item:getActionId()) then
        self:sendTextMessage(MESSAGE_STATUS_DEFAULT, 'Sorry but you can not move this object.')
        return RETURNVALUE_NOERROR
    end
    return RETURNVALUE_NOERROR
end
to
Lua:
ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if table.contains(ids, item:getActionId()) then
    print(1)
        self:sendTextMessage(MESSAGE_STATUS_DEFAULT, 'Sorry but you can not move this object.')
        print(2)
        return RETURNVALUE_NOERROR
    end
    print(3)
    return RETURNVALUE_NOERROR
end

restart server and show me what it says in console

When I move item on console:

1
2
...
 
Last edited:
It didnt work bcus we used returnvalue_noerror
change it
from
Lua:
RETURNVALUE_NOERROR
to
Lua:
RETURNVALUE_NOTPOSSIBLE

My fault in that case
 
Last edited:
can u try the script on first post
I have edited it
This time it should work
No errors, not working :(

In players.lua (events), maybe this is problem?

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
 
Last edited:
Back
Top