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

Scarab Coin @ Ankrahmun Tombs

Ray Rewind

Doctor
Joined
Jun 6, 2009
Messages
1,348
Reaction score
76
Location
Germany
I want the script like real Tibia if you put scarab coin on empty coal basin ID 1485 and you stand on the flame ID 8058 you get teleported to X Position
 
My 4 years old script.

Make 2 flames, one (action id 270) what requires scarab coin on specific place ex basin (can be any item, even floor) to teleport to dungeon, and second one (action id 271) what teleports back.

Used it in movements: tomb.lua
Code:
function onStepIn(cid, item, position, fromPosition)

local tileActionID = 270
local tileActionIDBack = 271
local coin = 2159

local teleportTo = {x=391, y=384, z=13}
local teleportBack = {x=442, y=232, z=11}

local itemPosition = {x=441, y=233, z=11, stackpos=STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}
local getItem = getThingFromPos(itemPosition)

    if isPlayer(cid) == TRUE then
        if item.itemid == 1397 and item.actionid == tileActionID then
            if getItem.itemid == coin then
                doRemoveItem(getItem.uid, 1)
                doTeleportThing(cid, teleportTo)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
                doSendMagicEffect(getThingPos(item.uid), CONST_ME_TELEPORT)
                doSendMagicEffect(itemPosition, 15)
            end
        elseif item.itemid == 1397 and item.actionid == tileActionIDBack then
            doTeleportThing(cid, teleportBack)
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
            doSendMagicEffect(getThingPos(item.uid), CONST_ME_TELEPORT)
        end
    end
    return TRUE
end

movements.xml add:
Code:
<movevent type="StepIn" actionid="270" event="script" value="tomb.lua" />
<movevent type="StepIn" actionid="271" event="script" value="tomb.lua" />
 
My 4 years old script.

Make 2 flames, one (action id 270) what requires scarab coin on specific place ex basin (can be any item, even floor) to teleport to dungeon, and second one (action id 271) what teleports back.

Used it in movements: tomb.lua
Code:
function onStepIn(cid, item, position, fromPosition)

local tileActionID = 270
local tileActionIDBack = 271
local coin = 2159

local teleportTo = {x=391, y=384, z=13}
local teleportBack = {x=442, y=232, z=11}

local itemPosition = {x=441, y=233, z=11, stackpos=STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}
local getItem = getThingFromPos(itemPosition)

    if isPlayer(cid) == TRUE then
        if item.itemid == 1397 and item.actionid == tileActionID then
            if getItem.itemid == coin then
                doRemoveItem(getItem.uid, 1)
                doTeleportThing(cid, teleportTo)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
                doSendMagicEffect(getThingPos(item.uid), CONST_ME_TELEPORT)
                doSendMagicEffect(itemPosition, 15)
            end
        elseif item.itemid == 1397 and item.actionid == tileActionIDBack then
            doTeleportThing(cid, teleportBack)
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
            doSendMagicEffect(getThingPos(item.uid), CONST_ME_TELEPORT)
        end
    end
    return TRUE
end

movements.xml add:
Code:
<movevent type="StepIn" actionid="270" event="script" value="tomb.lua" />
<movevent type="StepIn" actionid="271" event="script" value="tomb.lua" />
yeaaaaaaah your script was the only one in whole forums and others that works thanks mate u great for this community
 
