local action = Action()
local config = {
itemId = 2493,
monsterN = "Demon",
cooldown = 1, -- 60 = 60 seconds
cooldownStorage = 6500,
effect = CONST_ME_HOLYAREA,
effectSpawn = true
}
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getStorageValue(config.cooldownStorage) - os.time() > 0 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can use it again in: "..player:getStorageValue(config.cooldownStorage) - os.time().." seconds.")
return true
end
local monster = Game.createMonster(config.monsterN, player:getPosition())
player:setStorageValue(config.cooldownStorage, os.time() + config.cooldown)
if config.effectSpawn then
monster:getPosition():sendMagicEffect(config.effect)
end
return true
end
action:id(config.itemId)
action:register()