• 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 Fast travel system for 1.0

Gaddhuve

Member
Joined
May 6, 2011
Messages
76
Solutions
1
Reaction score
19
Im having some issues with this fast travel like system and Im really hoping someone could help me out. What is does is opens a modalwindow on-stepin with a location to fast travel to, after discovering the area.

When I get the modalwindow there are no available selections (even tho discovered) and when I press "Teleport" I get this message:

CLdjwW_Gb.png


I would be so grateful if someone could help me, cheers in advance!

SCRIPT:



compat.lua
getCreatureStorage = getPlayerStorageValue


data: catacombs.lua
places =
{
[1] = {placeName = "Dorion (Depot)", placeStorage = 6671, placepos = {x = 80, y = 64, z = 6}},
[2] = {placeName = "Venonh (Pits of Inferno)", placeStorage = 6672, placepos = {x = 346, y = 359, z = 8}},
[3] = {placeName = "Roshamuul (Gaz'Haragoth Lair)", placeStorage = 6673, placepos = {x = 2074, y = 228, z = 9}}
}

function getCatacombByName(name)
for k, v in pairs(places) do
if v.placeName:lower() == name:lower() then
return k
end
end
return false
end

function sendCatacombWindow(cid)
CatacombWindow = ModalWindow(1900, "Waypoints reached", "Select place:")

if CatacombWindow:getId() == 1900 then
CatacombWindow:addButton(1, "Teleport")
CatacombWindow:setDefaultEnterButton(1)
CatacombWindow:addButton(2, "Cancel")
CatacombWindow:setDefaultEscapeButton(2)

for i = 1, #places do
if getCreatureStorage(cid, places.placeStorage) == 1 then
CatacombWindow:addChoice(i, places.placeName)
end
end

end
CatacombWindow:sendToPlayer(cid)
return true
end


global.lua:
dofile('data/catacombs.lua')

creaturescripts\scripts file catacomb_window.lua:
function onModalWindow(cid, modalWindowId, buttonId, choiceId)

local player = Player(cid)
local pos = player:getPosition()

if modalWindowId ~= 1900 then
return false
end

if buttonId == 1 then -- Teleport

if getCreatureStorage(cid, places[choiceId].placeStorage) == 1 then
pos:sendMagicEffect(11)
player:teleportTo(places[choiceId].placepos)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have succesfully teleported to ' .. places[choiceId].placeName .. '.')
doSendMagicEffect(places[choiceId].placepos, 11)
else
sendCatacombWindow(cid)
end

elseif buttonId == 255 then
doPlayerPopupFYI(cid,"Please use a button.")
sendCatacombWindow(cid)
end

return true
end


data\creaturescripts\login.lua:
player:registerEvent("catacombw")


In folder data\movements\scripts\catacombs\
azsharanorth.lua
, azsharawest.lua, teleporter.lua, zenoyagraveyard.lua

Files:
azsharanorth.lua
Code:
local t = {
    pos = {x=2073, y=228, z=9},
    effect = CONST_ME_TUTORIALARROW
}

function onStepIn(creature, item, position, fromPosition)
    local player = Player(creature)
    if not player then
        return true
    end

    if player:getStorageValue(6663) < 1 then
        player:setStorageValue(6663, 1)
        player:say('It looks like a teleporter..', TALKTYPE_MONSTER_SAY)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have unlocked a Waypoint: Gaz Haragoth.')
        doSendMagicEffect(t.pos, t.effect, cid)
    end
    return true
end

azsharawest.lua
Code:
local t = {
    pos = {x=346, y=358, z=8},
    effect = CONST_ME_TUTORIALARROW
}

function onStepIn(creature, item, position, fromPosition)
    local player = Player(creature)
    if not player then
        return true
    end

    if player:getStorageValue(6662) < 1 then
        player:setStorageValue(6662, 1)
        player:say('It looks like a teleporter..', TALKTYPE_MONSTER_SAY)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have unlocked a Waipoint: Pits of Inferno.')
        doSendMagicEffect(t.pos, t.effect, cid)
    end
    return true
