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

Solved Teleport to trainers

kowal67612

New Member
Joined
Nov 7, 2023
Messages
38
Reaction score
4
Did I add it correctly, it doesn't want to teleport
coordinates are ok, but are they entered correctly?

LUA:
local config = {
    leftTopCorner = {x = 31538, y = 30766},
    rightDownCorner = {x = 31911, y = 30960},
    zPos = 7,
    tileItemId = 418, --tile item id for scanner, where you want to teleport player, ez to change for tile with uid if someone need
}

local function findFirstEmpty()
    for x = config.leftTopCorner.x, config.rightDownCorner.x do
        for y = config.leftTopCorner.y, config.rightDownCorner.y do
            local tmpPos = {x=32372, y=32232, z =7};
            local tmpPos = {x=x, y=y, z = config.zPos};
            local tmpPos = {x=x, y=y, z = config.zPos};
            local tmpPos = {x=x, y=y, z = config.zPos};
            local tmpPos = {x=x, y=y, z = config.zPos};
            local t = Tile(tmpPos)
            if t ~= nil then
                if(t:getThing():getId() == config.tileItemId and not t:getTopCreature()) then
                    return tmpPos
                end
            end
        end
    end
    return false
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local availableTrainingSlot = findFirstEmpty()
    if(availableTrainingSlot) then
        cid:teleportTo(availableTrainingSlot)
        cid:sendTextMessage(MESSAGE_INFO_DESCR, "Welcome.")
    else
        cid:sendTextMessage(MESSAGE_INFO_DESCR, "No available slots.")
    end
    return true
end
 
Did I add it correctly, it doesn't want to teleport
coordinates are ok, but are they entered correctly?

LUA:
local config = {
    leftTopCorner = {x = 31538, y = 30766},
    rightDownCorner = {x = 31911, y = 30960},
    zPos = 7,
    tileItemId = 418, --tile item id for scanner, where you want to teleport player, ez to change for tile with uid if someone need
}

local function findFirstEmpty()
    for x = config.leftTopCorner.x, config.rightDownCorner.x do
        for y = config.leftTopCorner.y, config.rightDownCorner.y do
            local tmpPos = {x=32372, y=32232, z =7};
            local tmpPos = {x=x, y=y, z = config.zPos};
            local tmpPos = {x=x, y=y, z = config.zPos};
            local tmpPos = {x=x, y=y, z = config.zPos};
            local tmpPos = {x=x, y=y, z = config.zPos};
            local t = Tile(tmpPos)
            if t ~= nil then
                if(t:getThing():getId() == config.tileItemId and not t:getTopCreature()) then
                    return tmpPos
                end
            end
        end
    end
    return false
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local availableTrainingSlot = findFirstEmpty()
    if(availableTrainingSlot) then
        cid:teleportTo(availableTrainingSlot)
        cid:sendTextMessage(MESSAGE_INFO_DESCR, "Welcome.")
    else
        cid:sendTextMessage(MESSAGE_INFO_DESCR, "No available slots.")
    end
    return true
end
Does it tell you "No available slots." in green text?
-> if no, how did you register the onUse script in actions.xml?

Have you placed the tile 418 on the map, inside those coordinates?

-- edit

nvm I see the issue.

try this.

LUA:
local config = {
    leftTopCorner = {x = 31538, y = 30766},
    rightDownCorner = {x = 31911, y = 30960},
    zPos = 7,
    tileItemId = 418, --tile item id for scanner, where you want to teleport player, ez to change for tile with uid if someone need
}

local function findFirstEmpty()
    for x = config.leftTopCorner.x, config.rightDownCorner.x do
        for y = config.leftTopCorner.y, config.rightDownCorner.y do
            local tmpPos = {x = x, y = y, z = config.zPos}
            local t = Tile(tmpPos)
            if t ~= nil then
                if(t:getThing():getId() == config.tileItemId and not t:getTopCreature()) then
                    return tmpPos
                end
            end
        end
    end
    return false
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local availableTrainingSlot = findFirstEmpty()
    if(availableTrainingSlot) then
        cid:teleportTo(availableTrainingSlot)
        cid:sendTextMessage(MESSAGE_INFO_DESCR, "Welcome.")
    else
        cid:sendTextMessage(MESSAGE_INFO_DESCR, "No available slots.")
    end
    return true
end
 
<action actionid="KrokIn" movementid="418" script="nostalrius/418.lua" />
Post automatically merged:

18:30 You see a magic forcefield.
You can see the other side through it.
Item ID: 1949, Movement ID: 418
Position: 32372, 32232, 7
Post automatically merged:

[Warning - Event::checkScript] Event onStepIn not found. scripts/nostalrius/418.lua
[Warning - Event::checkScript] Event onAddItem not found. scripts/nostalrius/418.lua
[Warning - MoveEvents::addEvent] Duplicate move event found: 17163
 
Last edited:
movement id its smth else i think, you have to register id of item,

as xikini mentioned, you have to check if its even registered (probably not) at begging of function "onUse" do random print like
LUA:
print("This is even registered?")

then check if console will display this message when u click on that item that supposed to teleport player

btw nostalrius / sabrehaven its not beginner friendly.
 

Similar threads

Back
Top