• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Zombie event autostarter, need it to stop spawning zombies after x time.

ohman

Member
Joined
Oct 24, 2008
Messages
294
Reaction score
8
Location
Sweden
Hi! When no players is joining zombie event the event will spawn zombies untill it got no place to spawn. How to do like an event "addEvent(stopevent, 600*1000)"? So all zombies will be delted and no more zombies created.

This is the autostarter:
Code:
function onTime(interval, lastExecution)
local players_on_arena_count = #getZombiesEventPlayers()
local function start()
if(players_on_arena_count >= 0) then
addZombiesEventBlockEnterPosition()
doSetStorage(ZE_STATUS, 2)
doBroadcastMessage("Zombie Event has started")
else
addZombiesEventBlockEnterPosition()
end
return true
end
setZombiesEventPlayersLimit(100)
doBroadcastMessage("Zombie Event is starting in 1 minutes. Enter the teleport in Thais temple to join!")
removeZombiesEventBlockEnterPosition()
addEvent(start,60*1000)
doSetStorage(ZE_STATUS, 1)
return true
end

I tried to do it like this:
Code:
function onTime(interval, lastExecution)
local players_on_arena_count = #getZombiesEventPlayers()
local function start()
if(players_on_arena_count >= 0) then
addZombiesEventBlockEnterPosition()
doSetStorage(ZE_STATUS, 2)
doBroadcastMessage("Zombie Event has started")
else
addZombiesEventBlockEnterPosition()
end
return true
end
setZombiesEventPlayersLimit(100)
doBroadcastMessage("Zombie Event is starting in 1 minutes. Enter the teleport in Thais temple to join!")
removeZombiesEventBlockEnterPosition()
addEvent(start,60*1000)
addEvent(stopeventzombie,600*1000)
doSetStorage(ZE_STATUS, 1)
return true
end
local function stopeventzombie()
if(players_on_arena_count >= 0) then
        doSetStorage(ZE_STATUS, 0)
        doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
        doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
        doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
        local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1
        local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1
        local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}
        for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do
            centerPos.z = z
            for i, uid in pairs(getSpectators(centerPos, width, height, false)) do
                if(isMonster(uid)) then
                    doRemoveCreature(uid)
                end
            end
        end
    end
end

But I got this error when the event is started.
The error:
[17:36:45.558] [Error - GlobalEvent Interface]
[17:36:45.558] data/globalevents/scripts/zombie/autostart.lua:onTime
[17:36:45.558] Description:
[17:36:45.558] (luaAddEvent) Callback parameter should be a function

Thanks! :)
 
Try This One
Code:
function doClean()
if(players_on_arena_count > 0) then
doSetStorage(ZE_STATUS, 0)
doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
  doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
  for x = ZE_spawnFromPosition.x, ZE_spawnToPosition.x do
        for y = ZE_spawnFromPosition.y, ZE_spawnToPosition.y do
            for z = ZE_spawnFromPosition.z, ZE_spawnToPosition.z do
                local pos = {x = x, y = y, z = z, stackpos = 253}
                local v = getThingfromPos(pos).uid
                if isMonster(v) then
                doRemoveCreature(v)
                end
            end
        end
    end
return true
end
end

function start()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count > 0) then
addZombiesEventBlockEnterPosition()
doSetStorage(ZE_STATUS, 2)
doBroadcastMessage("Zombie Event has started")
else
addZombiesEventBlockEnterPosition()
doBroadcastMessage("Zombie Event Couldn't Start Because of Low Players")
end
return true
end

function onTime(interval, lastExecution)
local players_on_arena_count = #getZombiesEventPlayers()
setZombiesEventPlayersLimit(100)
doBroadcastMessage("Zombie Event is starting in 1 minutes. Enter the teleport in Thais temple to join!")
removeZombiesEventBlockEnterPosition()
addEvent(start,60*1000)
addEvent(doClean,600*1000)
return true
end
Note:that script you are using is made by me :)
 
