bolachapanco
Member
How could I add a cooldown to this script and show a message about how much time is left before I can use the item again
Lua:
local config = {
{ name = "Ab'Dendriel", position = Position(32732, 31634, 7) },
{ name = "Ankrahmun", position = Position(33194, 32853, 8) },
{ name = "Carlin", position = Position(32360, 31782, 7) },
{ name = "Darashia", position = Position(33213, 32454, 1) },
{ name = "Edron", position = Position(33217, 31814, 7) },
{ name = "Kazordoon", position = Position(32649, 31925, 11) },
{ name = "Liberty Bay", position = Position(32317, 32826, 7) },
{ name = "Port Hope", position = Position(32595, 32744, 7) },
{ name = "Thais", position = Position(32369, 32241, 7) },
{ name = "Venore", position = Position(32957, 32076, 7) }
}
local teleportCube = Action()
function teleportCube.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local window = ModalWindow {
title = "Teleport System",
message = "Locations"
}
for i, info in pairs(config) do
window:addChoice(string.format("%s", info.name), function (player, button, choice)
if button.name ~= "Select" then
return true
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You were teleported to " .. info.name)
player:teleportTo(info.position)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return true
end)
end
window:addButton("Select")
window:addButton("Close")
window:setDefaultEnterButton(0)
window:setDefaultEscapeButton(1)
window:sendToPlayer(player)
return true
end
teleportCube:id(31633)
teleportCube:register()