• 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 Is a menu for teleporting even possible?

XiolenceOT

New Member
Joined
Jun 5, 2023
Messages
42
Reaction score
4
Is using an item such as the Nautical map with a unique ID that opens a menu, even if its a shop menu (if I have to)
to select teleport destinations possible? I keep getting "function even onUse not found" but it's clearly in the script, or is this only possible through the source files?

Lua:
 local TELEPORT_ITEM_ID = 10225
local TELEPORT_DESTINATIONS = {
    [1] = {name = "Destination 1", position = {x = 50, y = 100, z = 7}}, -- Adjust coordinates accordingly
    [2] = {name = "Destination 2", position = {x = 75, y = 150, z = 7}},
    [3] = {name = "Destination 3", position = {x = 120, y = 180, z = 7}}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == TELEPORT_ITEM_ID then
        showMenu(cid)
        return true
    end
    return false
end

function showMenu(cid)
    local player = Player(cid)
    local menuText = "Teleport Menu:\n"

    for option, destination in ipairs(TELEPORT_DESTINATIONS) do
        menuText = menuText .. option .. ". " .. destination.name .. "\n"
    end

    player:setActionId(5000) -- Set a temporary action ID to capture menu selection
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, menuText)
end

function onAction(cid, action, itemEx, toPosition, isHotkey)
    if action == "5000" and itemEx.itemid == TELEPORT_ITEM_ID then
        local choice = tonumber(itemEx.actionid)
        if choice and TELEPORT_DESTINATIONS[choice] then
            local destination = TELEPORT_DESTINATIONS[choice].position
            local player = Player(cid)
            player:teleportTo(destination)
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:say("You have been teleported to " .. TELEPORT_DESTINATIONS[choice].name .. ".", TALKTYPE_MONSTER_SAY)
            player:setActionId(0) -- Reset action ID to close the menu
        end
    end
    return true
end
 
Where are you finding these function names? lol

Replace your line with the default, and see if it still has an issue.
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
 
Where are you finding these function names? lol

Replace your line with the default, and see if it still has an issue.
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
Yeah I just gave up and went with the classic boat system, didn’t want to make different ships and ports but oh well lol
 
Back
Top