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

Error revert Lever and Create MagicWall TFS 1.3+

Azerty

Active Member
Joined
Apr 15, 2022
Messages
301
Solutions
4
Reaction score
31
Good afternoon, I made this lever script that when using it, it returns to its original position in a few seconds and the MagicWall reappears. However, if there is a player or a monster in the MagicWall SQM, it returns an error and the lever locks, only returning when the server restarts. Does anyone know how do I make it so that when the MagicWall appears, the player or monster will be pushed to the SQM from the north direction?

err.JPG

quest.jpg


Lua:
local doorPosition = Position(33075, 32591, 3)

local function revertCarrotAndLever(position, carrotPosition)
    local leverItem = Tile(position):getItemById(1946)
    if leverItem then
        leverItem:transform(1945)
    end
    
    local carrotItem = Tile(carrotPosition):getItemById(104)
    if carrotItem then
        Game.createItem(1498, 1, doorPosition)
        --carrotItem:remove()
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
    if getPlayerItemCount(player, 13118) >= 1 then
    local tile = doorPosition:getTile()
    if tile then
    local MagicWall = tile:getItemById(1498)
        if MagicWall then
        MagicWall:remove()
        doorPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You paved the way!')
        item:transform(1946)
        --Game.createItem(1498, 1, doorPosition)
        addEvent(revertCarrotAndLever, 10 * 1000, toPosition, doorPosition)
    end
end

        local doorItem = Tile(doorPosition):getItemById(1498)
        if doorItem then
            --Game.createItem(1498, 1, doorPosition)
            doorItem:transform(104)
        end
    else
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You do not have the Chayenne\'s magical key!')
    doTargetCombatHealth(0, player, COMBAT_FIREDAMAGE, -200, -200, CONST_ME_HITBYFIRE)
    end
    elseif item.itemid == 1946 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You need to wait few seconds to use again.')
        return true
    end
end
 
Solution
Dont work =/
Post automatically merged:


Dont work =/

tried like this?

Lua:
local doorPosition = Position(33075, 32591, 3)

local function revertCarrotAndLever(position, carrotPosition)
    local leverItem = Tile(position):getItemById(1946)
    if leverItem then
        leverItem:transform(1945)
    end
    
    local carrotItem = Tile(carrotPosition):getItemById(104)
    if carrotItem then
        creature = Tile(doorPosition):getTopCreature()
        if creature then
            creature:teleportTo(Position(33075, 32592, 3))
        end
        Game.createItem(1498, 1, doorPosition)
        --carrotItem:remove()
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
    if...
Good afternoon, I made this lever script that when using it, it returns to its original position in a few seconds and the MagicWall reappears. However, if there is a player or a monster in the MagicWall SQM, it returns an error and the lever locks, only returning when the server restarts. Does anyone know how do I make it so that when the MagicWall appears, the player or monster will be pushed to the SQM from the north direction?

View attachment 67375

View attachment 67374


Lua:
local doorPosition = Position(33075, 32591, 3)

local function revertCarrotAndLever(position, carrotPosition)
    local leverItem = Tile(position):getItemById(1946)
    if leverItem then
        leverItem:transform(1945)
    end
   
    local carrotItem = Tile(carrotPosition):getItemById(104)
    if carrotItem then
        Game.createItem(1498, 1, doorPosition)
        --carrotItem:remove()
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
    if getPlayerItemCount(player, 13118) >= 1 then
    local tile = doorPosition:getTile()
    if tile then
    local MagicWall = tile:getItemById(1498)
        if MagicWall then
        MagicWall:remove()
        doorPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
       
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You paved the way!')
        item:transform(1946)
        --Game.createItem(1498, 1, doorPosition)
        addEvent(revertCarrotAndLever, 10 * 1000, toPosition, doorPosition)
    end
end

        local doorItem = Tile(doorPosition):getItemById(1498)
        if doorItem then
            --Game.createItem(1498, 1, doorPosition)
            doorItem:transform(104)
        end
    else
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You do not have the Chayenne\'s magical key!')
    doTargetCombatHealth(0, player, COMBAT_FIREDAMAGE, -200, -200, CONST_ME_HITBYFIRE)
    end
    elseif item.itemid == 1946 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You need to wait few seconds to use again.')
        return true
    end
end
Try to teleport a player/monster from the position before creating item. Use
Tile(doorPosition):getTopCreature() to get creature/player and teleport it one SQM away (doorPosition with ypos + 1 for example)

