hello, could someone be exhausted in this script for the player to be able to teleport in the same place only after 2 min
Lua:
local WINDOW_ID = 4203
local BUTTON_ACCEPT = 0
local BUTTON_CLOSE = 1
local WAYPOINTS_STORAGE = 41875
local WAYPOINTS = {
[1] = {
name = "Ghostlands",
position = Position(32189, 31809, 6)
},
[2] = {
name = "Plains of Havoc",
position = Position(32715, 32328, 6)
},
[3] = {
name = "Ankrahmun Desert",
position = Position(33207, 32675, 6)
},
[4] = {
name = "Edron Nort",
position = Position(33159, 31657, 6)
},
[5] = {
name = "Roshamuul Nort",
position = Position(33631, 32385, 6)
},
[6] = {
name = "Issavi Centre",
position = Position(33896, 31511, 6)
},
[7] = {
name = "Svargrond",
position = Position(32296, 31152, 6)
},
[8] = {
name = "Liberty Bay Nort",
position = Position(32306, 32740, 6)
},
[9] = {
name = "Port Hope Nort",
position = Position(32643, 32679, 6)
},
[10] = {
name = "Yalahar Nort",
position = Position(32775, 31074, 6)
},
[11] = {
name = "Oramond",
position = Position(33677, 31950, 6)
},
[12] = {
name = "Zao Step",
position = Position(33153, 31246, 6)
}
}
function onStepIn(player, item, position, fromPosition)
if player:isPlayer() and fromPosition:getDistance(position) == 1 then
for i = 1, #WAYPOINTS do
local waypoint = WAYPOINTS[i]
if position == waypoint.position and player:getStorageValue(WAYPOINTS_STORAGE + i) ~= 1 then
player:setStorageValue(WAYPOINTS_STORAGE + i, 1)
player:sendTextMessage(MESSAGE_INFO_DESCR, "New waypoint unlocked!\n-- " .. waypoint.name .. " --")
return true
end
end
local empty = true
for i = 1, #WAYPOINTS do
local waypoint = WAYPOINTS[i]
if position == waypoint.position and player:getStorageValue(WAYPOINTS_STORAGE + i) == 1 then
empty = false
break
end
end
if not empty then
player:registerEvent("WaypointsModal")
local title = "Teletransport"
local message = "Choose your destination."
local window = ModalWindow(WINDOW_ID, title, message)
window:addButton(BUTTON_ACCEPT, "Teleport")
window:addButton(BUTTON_CLOSE, "Close")
for i = 1, #WAYPOINTS do
local waypoint = WAYPOINTS[i]
if player:getStorageValue(WAYPOINTS_STORAGE + i) == 1 then
window:addChoice(i, waypoint.name)
end
end
window:setDefaultEnterButton(BUTTON_ACCEPT)
window:setDefaultEscapeButton(BUTTON_CLOSE)
window:sendToPlayer(player)
end
end
return true
end
function onWaypointsModal(player, modalWindowId, buttonId, choiceId)
player:unregisterEvent("WaypointsModal")
if modalWindowId == WINDOW_ID then
if buttonId == BUTTON_ACCEPT then
if player:getStorageValue(WAYPOINTS_STORAGE + choiceId) == 1 then
player:teleportTo(WAYPOINTS[choiceId].position)
WAYPOINTS[choiceId].position:sendMagicEffect(CONST_ME_ENERGYAREA)
end
end
end
end