Lua:
local tileActionID = 270
local tileActionIDBack = 271
local coin = 2159
local teleportTo = {x=391, y=384, z=13}
local teleportBack = {x=442, y=232, z=11}
local itemPosition = {x=441, y=233, z=11, stackpos=STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return false
    end
  
    local getItem = getThingfromPos(itemPosition)
  
    if item.itemid == 1397 and item.actionid == tileActionID then
        if getItem.itemid == coin then
            doRemoveItem(getItem.uid, 1)
            doTeleportThing(player.uid, teleportTo)
            doSendMagicEffect(player:getPosition(), CONST_ME_TELEPORT)
            doSendMagicEffect(getThingPos(item.uid), CONST_ME_TELEPORT)
            doSendMagicEffect(itemPosition, 15)
        end
    elseif item.itemid == 1397 and item.actionid == tileActionIDBack then
        doTeleportThing(player.uid, teleportBack)
        doSendMagicEffect(player:getPosition(), CONST_ME_TELEPORT)
        doSendMagicEffect(getThingPos(item.uid), CONST_ME_TELEPORT)
    end
 
    return true
end
 
Last edited:
Lua:
local tileActionID = 270
local tileActionIDBack = 271
local coin = 2159
local teleportTo = {x=391, y=384, z=13}
local teleportBack = {x=442, y=232, z=11}
local itemPosition = {x=441, y=233, z=11, stackpos=STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return false
    end
  
    local getItem = getThingFromPos(itemPosition)
  
    if item.itemid == 1397 and item.actionid == tileActionID then
        if getItem.itemid == coin then
            doRemoveItem(getItem.uid, 1)
            doTeleportThing(player.uid, teleportTo)
            doSendMagicEffect(player:getPosition(), CONST_ME_TELEPORT)
            doSendMagicEffect(getThingPos(item.uid), CONST_ME_TELEPORT)
            doSendMagicEffect(itemPosition, 15)
        end
    elseif item.itemid == 1397 and item.actionid == tileActionIDBack then
        doTeleportThing(player.uid, teleportBack)
        doSendMagicEffect(player:getPosition(), CONST_ME_TELEPORT)
        doSendMagicEffect(getThingPos(item.uid), CONST_ME_TELEPORT)
    end
 
    return true
end
Why?
Lua:
local player = creature:getPlayer()
A player is a creature but a creature is not a player, remember Creature is the super class or parent of Player.
Lua:
function onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        return false
    end
Your code with the minor modifications although this could be written simpler works just as yours did without the extra step :)
Lua:
local tileActionID = 270
local tileActionIDBack = 271
local coin = 2159
local teleportTo = {x=391, y=384, z=13}
local teleportBack = {x=442, y=232, z=11}
local itemPosition = {x=441, y=233, z=11, stackpos=STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}
function onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        return false
    end
    local getItem = getThingFromPos(itemPosition)
    if item.itemid == 1397 and item.actionid == tileActionID then
        if getItem.itemid == coin then
            doRemoveItem(getItem.uid, 1)
            doTeleportThing(creature.uid, teleportTo)
            doSendMagicEffect(creature:getPosition(), CONST_ME_TELEPORT)
            doSendMagicEffect(getThingPos(item.uid), CONST_ME_TELEPORT)
            doSendMagicEffect(itemPosition, 15)
        end
    elseif item.itemid == 1397 and item.actionid == tileActionIDBack then
        doTeleportThing(creature.uid, teleportBack)
        doSendMagicEffect(creature:getPosition(), CONST_ME_TELEPORT)
        doSendMagicEffect(getThingPos(item.uid), CONST_ME_TELEPORT)
    end
    return true
end
 
Lua:
local player = creature:getPlayer()

The local is just cause i use it for readability, and the :getPlayer() will return userdata.
 
maybe im doing something wrong in RME, i tried that script u posted psychonaut, it seems that the flame teleports without a coin on the designated sqm
 
I just changed the functions, maybe missed something, i'm gonna take a look

Code:
local tileActionID = 270
local tileActionIDBack = 271
local coin = 2159
local teleportTo = {x = 1040, y = 1026, z = 7}
local teleportBack = {x = 1036, y = 1026, z = 7}
local itemPosition = {x = 1037, y = 1025, z = 7, stackpos=STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE}
local flameId = 1397

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player or item.itemid ~= flameId then
        return false
    end
 
    local getItem = getThingfromPos(itemPosition)
  
    if item.actionid == tileActionID then
        if getItem.itemid == coin then
            doRemoveItem(getItem.uid, 1)
            doTeleportThing(player.uid, teleportTo)
            doSendMagicEffect(player:getPosition(), CONST_ME_TELEPORT)
            doSendMagicEffect(getThingPos(item.uid), CONST_ME_TELEPORT)
            doSendMagicEffect(itemPosition, 15)
        end
    elseif item.actionid == tileActionIDBack then
        doTeleportThing(player.uid, teleportBack)
        doSendMagicEffect(player:getPosition(), CONST_ME_TELEPORT)
        doSendMagicEffect(getThingPos(item.uid), CONST_ME_TELEPORT)
    end
 
    return true
end

Make sure that flameId have the same id as your flame, put the actions id in the flames and it's done, in RME it should teleport to the position back.
 
Last edited by a moderator:
You set it to the coordinates back(when there's no coin).

Code:
<movevent event="StepIn" fromaid="270" toaid = "271" script="yourScript.lua" />
 
Back
Top