something like this
Code:
if carrotItem then
        creature = Tile(doorPosition):getTopCreature() 
        if creature then
            local newpos = doorPosition
            newpos.y = newpos.y + 1
            creature:teleportTo(newpos)
        end
        Game.createItem(1498, 1, doorPosition)
        --carrotItem:remove()
end

just an idea. :)
 
Try to teleport a player/monster from the position before creating item. Use
Tile(doorPosition):getTopCreature() to get creature/player and teleport it one SQM away (doorPosition with ypos + 1 for example)

something like this
Code:
if carrotItem then
        creature = Tile(doorPosition):getTopCreature()
        if creature then
            local newpos = doorPosition
            newpos.y = newpos.y + 1
            creature:teleportTo(newpos)
        end
        Game.createItem(1498, 1, doorPosition)
        --carrotItem:remove()
end

just an idea. :)
Dont work =/
Post automatically merged:

Try to teleport a player/monster from the position before creating item. Use
Tile(doorPosition):getTopCreature() to get creature/player and teleport it one SQM away (doorPosition with ypos + 1 for example)

something like this
Code:
if carrotItem then
        creature = Tile(doorPosition):getTopCreature()
        if creature then
            local newpos = doorPosition
            newpos.y = newpos.y + 1
            creature:teleportTo(newpos)
        end
        Game.createItem(1498, 1, doorPosition)
        --carrotItem:remove()
end

just an idea. :)
Dont work =/
 
Dont work =/
Post automatically merged:


Dont work =/

tried like this?

Lua:
local doorPosition = Position(33075, 32591, 3)

local function revertCarrotAndLever(position, carrotPosition)
    local leverItem = Tile(position):getItemById(1946)
    if leverItem then
        leverItem:transform(1945)
    end
    
    local carrotItem = Tile(carrotPosition):getItemById(104)
    if carrotItem then
        creature = Tile(doorPosition):getTopCreature()
        if creature then
            creature:teleportTo(Position(33075, 32592, 3))
        end
        Game.createItem(1498, 1, doorPosition)
        --carrotItem:remove()
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
    if getPlayerItemCount(player, 13118) >= 1 then
    local tile = doorPosition:getTile()
    if tile then
    local MagicWall = tile:getItemById(1498)
        if MagicWall then
        MagicWall:remove()
        doorPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You paved the way!')
        item:transform(1946)
        --Game.createItem(1498, 1, doorPosition)
        addEvent(revertCarrotAndLever, 10 * 1000, toPosition, doorPosition)
    end
end

        local doorItem = Tile(doorPosition):getItemById(1498)
        if doorItem then
            --Game.createItem(1498, 1, doorPosition)
            doorItem:transform(104)
        end
    else
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You do not have the Chayenne\'s magical key!')
    doTargetCombatHealth(0, player, COMBAT_FIREDAMAGE, -200, -200, CONST_ME_HITBYFIRE)
    end
    elseif item.itemid == 1946 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You need to wait few seconds to use again.')
        return true
    end
end
 
Solution
tried like this?

Lua:
local doorPosition = Position(33075, 32591, 3)

local function revertCarrotAndLever(position, carrotPosition)
    local leverItem = Tile(position):getItemById(1946)
    if leverItem then
        leverItem:transform(1945)
    end
   
    local carrotItem = Tile(carrotPosition):getItemById(104)
    if carrotItem then
        creature = Tile(doorPosition):getTopCreature()
        if creature then
            creature:teleportTo(Position(33075, 32592, 3))
        end
        Game.createItem(1498, 1, doorPosition)
        --carrotItem:remove()
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
    if getPlayerItemCount(player, 13118) >= 1 then
    local tile = doorPosition:getTile()
    if tile then
    local MagicWall = tile:getItemById(1498)
        if MagicWall then
        MagicWall:remove()
        doorPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
       
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You paved the way!')
        item:transform(1946)
        --Game.createItem(1498, 1, doorPosition)
        addEvent(revertCarrotAndLever, 10 * 1000, toPosition, doorPosition)
    end
end

        local doorItem = Tile(doorPosition):getItemById(1498)
        if doorItem then
            --Game.createItem(1498, 1, doorPosition)
            doorItem:transform(104)
        end
    else
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You do not have the Chayenne\'s magical key!')
    doTargetCombatHealth(0, player, COMBAT_FIREDAMAGE, -200, -200, CONST_ME_HITBYFIRE)
    end
    elseif item.itemid == 1946 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You need to wait few seconds to use again.')
        return true
    end
end
It worked! Thank u!!!
 
Back
Top