• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Error revert Lever and Create MagicWall TFS 1.3+

Azerty

Member
Joined
Apr 15, 2022
Messages
147
Solutions
3
Reaction score
10
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...

jakub742

Member
Joined
May 1, 2010
Messages
110
Solutions
2
Reaction score
8
Location
Slovakia
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. :)
 
OP
OP
A

Azerty

Member
Joined
Apr 15, 2022
Messages
147
Solutions
3
Reaction score
10
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 =/
 

mano368

Intermediate OT User
Joined
Sep 2, 2011
Messages
285
Solutions
34
Reaction score
116
Location
Brazil
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
OP
OP
A

Azerty

Member
Joined
Apr 15, 2022
Messages
147
Solutions
3
Reaction score
10
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!!!
 
Top