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

Lua Teleport Storages Pos

adrenysny

Member
Joined
Feb 17, 2021
Messages
140
Reaction score
14
Someone will have a Movements scripts, that if you have a storage it will transport you to one side, and you do not have it, it will transport you to another, for example

Storages:
  • 14330
  • 14331
  • 14332
  • Teleport: Pos "A" >32213, 31376, 14
None Storages:
  • Teleport: Pos "B" >32161, 31327, 11
Note: if you have the 3 storages it transports you to position A, if you do not have any storage it transports you to position B
 
Solution
try this:
Lua:
local successPosition = Position(32213, 31376, 14)
local failPosition = Position(32161, 31327, 11)
local storages = {
    14330,
    14331,
    14332
}

local teleportQuest = MoveEvent()

function teleportQuest.onStepIn(creature, item, pos, fromPosition)
    if not creature:isPlayer() then
        return true
    end

    for _, storage in pairs(storages) do
        if creature:getStorageValue(storage) == -1 then
            creature:teleportTo(failPosition)
            failPosition:sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end
    end

    creature:teleportTo(successPosition)
    successPosition:sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

teleportQuest:aid(00000) -- ActionID Here...
try this:
Lua:
local successPosition = Position(32213, 31376, 14)
local failPosition = Position(32161, 31327, 11)
local storages = {
    14330,
    14331,
    14332
}

local teleportQuest = MoveEvent()

function teleportQuest.onStepIn(creature, item, pos, fromPosition)
    if not creature:isPlayer() then
        return true
    end

    for _, storage in pairs(storages) do
        if creature:getStorageValue(storage) == -1 then
            creature:teleportTo(failPosition)
            failPosition:sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end
    end

    creature:teleportTo(successPosition)
    successPosition:sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

teleportQuest:aid(00000) -- ActionID Here
teleportQuest:register()
 
Last edited:
Solution
try this:
Lua:
local successPosition = Position(32213, 31376, 14)
local failPosition = Position(32161, 31327, 11)
local storages = {
    14330,
    14331,
    14332
}

local teleportQuest = MoveEvent()

function teleportQuest.onStepIn(creature, item, pos, fromPosition)
    if not creature:isPlayer() then
        return true
    end

    for _, storage in pairs(storages) do
        if player:getStorageValue(storage) == -1 then
            creature:teleportTo(failPosition)
            failPosition:sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end
    end

    creature:teleportTo(successPosition)
    successPosition:sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

teleportQuest:aid(00000) -- ActionID Here
teleportQuest:register()
error console :(
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/movements/quests/heart_of_destruction/boss_to_room/teleport_realityquake_room.lua:callback
..._destruction/boss_to_room/teleport_realityquake_room.lua:17: attempt to index global 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        ..._destruction/boss_to_room/teleport_realityquake_room.lua:17: in function <..._destruction/boss_to_room/teleport_realityquake_room.lua:11>
Reloaded: scripts.

Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/movements/quests/heart_of_destruction/boss_to_room/teleport_realityquake_room.lua:callback
..._destruction/boss_to_room/teleport_realityquake_room.lua:17: attempt to index global 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        ..._destruction/boss_to_room/teleport_realityquake_room.lua:17: in function <..._destruction/boss_to_room/teleport_realityquake_room.lua:11>




script
Code:
local successPosition = Position(32213, 31376, 14)
local failPosition = Position(32161, 31327, 11)
local storages = {
    14330,
    14331,
    14332
}

local teleportQuest = MoveEvent()

function teleportQuest.onStepIn(creature, item, pos, fromPosition)
    if not creature:isPlayer() then
        return true
    end

    for _, storage in pairs(storages) do
        if player:getStorageValue(storage) == -1 then
            creature:teleportTo(failPosition)
            failPosition:sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end
    end

    creature:teleportTo(successPosition)
    successPosition:sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

teleportQuest:aid(42470) -- ActionID Here
teleportQuest:register()
 
error console :(
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/movements/quests/heart_of_destruction/boss_to_room/teleport_realityquake_room.lua:callback
..._destruction/boss_to_room/teleport_realityquake_room.lua:17: attempt to index global 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        ..._destruction/boss_to_room/teleport_realityquake_room.lua:17: in function <..._destruction/boss_to_room/teleport_realityquake_room.lua:11>
Reloaded: scripts.

Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/movements/quests/heart_of_destruction/boss_to_room/teleport_realityquake_room.lua:callback
..._destruction/boss_to_room/teleport_realityquake_room.lua:17: attempt to index global 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        ..._destruction/boss_to_room/teleport_realityquake_room.lua:17: in function <..._destruction/boss_to_room/teleport_realityquake_room.lua:11>




script
Code:
local successPosition = Position(32213, 31376, 14)
local failPosition = Position(32161, 31327, 11)
local storages = {
    14330,
    14331,
    14332
}

local teleportQuest = MoveEvent()

function teleportQuest.onStepIn(creature, item, pos, fromPosition)
    if not creature:isPlayer() then
        return true
    end

    for _, storage in pairs(storages) do
        if player:getStorageValue(storage) == -1 then
            creature:teleportTo(failPosition)
            failPosition:sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end
    end

    creature:teleportTo(successPosition)
    successPosition:sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

teleportQuest:aid(42470) -- ActionID Here
teleportQuest:register()
change
Lua:
if player:getStorageValue(storage) == -1 then
to
Lua:
if creature:getStorageValue(storage) == -1 then
 
Back
Top