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

How to move player 1 sqm if he is on X position?

cristianso

Member
Joined
Jan 27, 2019
Messages
47
Reaction score
16
I have this script that remove a stone when you pull the lever. After a while, the stone is created on the same spot.
However, if the player in on the same position of the stone, the stone is not created... So, I need to move the player 1 sqm away if he is on the same spot of the stone.


LUA:
local stonePositions = {
    Position(14773, 13605, 9)
}

local function createStones()
    for i = 1, #stonePositions do
        Game.createItem(1353, 1, stonePositions[i])
    end
end

local function revertLever(position)
    local leverItem = Tile(position):getItemById(1946)
    if leverItem then
        leverItem:transform(1945)
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid ~= 1945 then
        return false
    end

    local stone
        for i = 1, #stonePositions do
            stone = Tile(stonePositions[i]):getItemById(1354)
            if stone then
                stone:remove()
                stonePositions[i]:sendMagicEffect(CONST_ME_EXPLOSIONAREA)
            end
        end
        
        addEvent(createStones, 12 * 1000)
        item:transform(1946)
        addEvent(revertLever, 12 * 1000, toPosition)
        return true
end
 

Similar threads

  • Question Question
Replies
1
Views
478
Back
Top