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

AutoStart Zombie

Fabiaanzky

New Member
Joined
Nov 12, 2014
Messages
30
Reaction score
1
Location
Chile
OTLanders community,
I'm looking for a script for zombie event, TFS 0.4
to automatically start a day x and hour x.

I have one but I need to improve it, so when no player enters the event, send a message that did not start due to lack of players in the event.
Somebody could help me?

Lua:
local autoStartsTable = {
{["day_of_week"] = 0, ["hour"] = 1, ["minute"] = 6, ["storage"] = 7867},
{["day_of_week"] = 0, ["hour"] = 21, ["minute"] = 0, ["storage"] = 7868},
{["day_of_week"] = 1, ["hour"] = 16, ["minute"] = 30, ["storage"] = 7869},
}

function shouldExecuteEvent(configTable)
    for _, config in pairs(configTable) do
        if(tonumber(os.date("%d")) ~= getStorage(config.storage) and tonumber(os.date("%w")) == config.day_of_week) then
            if(tonumber(os.date("%H")) == config.hour and tonumber(os.date("%M")) == config.minute) then
                doSetStorage(config.storage, tonumber(os.date("%d")))
                return true
            end
        end
    end
    return false
end

function onThink(interval, lastExecution, thinkInterval)
    if(shouldExecuteEvent(autoStartsTable)) then
        if(getStorage(ZE_STATUS) ~= 1 and getStorage(ZE_STATUS) ~= 2) then
            removeZombiesEventBlockEnterPosition()
            doSetStorage(ZE_STATUS, 1)
            doBroadcastMessage("Zombie Arena Event teleport will be open for 2 minutes. We are waiting for " .. getZombiesEventPlayersLimit() - #getZombiesEventPlayers() .. " players to start.")
            addEvent(startArenaEvent, 120 * 1000)
        end
    end
    return true
end

function startArenaEvent()
    if(getStorage(ZE_STATUS) == 1) then
        addZombiesEventBlockEnterPosition()
        doSetStorage(ZE_STATUS, 2)
        doBroadcastMessage("Zombie Arena Event started.")
    end
end

This code works perfectly for those who need it, but I need that since there are no players in the event it does not start and does not generate zombies.
 
Post the whole script and I will add a broadcast when not enough players have entered the event.
 
Post the whole script and I will add a broadcast when not enough players have entered the event.

That is the autostart script. What script do you need? Because there are many.

this is the "onthink" / globalevents
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

this is the "onstartup" / globalevents
Lua:
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
 
Back
Top