Try This One
Code:
function doClean()
if(players_on_arena_count > 0) then
doSetStorage(ZE_STATUS, 0)
doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
  doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
  for x = ZE_spawnFromPosition.x, ZE_spawnToPosition.x do
        for y = ZE_spawnFromPosition.y, ZE_spawnToPosition.y do
            for z = ZE_spawnFromPosition.z, ZE_spawnToPosition.z do
                local pos = {x = x, y = y, z = z, stackpos = 253}
                local v = getThingfromPos(pos).uid
                if isMonster(v) then
                doRemoveCreature(v)
                end
            end
        end
    end
return true
end
end

function start()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count > 0) then
addZombiesEventBlockEnterPosition()
doSetStorage(ZE_STATUS, 2)
doBroadcastMessage("Zombie Event has started")
else
addZombiesEventBlockEnterPosition()
doBroadcastMessage("Zombie Event Couldn't Start Because of Low Players")
end
return true
end

function onTime(interval, lastExecution)
local players_on_arena_count = #getZombiesEventPlayers()
setZombiesEventPlayersLimit(100)
doBroadcastMessage("Zombie Event is starting in 1 minutes. Enter the teleport in Thais temple to join!")
removeZombiesEventBlockEnterPosition()
addEvent(start,60*1000)
addEvent(doClean,600*1000)
return true
end
Note:that script you are using is made by me :)

It didnt work :/

[21:4:40.656] [Error - GlobalEvent Interface]
[21:4:40.656] In a timer event called from:
[21:4:40.656] data/globalevents/scripts/zombie/autostart.lua:onTime
[21:4:40.656] Description:
[21:4:40.656] data/globalevents/scripts/zombie/autostart.lua:2: attempt to compare number with nil
[21:4:40.656] stack traceback:
[21:4:40.656] data/globalevents/scripts/zombie/autostart.lua:2: in function <data/globalevents/scripts/zombie/autostart.lua:1>
 
Code:
function doClean()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count > 0) then
doSetStorage(ZE_STATUS, 0)
doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
for x = ZE_spawnFromPosition.x, ZE_spawnToPosition.x do
for y = ZE_spawnFromPosition.y, ZE_spawnToPosition.y do
for z = ZE_spawnFromPosition.z, ZE_spawnToPosition.z do
local pos = {x = x, y = y, z = z, stackpos = 253}
local v = getThingfromPos(pos).uid
if isMonster(v) then
doRemoveCreature(v)
end
end
end
end
return true
end
end

function start()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count > 0) then
addZombiesEventBlockEnterPosition()
doSetStorage(ZE_STATUS, 2)
doBroadcastMessage("Zombie Event has started")
else
addZombiesEventBlockEnterPosition()
doBroadcastMessage("Zombie Event Couldn't Start Because of Low Players")
end
return true
end

function onTime(interval, lastExecution)
local players_on_arena_count = #getZombiesEventPlayers()
setZombiesEventPlayersLimit(100)
doBroadcastMessage("Zombie Event is starting in 1 minutes. Enter the teleport in Thais temple to join!")
removeZombiesEventBlockEnterPosition()
addEvent(start,60*1000)
addEvent(doClean,600*1000)
return true
end
 
Code:
function doClean()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count > 0) then
doSetStorage(ZE_STATUS, 0)
doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
for x = ZE_spawnFromPosition.x, ZE_spawnToPosition.x do
for y = ZE_spawnFromPosition.y, ZE_spawnToPosition.y do
for z = ZE_spawnFromPosition.z, ZE_spawnToPosition.z do
local pos = {x = x, y = y, z = z, stackpos = 253}
local v = getThingfromPos(pos).uid
if isMonster(v) then
doRemoveCreature(v)
end
end
end
end
return true
end
end

function start()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count > 0) then
addZombiesEventBlockEnterPosition()
doSetStorage(ZE_STATUS, 2)
doBroadcastMessage("Zombie Event has started")
else
addZombiesEventBlockEnterPosition()
doBroadcastMessage("Zombie Event Couldn't Start Because of Low Players")
end
return true
end

