zbizu
Legendary OT User
improved version of this: https://otland.net/threads/tfs-1-1-...ablo-3-teleport-great-for-rpg-servers.230015/
stepping on spot unlocks it
configurable price
id 3169, set uid and add it to table later to create spot
creaturescripts.xml
tp_pad.lua creaturescript
movements.xml
tp_pad.lua movement
stepping on spot unlocks it
configurable price
id 3169, set uid and add it to table later to create spot
creaturescripts.xml
Code:
<event type="modalwindow" name="tp_pad" script="tp_pad.lua"/>
<event type="login" name="tp_pad_register" script="tp_pad.lua"/>
tp_pad.lua creaturescript
Code:
function onModalWindow(player, modalWindowId, buttonId, choiceId)
if modalWindowId == 1860 then
if not tp_pads[choiceId + 8300] then
return true
end
local npos = Item(choiceId + 8300):getPosition()
if buttonId == 1 then
if tp_pads[choiceId + 8300].price ~= nil then
if not doPlayerRemoveMoney(player, tp_pads[choiceId + 8300].price) then
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "You don't have enough money.")
return true
end
end
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
player:teleportTo(npos)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return true
end
end
return true
end
function onLogin(player)
player:registerEvent("tp_pad")
return true
end
movements.xml
Code:
<movevent event="StepIn" itemid="3169" script="tp_pad.lua"/>
tp_pad.lua movement
Code:
tp_pads = {
[8301] = {price = 300, name = "Spot 1", storage = 99586},
[8302] = {price = 300, name = "Spot 2", storage = 99587},
[8303] = {price = 0, name = "Spot 3", storage = 99588},
[8304] = {price = 300, name = "Spot 4", storage = 99589},
[8305] = {price = 300, name = "Spot 5", storage = 99590}
}
function onStepIn(player, item, position, fromPosition)
if not tp_pads[item.uid] then return true end
if not isInRange(position, {x = fromPosition.x - 1, y = fromPosition.y - 1, z = fromPosition.z}, {x = fromPosition.x + 1, y = fromPosition.y + 1, z = fromPosition.z}) then
-- player got there from another pad
return true
end
if not player:isPlayer() then
return true
end
if tp_pads[item.uid].storage then
if player:getStorageValue(tp_pads[item.uid].storage) < 1 then
player:setStorageValue(tp_pads[item.uid].storage, 1)
player:say("Spot unlocked.", TALKTYPE_ORANGE_1, true, player, player:getPosition())
end
end
if player:isPzLocked() then
player:teleportTo(fromPosition)
player:say("The pad is not responding.", TALKTYPE_ORANGE_1, true, player, player:getPosition())
else
local padWindow = ModalWindow(1860, "Teleport", "Select destination:")
for i = 8301, 8305 do
if i ~= item.uid then
if tp_pads[i].price then
if tp_pads[i].storage then
if player:getStorageValue(tp_pads[i].storage) > 0 then
padWindow:addChoice(i - 8300, tp_pads[i].name .. (tp_pads[i].price > 0 and " [" .. tp_pads[i].price .. " gold]" or ""))
end
else
padWindow:addChoice(i - 8300, tp_pads[i].name .. (tp_pads[i].price > 0 and " [" .. tp_pads[i].price .. " gold]" or ""))
end
else
if tp_pads[i].storage then
if player:getStorageValue(tp_pads[i].storage) > 0 then
padWindow:addChoice(i - 8300, tp_pads[i].name)
end
else
padWindow:addChoice(i - 8300, tp_pads[i].name)
end
end
end
end
padWindow:addButton(1, "Select")
padWindow:addButton(2, "Cancel")
padWindow:setDefaultEnterButton(1)
padWindow:setDefaultEscapeButton(2)
padWindow:sendToPlayer(player)
end
return true
end