Hello im using script that spawns boss every hour and it has 10% chance to be spawned every one hour but i want it to edit because it has one issue, how can i stop it from spawning that same boss if it was already spawned?
Lua:
local timeToRemove = 3600 * 1000 -- 1 hour
local function removeBoss(uid)
local monster = Monster(uid)
if not monster then
return
end
monster:remove()
broadcastMessage("1 Hour has passed, and no one defeated the Daily Boss!", MESSAGE_EVENT_ADVANCE)
end
function onThink(interval)
local state = Game.getGameState()
if state == GAME_STATE_CLOSED or state == GAME_STATE_CLOSING then
return true
end
local rand = math.random(1, 100)
if rand <= 10 then
local creature = monsterSystem[math.random(#monsterSystem)]
local monster = Game.createMonster(creature.name, creature.pos)
if monster then
broadcastMessage(creature.msg, MESSAGE_EVENT_ADVANCE)
Creature(monster):registerEvent("AutoEvent")
addEvent(removeBoss, timeToRemove, monster:getId())
end
return true
end
return true
end