• 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!

RevScripts ZOMBIE EVENT SYSTEM

Gaber Zen

Well-Known Member
Joined
Apr 22, 2023
Messages
224
Reaction score
51
Location
Egypt
some one help me, everytime need open event zombie use!zombie start like Talkaction.
how can work in globalevents
0.4
Lua:
function onSay(cid, words, param, channel)
    if(getStorage(ZE_STATUS) ~= 2) then
        local players_on_arena_count = #getZombiesEventPlayers()
        if(param == 'force') then
            if(players_on_arena_count > 0) then
                setZombiesEventPlayersLimit(players_on_arena_count  )
                addZombiesEventBlockEnterPosition()
                doSetStorage(ZE_STATUS, 2)
                doBroadcastMessage("Zombie Arena Event started.")
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Zombies event started.")
            else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Cannot start Zombies event. There is no players on arena.")
            end
        else
            if(param ~= '' and tonumber(param) > 0) then
                setZombiesEventPlayersLimit(tonumber(param))
            end
            removeZombiesEventBlockEnterPosition()
            doSetStorage(ZE_STATUS, 1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Event started.")
            doPlayerBroadcastMessage(cid, "Zombie Arena Event teleport is opened. We are waiting for " .. getZombiesEventPlayersLimit() - players_on_arena_count .. " players to start.")
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Zombies event is already running.")
    end
    return true
end

<talkaction log="yes" words="/zombiestart" access="4" event="script" value="zombie/onsay.lua"/>
<globalevent name="ZombieGlobalThink" interval="5000" event="script" value="zombie/onthink.lua"/>
<globalevent name="ZombieGlobalStartup" type="start" event="script" value="zombie/onstartup.lua"/>
Lua:
function onThink(interval, lastExecution, thinkInterval)
    if(getStorage(ZE_STATUS) == 2) then
        setZombiesToSpawnCount(getZombiesToSpawnCount()+1)
        local players = getZombiesEventPlayers()
        for i=1, getZombiesToSpawnCount() * 2 do
            if(getZombiesToSpawnCount() > 0 and spawnNewZombie()) then
                setZombiesToSpawnCount(getZombiesToSpawnCount()-1)
            end
        end
    end
    return true
end
Code:
function onStartup()
    db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = " .. ZE_isOnZombieArea .. ";")
    doSetStorage(ZE_STATUS, 0)
    doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
    doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
    doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
    addZombiesEventBlockEnterPosition()
    return true
end
 
Last edited:
Here is my engine script, fully working in globalevents. Only for 1+ engines. Maybe the code will help you though.
Lua:
-- <globalevent name="Zumbi_Event" time="1:55:00" script="ZE_globalevents.lua"/>

dofile('data/lib/ZE_config.lua')

zeArenaFromPosition = Position(712, 1410, 14) --pos of top left corner {x = 767, y = 1410, z = 7}
zeArenaToPosition = Position(712, 1435, 7) --pos of bottom right corner {x = 767, y = 1435, z = 7}

local function ZE_Verifica()
    local tile = Tile(ZE.tpOpen)
    if tile then
        local item = tile:getItemById(1387)
        if item then
            item:remove()
            broadcastMessage("the Zombie Event will start now!", MESSAGE_STATUS_WARNING)
            doSummonCreature("Zumbi", ZE.posEnterEvent, false, true)
        else           
            broadcastMessage("The Zombie Event was opened in Spectro Vvs City and will be closed in ".. ZE.tpTimeOpen .." minutes.", MESSAGE_STATUS_WARNING)
            setGlobalStorageValue(ZE.storage, 0)
            
            local teleport = Game.createItem(1387, 1, ZE.tpOpen)
            if teleport then
                teleport:setActionId(45110)
            end
        end
    end
end

local function warnEvents(i)
    Game.broadcastMessage("The Zombie event end!")
    if i > 1 then
        addEvent(warnEvents, 2 * 60 * 1000, i - 1)
    end
end


--- TESTE
local function SumonarZumbis(b)

Game.createMonster("Zumbi", {x = math.random(zeArenaFromPosition.x, zeArenaToPosition.x), y = math.random(zeArenaFromPosition.y, zeArenaToPosition.y), z = math.random(zeArenaFromPosition.z, zeArenaToPosition.z)}, false, true)

if b > 1 then
        addEvent(SumonarZumbis, 1 * 60 * 1000, b - 1)
    end
end
-- TESTE

function onTime(interval)

    ZE_Verifica()
    addEvent(ZE_Verifica, ZE.tpTimeOpen * 60 * 1000)
    addEvent(warnEvents, 2 * 60 * 1000, 4)
    addEvent(SumonarZumbis, 10 * 60 * 1000, 16)
    return true
end
 
you have other lib:S
Look my lib
your script look is worng
Lua:
-- CONFIG
ZE_DEFAULT_NUMBER_OF_PLAYERS = 3
ZE_ACCESS_TO_IGNORE_ARENA = 1
-- POSITIONS
ZE_blockEnterItemPosition = {x= 997, y=1013, z=7}
ZE_enterPosition = {x = 997, y = 1013, z = 7}
ZE_kickPosition = {x=1000, y=1000, z=7}
ZE_spawnFromPosition = {x = 1678, y = 1691, z = 7}
ZE_spawnToPosition =  {x = 1721, y = 1731, z = 7}
-- ITEM IDS
ZE_blockEnterItemID = 1546
-- STORAGES
-- - player
ZE_isOnZombieArea = 34370
-- - global
ZE_STATUS = 34370 -- =< 0 - off, 1 - waiting for players, 2 - is running
ZE_PLAYERS_NUMBER = 34371
ZE_ZOMBIES_TO_SPAWN = 34372
ZE_ZOMBIES_SPAWNED = 34373

-- FUNCTION

function setZombiesEventPlayersLimit(value)
    doSetStorage(ZE_PLAYERS_NUMBER, value)
end

function getZombiesEventPlayersLimit()
    return getStorage(ZE_PLAYERS_NUMBER)
end

function addPlayerToZombiesArea(cid)
    doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
    doTeleportThing(cid, ZE_enterPosition, true)
    doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
    if(getPlayerAccess(cid) < ZE_ACCESS_TO_IGNORE_ARENA) then
        setPlayerZombiesEventStatus(cid, os.time())
    end
end

function kickPlayerFromZombiesArea(cid)
    doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
    doTeleportThing(cid, ZE_kickPosition, true)
    doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
    setPlayerZombiesEventStatus(cid, 0)
end

function getPlayerZombiesEventStatus(cid)
    return getCreatureStorage(cid, ZE_isOnZombieArea)
end

function setPlayerZombiesEventStatus(cid, value)
    doCreatureSetStorage(cid, ZE_isOnZombieArea, value)
end

function getZombiesEventPlayers()
    local players = {}
    for i, cid in pairs(getPlayersOnline()) do
        if(getPlayerZombiesEventStatus(cid) > 0) then
            table.insert(players, cid)
        end
    end
    return players
end

function getZombiesCount()
    return getStorage(ZE_ZOMBIES_SPAWNED)
end

function addZombiesCount()
    doSetStorage(ZE_ZOMBIES_SPAWNED, getStorage(ZE_ZOMBIES_SPAWNED)+1)
end

function resetZombiesCount()
    doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
end

function getZombiesToSpawnCount()
    return getStorage(ZE_ZOMBIES_TO_SPAWN)
end

function setZombiesToSpawnCount(count)
    doSetStorage(ZE_ZOMBIES_TO_SPAWN, count)
end

function addZombiesEventBlockEnterPosition()
    if(getTileItemById(ZE_blockEnterItemPosition, ZE_blockEnterItemID).uid == 0) then
        doCreateItem(ZE_blockEnterItemID, 1, ZE_blockEnterItemPosition)
    end
end

function removeZombiesEventBlockEnterPosition()
    local item = getTileItemById(ZE_blockEnterItemPosition, ZE_blockEnterItemID)
    if(item.uid ~= 0) then
        doRemoveItem(item.uid)
    end
end

function spawnNewZombie()
    local posx = {}
    local posy = {}
    local posz = {}
    local pir = {}
    for i=1, 5 do
        local posx_tmp = math.random(ZE_spawnFromPosition.x ,ZE_spawnToPosition.x)
        local posy_tmp = math.random(ZE_spawnFromPosition.y ,ZE_spawnToPosition.y)
        local posz_tmp = math.random(ZE_spawnFromPosition.z ,ZE_spawnToPosition.z)
        local pir_tmp = 0
        local spec = getSpectators({x=posx_tmp, y=posy_tmp, z=posz_tmp}, 3, 3, false)
        if(spec and #spec > 0) then
            for z, pid in pairs(spec) do
                if(isPlayer(pid)) then
                    pir_tmp = pir_tmp + 1
                end
            end
        end
        posx[i] = posx_tmp
        posy[i] = posy_tmp
        posz[i] = posz_tmp
        pir[i] = pir_tmp
    end
    local lowest_i = 1
    for i=2, 5 do
        if(pir[i] < pir[lowest_i]) then
            lowest_i = i
        end
    end
    local ret = (type(doCreateMonster("Zombie Event", {x=posx[lowest_i], y=posy[lowest_i], z=posz[lowest_i]}, false)) == 'number')
    if(ret) then
        addZombiesCount()
    end
    return ret
end
 

Attachments

Last edited:
Back
Top