Original thread:
https://otland.net/threads/tfs-1-1-...ablo-3-teleport-great-for-rpg-servers.230015/
https://otland.net/threads/tfs-1-1-...ablo-3-teleport-great-for-rpg-servers.230015/
In data/lib create 010-teleport.lua file and paste:
PHP:
places = {
{placeName = 'Cirith Deposit', placeStorage = 6661, placepos = {x = 1304, y = 891, z = 8}},
{placeName = 'Azshara West Catacomb', placeStorage = 6662, placepos = {x = 246, y = 485, z = 8}},
{placeName = 'Azshara North Catacomb', placeStorage = 6663, placepos = {x = 259, y = 401, z = 7}}
}
modalId = 1900
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)
modalWindowCreate(modalId, 'Teleporter', 'Select place:')
modalWindowAddButton(modalId, 1, 'Teleport')
setDefaultEnterButton(modalId, 1)
modalWindowAddButton(modalId, 2, 'Cancel')
setDefaultEscapeButton(modalId, 2)
for i = 1, #places do
if getCreatureStorage(cid, places[i].placeStorage) == 1 then
addChoice(modalId, i, places[i].placeName)
end
end
sendToPlayer(cid, modalId)
return true
end
In data/movements/movements.xml paste:
PHP:
<movevent type="StepIn" actionid="9024" event="script" value="catacombs/teleporter.lua"/>
<movevent type="StepIn" uniqueid="6661-6663" event="script" value="catacombs/catacombsTiles.lua"/>
And create folder with name catacombs into data/movements/scripts and create two folders:
teleporter.lua
PHP:
function onStepIn(cid, item, position, fromPosition)
return sendCatacombWindow(cid)
end
And catacombsTiles.lua
PHP:
local config = {
[6661] = {{x = 1305, y = 891, z = 8}, CONST_ME_METEORITE, 'Cirith Deposit'},
}
function onStepIn(cid, item, position, fromPosition)
local catacombsConfig = config[item.uid]
if not catacombsConfig then
return true
end
if getCreatureStorage(cid, item.uid) < 1 then
doCreatureSetStorage(cid, item.uid, 1)
doCreatureSay(cid, 'It looks like a teleporter.', TALKTYPE_MONSTER)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You have unlocked Catacomb Teleporter: ' .. catacombsConfig[3] .. '.')
doSendMagicEffect(catacombsConfig[1], catacombsConfig[2])
end
return true
end
Next step is data/creaturescripts. Into .xml file paste:
PHP:
<event type="modalwindow" name="catacombw" event="script" value="catacomb_window.lua"/>
And data/creaturescripts/scripts create new file catacomb_window.lua and paste:
PHP:
function onModalWindow(cid, modalWindowId, buttonId, choiceId)
if modalWindowId ~= 1900 then
return false
end
if buttonId == 1 then -- Teleport
if getCreatureStorage(cid, places[choiceId].placeStorage) == 1 then
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
doTeleportThing(cid, places[choiceId].placepos, true, true)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You have succesfully teleported to ' .. places[choiceId].placeName .. '.')
doSendMagicEffect(places[choiceId].placepos, CONST_ME_TELEPORT)
else
sendCatacombWindow(cid)
end
elseif buttonId == 255 then
doPlayerPopupFYI(cid,"Please use a button.")
sendCatacombWindow(cid)
end
return true
end