local time = 600 -- tempo em segundos para usar
local monster = "Demon" -- "Monstro" entre aspas
local pos = {x=805, y=568, z=7} -- Posição que irá nascer.
local from,to = {x=790, y=550, z=7},{x=820, y=575, z=7} -- area total da area onde o monstro vai estar
function CheckArea(area)
local var = 0
for x = area[1].x - 1, area[2].x + 1 do
for y = area[1].y - 1, area[2].y + 1 do
local pos = {x=x, y=y, z=area[1].z}
local m = getTopCreature(pos).uid
if m ~= 0 and isMonster(m) then
var = var +1
end
end
end
return var
end
function onUse(cid, item, frompos, itemex, topos)
if getStorage(2111) - os.time() < 1 then
if CheckArea({from,to}) == 0 then
doSetStorage(2111, os.time() + time)
addEvent(function() doCreateMonster(monster, pos) end, 10000)
doCreatureSay(cid, "Demon Invocado ! Prepare-se !", TALKTYPE_MONSTER)
else
doPlayerSendCancel(cid, "ja existe um monstro na area")
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) return true
end
else
doPlayerSendCancel(cid, "Voce precisa esperar ".. getStorage(2111) - os.time() .." Segundos restantes")
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) return true
end
doTransformItem(item.uid, item.itemid % 2 == 1 and item.itemid + 1 or item.itemid + -1)
return true
end