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

Solved Events problem

lucastiond

New Member
Joined
Jul 14, 2013
Messages
35
Reaction score
0
Hello guys

I'm trying to make one item desappears if moved, but with some conditions...

When the player talks to the npc, he gets the item. This item can not be moved, or otherwise it will be removed.
But if the player places this item in the right tiles, it won't desappear.

How can I do that?

My tfs is 1.2

Thanks!
 
Solution
you can put the correct positions the item should be placed inside the array at the top, the 3 i provided are examples:
Lua:
local correctPositions = {Position(1, 1, 1), Position(2, 2, 2), Position(3, 3, 3)}

function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    local isCorrectPosition = false
    for i = 1, #correctPositions do
        if toPosition == correctPositions[i] then
            isCorrectPosition = true
            break
        end
    end
    if not isCorrectPosition then
        item:remove()
        return false
    end
    return true
end
you can put the correct positions the item should be placed inside the array at the top, the 3 i provided are examples:
Lua:
local correctPositions = {Position(1, 1, 1), Position(2, 2, 2), Position(3, 3, 3)}

function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    local isCorrectPosition = false
    for i = 1, #correctPositions do
        if toPosition == correctPositions[i] then
            isCorrectPosition = true
            break
        end
    end
    if not isCorrectPosition then
        item:remove()
        return false
    end
    return true
end
 
Solution
you can put the correct positions the item should be placed inside the array at the top, the 3 i provided are examples:
Lua:
local correctPositions = {Position(1, 1, 1), Position(2, 2, 2), Position(3, 3, 3)}

function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    local isCorrectPosition = false
    for i = 1, #correctPositions do
        if toPosition == correctPositions[i] then
            isCorrectPosition = true
            break
        end
    end
    if not isCorrectPosition then
        item:remove()
        return false
    end
    return true
end
That would still remove it even if he's just moving it around his backpack. Probably shouldn't.
 
That would still remove it even if he's just moving it around his backpack. Probably shouldn't.
yes i know mkalo already told me a bit ago
a few threads ago i helped this guy in and he wanted his quest item (i think this is the same item he's referring to) to be removed whenever it was moved even in backpack
but if he doesn't want it to be removed in backpack, he can reply here since he didn't specify and i'll fix it for him
 
yes i know mkalo already told me a bit ago
a few threads ago i helped this guy in and he wanted his quest item (i think this is the same item he's referring to) to be removed whenever it was moved even in backpack
but if he doesn't want it to be removed in backpack, he can reply here since he didn't specify and i'll fix it for him

Amazing @Xeraphus , that was exactly what I wanted.

It worked flawless

Thanks!!
 
Just one more question @Xeraphus

How can I send one message like this: player:say('Etc....', TALKTYPE_MONSTER_SAY) in the exactly position the player moves the item? ( In this case, the correct positions)

I was only able to do like self:say, but I want the message above the item, not above the player
 
Back
Top