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

RME Map editor, how to make item unmovable? TFS 1.4.2

beenii

Well-Known Member
Joined
Jul 26, 2010
Messages
580
Solutions
1
Reaction score
57
I was reading everything related in the forum and I did not find any optimal way.

What would be the best option to do it? maybe with some script that handles action id? because it is tiring to have to put unique id to all the items

Or how can I register a uniqueid to all the items that I want to not make movable without receiving an error in the console?

Any definitive solution so that it is not tradable, does not move with the browse field, nor can it be used?

On this post:

Lua:
BLOCK_ITEM_WITH_ACTION = 8000

if item:getActionId() == BLOCK_ITEM_WITH_ACTION then

        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.
 
Solution
I was reading everything related in the forum and I did not find any optimal way.

What would be the best option to do it? maybe with some script that handles action id? because it is tiring to have to put unique id to all the items

Or how can I register a uniqueid to all the items that I want to not make movable without receiving an error in the console?

Any definitive solution so that it is not tradable, does not move with the browse field, nor can it be used?

On this post:

Lua:
BLOCK_ITEM_WITH_ACTION = 8000

if item:getActionId() == BLOCK_ITEM_WITH_ACTION then

        self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)

        return false...
I was reading everything related in the forum and I did not find any optimal way.

What would be the best option to do it? maybe with some script that handles action id? because it is tiring to have to put unique id to all the items

Or how can I register a uniqueid to all the items that I want to not make movable without receiving an error in the console?

Any definitive solution so that it is not tradable, does not move with the browse field, nor can it be used?

On this post:

Lua:
BLOCK_ITEM_WITH_ACTION = 8000

if item:getActionId() == BLOCK_ITEM_WITH_ACTION then

        self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)

        return false

    end
Dous it help if you give it a random ununiqueid
I was reading everything related in the forum and I did not find any optimal way.

What would be the best option to do it? maybe with some script that handles action id? because it is tiring to have to put unique id to all the items

Or how can I register a uniqueid to all the items that I want to not make movable without receiving an error in the console?

Any definitive solution so that it is not tradable, does not move with the browse field, nor can it be used?

On this post:

Lua:
BLOCK_ITEM_WITH_ACTION = 8000

if item:getActionId() == BLOCK_ITEM_WITH_ACTION then

        self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)

        return false

    end
Post in thread 'RME Map editor, how to make item unmovable?' Windows - RME Map editor, how to make item unmovable? (https://otland.net/threads/rme-map-editor-how-to-make-item-unmovable.238798/post-2309642)
I think this can solve your problem
 
I was reading everything related in the forum and I did not find any optimal way.

What would be the best option to do it? maybe with some script that handles action id? because it is tiring to have to put unique id to all the items

Or how can I register a uniqueid to all the items that I want to not make movable without receiving an error in the console?

Any definitive solution so that it is not tradable, does not move with the browse field, nor can it be used?

On this post:

Lua:
BLOCK_ITEM_WITH_ACTION = 8000

if item:getActionId() == BLOCK_ITEM_WITH_ACTION then

        self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)

        return false

    end
you can try:

data/scripts/file.lua
Lua:
local BLOCK_ITEM_WITH_ACTION = 8000

local action = Action()

function action.onUse(player, item, fromPos, target, toPos, isHotkey)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You can't use this item.")
    return true
end

action:aid(BLOCK_ITEM_WITH_ACTION)
action:register()

local event = EventCallback

function event.onMoveItem(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if item:getActionId() == BLOCK_ITEM_WITH_ACTION then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You can't move this item.")
        return RETURNVALUE_NOTPOSSIBLE
    end
    return RETURNVALUE_NOERROR
end

event:register(-math.huge)

local event = EventCallback

function event.onTradeRequest(player, target, item)
    if item:getActionId() == BLOCK_ITEM_WITH_ACTION then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You can't trade this item.")
        return false
    end
    return true
end

event:register(-math.huge)

local event = EventCallback

function event.onTradeAccept(player, target, item, targetItem)
    if item:getActionId() == BLOCK_ITEM_WITH_ACTION then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You can't trade this item.")
        return false
    end
    return true
end

event:register(-math.huge)
 
Solution
you can try:

data/scripts/file.lua
Lua:
local BLOCK_ITEM_WITH_ACTION = 8000

local action = Action()

function action.onUse(player, item, fromPos, target, toPos, isHotkey)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You can't use this item.")
    return true
end

action:aid(BLOCK_ITEM_WITH_ACTION)
action:register()

local event = EventCallback

function event.onMoveItem(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if item:getActionId() == BLOCK_ITEM_WITH_ACTION then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You can't move this item.")
        return RETURNVALUE_NOTPOSSIBLE
    end
    return RETURNVALUE_NOERROR
end

event:register(-math.huge)

local event = EventCallback

function event.onTradeRequest(player, target, item)
    if item:getActionId() == BLOCK_ITEM_WITH_ACTION then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You can't trade this item.")
        return false
    end
    return true
end

event:register(-math.huge)

local event = EventCallback

function event.onTradeAccept(player, target, item, targetItem)
    if item:getActionId() == BLOCK_ITEM_WITH_ACTION then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You can't trade this item.")
        return false
    end
    return true
end

event:register(-math.huge)

Hello it works fine, i add this part for more protection:
Code:
local event = EventCallback

function event.onBrowseField(player, position)
    local tile = Tile(position)
    if not tile then
        return false
    end
    
    local tileItems = tile:getItems()
    for k, item in ipairs(tileItems) do
    if item:getActionId() == BLOCK_ITEM_WITH_ACTION and k < #tileItems then
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "can't use on BrowseField on this tile.")
        return false
        end
    end
    
    return true
end

event:register(math.huge)

I have a question, you used event:register(-math.huge) and change it to event:register(math.huge)

I think this script should have the highest priority, because if an item that is blocked in RME, and if it has any action (stamina refil for example) it will first read that it must regenerate stamina instead of blocking its use, tell me what you think.

Another question, do you know what would have to be edited in the source code, so that blocked articles with actionID do not appear in onBrowseField? as well as items with uniqueid do not appear in onBrowseField
 
Hello it works fine, i add this part for more protection:
Code:
local event = EventCallback

function event.onBrowseField(player, position)
    local tile = Tile(position)
    if not tile then
        return false
    end
  
    local tileItems = tile:getItems()
    for k, item in ipairs(tileItems) do
    if item:getActionId() == BLOCK_ITEM_WITH_ACTION and k < #tileItems then
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "can't use on BrowseField on this tile.")
        return false
        end
    end
  
    return true
end

event:register(math.huge)

I have a question, you used event:register(-math.huge) and change it to event:register(math.huge)

I think this script should have the highest priority, because if an item that is blocked in RME, and if it has any action (stamina refil for example) it will first read that it must regenerate stamina instead of blocking its use, tell me what you think.

Another question, do you know what would have to be edited in the source code, so that blocked articles with actionID do not appear in onBrowseField? as well as items with uniqueid do not appear in onBrowseField
If you read the EventCallback system this is called tiggerIndex, it is the execution index, this is similar to priority but in reverse
The lower index will always be executed before the higher one.

Thank you for teaching me something I created myself 🤣
 
If you read the EventCallback system this is called tiggerIndex, it is the execution index, this is similar to priority but in reverse
The lower index will always be executed before the higher one.

Thank you for teaching me something I created myself 🤣
why do you take it that way? I was just suggesting, you could have explained instead of mocking
 
Back
Top