function onTime(interval, lastExecution)
local players_on_arena_count = #getZombiesEventPlayers()
setZombiesEventPlayersLimit(100)
doBroadcastMessage("Zombie Event is starting in 1 minutes. Enter the teleport in Thais temple to join!")
removeZombiesEventBlockEnterPosition()
addEvent(start,60*1000)
addEvent(doClean,600*1000)
return true
end

The cleanup works. But players cant enter the event teleport now. When a player tries, the item that blocks teleport appears (I changed it so it blockes the TP instead of deleting the TP), it worked before. The gamemaster can enter.
 
Code:
function onTime(interval, lastExecution)
setZombiesEventPlayersLimit(100)
doBroadcastMessage("Zombie Event is starting in 1 minutes. Enter the teleport in Thais temple to join!")
removeZombiesEventBlockEnterPosition()
addEvent(start,60*1000)
addEvent(doClean,600*1000)
doSetStorage(ZE_STATUS, 1)
return true
end

local function start()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count >= 0) then
addZombiesEventBlockEnterPosition()
doSetStorage(ZE_STATUS, 2)
doBroadcastMessage("Zombie Event has started")
else
addZombiesEventBlockEnterPosition()
end
return true
end

function doClean()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count > 0) then
doSetStorage(ZE_STATUS, 0)
doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
for x = ZE_spawnFromPosition.x, ZE_spawnToPosition.x do
for y = ZE_spawnFromPosition.y, ZE_spawnToPosition.y do
for z = ZE_spawnFromPosition.z, ZE_spawnToPosition.z do
local pos = {x = x, y = y, z = z, stackpos = 253}
local v = getThingfromPos(pos).uid
if isMonster(v) then
doRemoveCreature(v)
end
end
end
end
return true
end
end
 
Code:
function onTime(interval, lastExecution)
setZombiesEventPlayersLimit(100)
doBroadcastMessage("Zombie Event is starting in 1 minutes. Enter the teleport in Thais temple to join!")
removeZombiesEventBlockEnterPosition()
addEvent(start,60*1000)
addEvent(doClean,600*1000)
doSetStorage(ZE_STATUS, 1)
return true
end

local function start()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count >= 0) then
addZombiesEventBlockEnterPosition()
doSetStorage(ZE_STATUS, 2)
doBroadcastMessage("Zombie Event has started")
else
addZombiesEventBlockEnterPosition()
end
return true
end

function doClean()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count > 0) then
doSetStorage(ZE_STATUS, 0)
doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
for x = ZE_spawnFromPosition.x, ZE_spawnToPosition.x do
for y = ZE_spawnFromPosition.y, ZE_spawnToPosition.y do
for z = ZE_spawnFromPosition.z, ZE_spawnToPosition.z do
local pos = {x = x, y = y, z = z, stackpos = 253}
local v = getThingfromPos(pos).uid
if isMonster(v) then
doRemoveCreature(v)
end
end
end
end
return true
end
end

Players can enter TP. But the event dont start.

[21:44:00.383] [Error - GlobalEvent Interface]
[21:44:00.383] data/globalevents/scripts/zombie/autostart.lua:onTime
[21:44:00.383] Description:
[21:44:00.383] (luaAddEvent) Callback parameter should be a function

Thank you so mush for your help!
 
Code:
function start()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count >= 0) then
addZombiesEventBlockEnterPosition()
doSetStorage(ZE_STATUS, 2)
doBroadcastMessage("Zombie Event has started")
else
addZombiesEventBlockEnterPosition()
end
return true
end

function doClean()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count > 0) then
doSetStorage(ZE_STATUS, 0)
doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
for x = ZE_spawnFromPosition.x, ZE_spawnToPosition.x do
for y = ZE_spawnFromPosition.y, ZE_spawnToPosition.y do
for z = ZE_spawnFromPosition.z, ZE_spawnToPosition.z do
local pos = {x = x, y = y, z = z, stackpos = 253}
local v = getThingfromPos(pos).uid
if isMonster(v) then
doRemoveCreature(v)
end
end
end
end
return true
end

