local skulls = {SKULL_BLACK, SKULL_RED, SKULL_GREEN, SKULL_ORANGE, SKULL_YELLOW, SKULL_WHITE}
local position = Position(1000, 1000, 7)
local effect = CONST_ME_POFF
local itemId = 2299
local exhaustTable = {}
local cooldown = 60
local action = Action()
function action.onUse(player, item, fromPos, target, toPos, isHotkey)
if not player then
return true
end
local playerGuid = player:getGuid()
local timeAmount = exhaustTable[playerGuid]
if timeAmount and timeAmount > os.time() then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must wait " .. (timeAmount - os.time()) .. " seconds.")
return true
end
if table.contains(skulls, player:getSkull()) then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You can not use this item aslong you got a skull.')
return true
end
player:teleportTo(position)
player:getPosition():sendMagicEffect(effect)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have been teleported.')
exhaustTable[playerGuid] = os.time() + cooldown
return true
end
action:id(itemId)
action:register()