• 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 Problems with a TP script.

calveron

Bravemansworld
Joined
Feb 5, 2008
Messages
165
Reaction score
13
Location
Sweden
Problem solved :)

action script:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)
       if not getCreatureCondition(cid, CONDITION_INFIGHT) then
  local Destination = ModalWindow(2, "Destination", "Make your choice:")
Destination:addChoice(1, "1. Thais")
Destination:addChoice(2, "2. Carlin")
Destination:addChoice(3, "3. Venore")
Destination:addChoice(4, "4. Ab'dendriel")
Destination:addChoice(5, "5. Liberty Bay")
Destination:addChoice(6, "6. Port Hope")
Destination:addChoice(7, "7. Ankrahmun")
Destination:addChoice(8, "8. Darashia")
Destination:addChoice(9, "9. Kazordoon")
Destination:addChoice(10, "10. Edron")
Destination:addChoice(11, "11. Svargrond")
Destination:addChoice(12, "12. Yalahar")
Destination:addChoice(13, "13. Farmine")
Destination:addChoice(14, "14. Gray Beach")
Destination:addChoice(15, "15. Roshamuul")
  Destination:addButton(1, 'Go')
  Destination:addButton(2, 'Exit')
  Destination:sendToPlayer(player)
    else
        doPlayerSendCancel(cid, "PZ locked!")
           doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)

    end
    return true
end

creaturescript:
Code:
function onModalWindow(cid, modalWindowId, buttonId, choiceId)

if modalWindowId == 2 then


local player = Player(cid)
local thais = {x = 32369, y = 32241, z = 7}
local carlin = {x = 32360, y = 31782, z = 7}
local venore = {x = 32957, y = 32076, z = 7}
local ab = {x = 32732, y = 31634, z = 7}
local liberty = {x = 32317, y = 32826, z = 7}
local port = {x = 32594, y = 32745, z = 7}
local ankrahmun = {x = 33194, y = 32853, z = 7}
local darashia = {x = 33213, y = 32454, z = 1}
local kazordoon = {x = 32649, y = 31925, z = 11}
local edron = {x = 33217, y = 31814, z = 8}
local svargrond = {x = 32212, y = 31132, z = 7}
local yalahar = {x = 32787, y = 31276, z = 7}
local farmine = {x = 33023, y = 31521, z = 11}
local gray = {x = 33447, y = 31323, z = 9}
local roshamuul = {x = 33513, y = 32363, z = 6}

if buttonId == 2 then
return false
else
    if choiceId == 1 then
player:teleportTo(thais)
return true
    end
    if choiceId == 2 then
player:teleportTo(carlin)
return true
    end
    if choiceId == 3 then
player:teleportTo(venore)
return true
    end
    if choiceId == 4 then
player:teleportTo(ab)
return true
    end
    if choiceId == 5 then
player:teleportTo(liberty)
return true
    end
    if choiceId == 6 then
player:teleportTo(port)
return true
    end
    if choiceId == 7 then
player:teleportTo(ankrahmun)
return true
    end
    if choiceId == 8 then
player:teleportTo(darashia)
return true
    end
    if choiceId == 9 then
player:teleportTo(kazordoon)
return true
    end
    if choiceId == 10 then
player:teleportTo(edron)
return true
    end
    if choiceId == 11 then
player:teleportTo(svargrond)
return true
    end
    if choiceId == 12 then
player:teleportTo(yalahar)
return true
    end
    if choiceId == 13 then
player:teleportTo(farmine)
return true
    end
    if choiceId == 14 then
player:teleportTo(gray)
return true
    end
    if choiceId == 15 then
player:teleportTo(roshamuul)
return true
    end

    end
end
end
 
Last edited:
Try with this, don't forget to change eventName to something else.
Code:
local towns = {
    "Thais",
    "Carlin",
    "Venore",
    "Ab'dendriel",
    "Liberty Bay",
    "Port Hope",
    "Ankrahmun",
    "Darashia",
    "Kazordoon",
    "Edron",
    "Svargrond",
    "Yalahar",
    "Farmine",
    "Gray Beach",
    "Roshamuul"
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
        player:sendCancelMessage("PZ locked!")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    local modalWindow = ModalWindow(2, "Destination", "Make your choice:")
    for i = 1, #towns do
        modalWindow:addChoice(i, i .. ". " .. towns[i])
    end

    modalWindow:addButton(1, 'Go')
    modalWindow:setDefaultEnterButton(1)
    modalWindow:addButton(2, 'Exit')
    modalWindow:setDefaultEscapeButton(2)

    modalWindow:sendToPlayer(player)
    player:registerEvent("eventName")
    return true
end

local destinations = {
    Position(32369, 32241, 7),
    Position(32360, 31782, 7),
    Position(32957, 32076, 7),
    Position(32732, 31634, 7),
    Position(32317, 32826, 7),
    Position(32594, 32745, 7),
    Position(33194, 32853, 7),
    Position(33213, 32454, 1),
    Position(32649, 31925, 11),
    Position(33217, 31814, 8),
    Position(32212, 31132, 7),
    Position(32787, 31276, 7),
    Position(33023, 31521, 11),
    Position(33447, 31323, 9),
    Position(33513, 32363, 6)
}

function onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:unregisterEvent("eventName")
    if modalWindowId ~= 2 or buttonId ~= 1 then
        return false
    end
   
    local destination = destinations[choiceId]
    if not destination then
        return true
    end
   
    player:teleportTo(destination)
    destination:sendMagicEffect(CONST_ME_TELEPORT)
    return true
end
 
Back
Top