function onTime(interval, lastExecution)
setZombiesEventPlayersLimit(100)
doBroadcastMessage("Zombie Event is starting in 1 minutes. Enter the teleport in Thais temple to join!")
removeZombiesEventBlockEnterPosition()
addEvent(start,60*1000)
addEvent(doClean,600*1000)
doSetStorage(ZE_STATUS, 1)
return true
end
 
Code:
function start()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count >= 0) then
addZombiesEventBlockEnterPosition()
doSetStorage(ZE_STATUS, 2)
doBroadcastMessage("Zombie Event has started")
else
addZombiesEventBlockEnterPosition()
end
return true
end

function doClean()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count > 0) then
doSetStorage(ZE_STATUS, 0)
doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
for x = ZE_spawnFromPosition.x, ZE_spawnToPosition.x do
for y = ZE_spawnFromPosition.y, ZE_spawnToPosition.y do
for z = ZE_spawnFromPosition.z, ZE_spawnToPosition.z do
local pos = {x = x, y = y, z = z, stackpos = 253}
local v = getThingfromPos(pos).uid
if isMonster(v) then
doRemoveCreature(v)
end
end
end
end
return true
end

function onTime(interval, lastExecution)
setZombiesEventPlayersLimit(100)
doBroadcastMessage("Zombie Event is starting in 1 minutes. Enter the teleport in Thais temple to join!")
removeZombiesEventBlockEnterPosition()
addEvent(start,60*1000)
addEvent(doClean,600*1000)
doSetStorage(ZE_STATUS, 1)
return true
end

Cant load the script :(

[17:21:06.306] [Error - LuaInterface::loadFile] data/globalevents/scripts/zombie/autostart.lua:41: 'end' expected (to close 'function' at line 13) near '<eof>'
[17:21:06.306] [Error - Event::checkScript] Cannot load script (data/globalevents/scripts/zombie/autostart.lua)
[17:21:06.307] data/globalevents/scripts/zombie/autostart.lua:41: 'end' expected (to close 'function' at line 13) near '<eof>'

EDIT: Fixed that error by adding one more "end" in function doClean. I'll try the script now.

EDIT AGAIN: IT WORKS!! thanks :):)
 
Last edited:
Cant load the script :(



EDIT: Fixed that error by adding one more "end" in function doClean. I'll try the script now.

EDIT AGAIN: IT WORKS!! thanks :):)
Can you post the fixed scrip
Cant load the script :(



EDIT: Fixed that error by adding one more "end" in function doClean. I'll try the script now.

EDIT AGAIN: IT WORKS!! thanks :):)
Can you post the fixed scrip pls
 
Code:
function start()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count >= 0) then
addZombiesEventBlockEnterPosition()
doSetStorage(ZE_STATUS, 2)
doBroadcastMessage("Zombie Event has started")
else
addZombiesEventBlockEnterPosition()
end
return true
end

function doClean()
local players_on_arena_count = #getZombiesEventPlayers()
if(players_on_arena_count > 0) then
doSetStorage(ZE_STATUS, 0)
doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
for x = ZE_spawnFromPosition.x, ZE_spawnToPosition.x do
for y = ZE_spawnFromPosition.y, ZE_spawnToPosition.y do
for z = ZE_spawnFromPosition.z, ZE_spawnToPosition.z do
local pos = {x = x, y = y, z = z, stackpos = 253}
local v = getThingfromPos(pos).uid
if isMonster(v) then
doRemoveCreature(v)
end
end
end
end
end
return true
end

function onTime(interval, lastExecution)
setZombiesEventPlayersLimit(100)
doBroadcastMessage("Zombie Event is starting in 1 minutes. Enter the teleport in Thais temple to join!")
removeZombiesEventBlockEnterPosition()
addEvent(start,60*1000)
addEvent(doClean,600*1000)
doSetStorage(ZE_STATUS, 1)
return true
end
 
Back
Top