data/scripts/teleporttown.lua
If you dont want this script only play for premium, need delete this part of script
I'm not a programmer, but I can pretend to be one. I have my favorite tool if you know how to use it well, Chat gpt... it doesn't make the best scripts but they work for you. If you have any questions, ask me and I'll ask her for you!
I hope I can help people with the same level of knowledge as me. It is appreciated to see these scripts and to return the favor with the same love!
be happy, regards!
LUA:
local teleportItemId = 26398
local config = {
modalWindow = {
id = 1001,
title = "Stone Teleport",
message = "Select a city to teleport:",
eventText = "ModalWindow_TeleportCities",
buttons = {
{text = "Teleport", defaultEnterButton = true},
{text = "Cancel", defaultEscapeButton = true},
}
},
cities = {
{name = "City1", pos = Position(1283, 615, 5)}, -- Example positions, replace with actual temple positions
{name = "City2", pos = Position(960, 1058, 7)},
{name = "City3", pos = Position(1703, 950, 8)},
{name = "City4", pos = Position(1669, 1279, 6)},
{name = "City5", pos = Position(439, 520, 7)},
}
}
-- End configuration --
local function createCityTeleportWindow(playerId)
local player = Player(playerId)
if not player then
return
end
if not player:isPremium() then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You need to be a premium player to use this stone.")
return
end
if player:hasEvent(CREATURE_EVENT_MODALWINDOW, config.modalWindow.eventText) then
player:unregisterEvent(config.modalWindow.eventText)
end
player:registerEvent(config.modalWindow.eventText)
local modalWindow = ModalWindow(config.modalWindow.id, config.modalWindow.title, config.modalWindow.message)
for id, button in ipairs(config.modalWindow.buttons) do
modalWindow:addButton(id, button.text)
if button.defaultEscapeButton then
modalWindow:setDefaultEscapeButton(id)
elseif button.defaultEnterButton then
modalWindow:setDefaultEnterButton(id)
end
end
for id, city in ipairs(config.cities) do
modalWindow:addChoice(id, city.name)
end
modalWindow:hasPriority()
modalWindow:sendToPlayer(player)
end
local action = Action()
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item:getId() == teleportItemId then
createCityTeleportWindow(player:getId())
end
return true
end
action:id(teleportItemId)
action:register()
local creatureevent = CreatureEvent(config.modalWindow.eventText)
function creatureevent.onModalWindow(player, modalWindowId, buttonId, choiceId)
player:unregisterEvent(config.modalWindow.eventText)
if modalWindowId == config.modalWindow.id then
local buttonChoice = config.modalWindow.buttons[buttonId].text
if buttonChoice == "Teleport" then
local city = config.cities[choiceId]
if city then
player:teleportTo(city.pos)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have been teleported to " .. city.name .. "!")
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Invalid city selection.")
end
end
end
end
creatureevent:register()
If you dont want this script only play for premium, need delete this part of script
LUA:
if not player:isPremium() then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You need to be a premium player to use this stone.")
return
end
I'm not a programmer, but I can pretend to be one. I have my favorite tool if you know how to use it well, Chat gpt... it doesn't make the best scripts but they work for you. If you have any questions, ask me and I'll ask her for you!
I hope I can help people with the same level of knowledge as me. It is appreciated to see these scripts and to return the favor with the same love!
be happy, regards!