end

teleporter.lua
Code:
local choose = {}

function onStepIn(cid, item, position, fromPosition)

    local player = Player(cid)
    local pos = player:getPosition()

    if not player then
        return true
    end

    if getPlayerStorageValue(cid, 6661) == 1 then
    return sendCatacombWindow(cid)
    end

    return true
end

zenoyagraveyard.lua
Code:
local t = {
    pos = {x=79, y=63, z=6},
    effect = CONST_ME_TUTORIALARROW
}

function onStepIn(creature, item, position, fromPosition)
    local player = Player(creature) 
    if not player then
        return true
    end

    if player:getStorageValue(6661) < 1 then
        player:setStorageValue(6661, 1)
        player:say('It looks like a teleporter..', TALKTYPE_MONSTER_SAY)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have unlocked a Waypoint: Depot.')
        doSendMagicEffect(t.pos, t.effect, cid)
    end
    return true
end
 
Last edited:
Never place code inside a spoiler tag and then center it... you might as well just past it with no tags or formatting...
It is extra work if we have to format your code, meet us half way we know the language, don't insult us by making us format your code too.
 
If this is the whole script for catacomb_window.lua
Then change this
Code:
if modalWindowId ~= 1900 then
to this
Code:
if modalWindowId == nil or modalWindowId ~= 1900 then
 
Line 7 of catacomb_window.lua is return false, that is why i sort of asked if it was the whole script.
 
Code:
[1] = {placeName = "Dorion (Depot)", placeStorage = 6661, placepos = {x = 80, y = 64, z = 6}},
[2] = {placeName = "Venonh (Pits of Inferno)", placeStorage = 6662, placepos = {x = 346, y = 359, z = 8}},
[3] = {placeName = "Roshamuul (Gaz'Haragoth Lair)", placeStorage = 6663, placepos = {x = 2074, y = 228, z = 9}}
Replace.
 
Did you add this part
Code:
dofile('data/catacombs.lua')
Correctly?

it seems like it doesn't read the table

also try this
Code:
function onModalWindow(cid, modalWindowId, buttonId, choiceId)
local placess =
{
[1] = {placeName = "Dorion (Depot)", placeStorage = 6671, placepos = {x = 80, y = 64, z = 6}},
[2] = {placeName = "Venonh (Pits of Inferno)", placeStorage = 6672, placepos = {x = 346, y = 359, z = 8}},
[3] = {placeName = "Roshamuul (Gaz'Haragoth Lair)", placeStorage = 6673, placepos = {x = 2074, y = 228, z = 9}}
}
local player = Player(cid)
local pos = player:getPosition()

if modalWindowId ~= 1900 then
return false
end

if buttonId == 1 then -- Teleport

if getCreatureStorage(cid, placess[choiceId].placeStorage) == 1 then
pos:sendMagicEffect(11)
player:teleportTo(placess[choiceId].placepos)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have succesfully teleported to ' .. placess[choiceId].placeName .. '.')
doSendMagicEffect(placess[choiceId].placepos, 11)
else
sendCatacombWindow(cid)
end

elseif buttonId == 255 then
doPlayerPopupFYI(cid,"Please use a button.")
sendCatacombWindow(cid)
end

return true
end
 
Good mornin'!

First of, thank you for taking your time on this!

Secondly Ive pasted the dofile('data/compat.lua') right on top of global.lua, beneath
Code:
dofile('data/compat.lua')
dofile('data/catacombs.lua')

TRUE = true
FALSE = false

Your script loads fine but starts an error in teleporter.lua

GAOvbWNp.png


the code:
Code:
function onStepIn(creature, item, position, fromPosition)
    local player = Player(creature)
    if not player then
        return true
    end
    local pos = player:getPosition()


    if player:getStorageValue(6661) == 1 then
        return player:sendCatacombWindow()
    end

    return true
end

@StreamSide I searched around for a while but couldnt find the script you are talking about. Cheers again!
 
Back
Top