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

*NEW* Zombie Event [TFS 1.x]

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,782
Solutions
31
Reaction score
2,286
Location
Sweden?
Hello,

well this is a update on my old Zombie event. Since the old one, was bit buggy and was bit messy.

xHhGcL9.png


Features:
  • Highly optimized, with no intense onThink events!
  • Min players/Max players/Max Zombies!
  • Zombie does not get summoned into walls!
  • Automatic Start through globalevent or command!
  • Join on teleport or command!
  • Zombie Count and Kill Count!
  • 3 Trophy rewards with description and date!
Add these lines into data/creaturescripts/creaturescripts.xml:
Code:
    <!-- Zombie Event -->
    <event type="preparedeath" name="ZombiePlayerDeath" script="player/zombieEventDeath.lua" />
    <event type="death" name="ZombieOnDeath" script="player/zombieEventDeath.lua" />

Now into data/creaturescripts/scripts and create new lua and name it "zombieEventDeath.lua" and paste:

Code:
function onDeath(monster, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    -- Send text and effect
    monster:say("I WILL BE BACK!", TALKTYPE_MONSTER_YELL)
    monster:getPosition():sendMagicEffect(CONST_ME_MORTAREA)

    -- Remove zombie count, when it dies
    Game.setStorageValue(ze_zombieCountGlobalStorage, getZombieEventZombieCount() - 1)

    -- Store player kills
    local killerId = killer:getId()
    if zombieKillCount[killerId] ~= nil then
        zombieKillCount[killerId] = zombieKillCount[killerId] + 1
    else
        zombieKillCount[killerId] = 1
    end

    return true
end

function onPrepareDeath(player, killer)
    -- Remove player from count
    local count = getZombieEventJoinedCount()
    Game.setStorageValue(ze_joinCountGlobalStorage, count - 1)

    -- Reset player after death
    player:teleportTo(player:getTown():getTemplePosition())
    player:setStorageValue(ze_joinStorage, 0)
    player:addHealth(player:getMaxHealth())
    player:addMana(player:getMaxMana())
    player:unregisterEvent("ZombiePlayerDeath")

    -- Let's reward the 3 last players
    if count <= 3 then
        local playerName =  player:getName()

        local trophy = ze_trophiesTable[count]
        local item = player:addItem(trophy.itemid, 1)
        if item then
            item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, string.format("%s %s\n%s.", playerName, trophy.description, os.date("%x")))
        end

        -- Store kill count and remove from table to avoid memory leak
        local playerId, killCount = player:getId(), 0
        if zombieKillCount[playerId] ~= nil then
            killCount = zombieKillCount[playerId]
            zombieKillCount[playerId] = nil
        end

        -- Broadcast
        Game.broadcastMessage(string.format("%d place goes to %s of Zombie Event versus %d Zombies and slained %d Zombies.", count, playerName, getZombieEventZombieCount(), killCount))

        -- The last player died, let's reset the event
        if count <= 1 then
            resetZombieEvent()
        end
    end

    return false
end

Paste these lines into data/movements/movements.xml:
Code:
    <!-- Zombie Event -->
    <movevent event="StepIn" actionid="7000" script="zombieEventTeleport.lua" />

Now in data/movements/scripts, create new lua and name it "zombieEventTeleport" and paste below:
Code:
function onStepIn(creature, item, position, fromPosition)

    local player = creature:getPlayer()

    if not player == nil then
        return true
    end

    -- If it's a staff memeber, just teleport inside and do not count as participant
    if player:getGroup():getAccess() then
        player:teleportTo(ze_WaitingRoomStartPosition)
        return true
    end

    -- If the event state is closed or started, then stop players from enter
    if isInArray({ze_EVENT_CLOSED, ze_EVENT_STARTED}, getZombieEventState()) then
        player:teleportTo(fromPosition, true)
        fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
        return true
    end

    -- Check if the event has already max players
    if getZombieEventJoinedCount() >= ze_maxPlayers then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "The Zombie Event is already full.")
        player:teleportTo(fromPosition, true)
        fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
        return true
    end

    -- Execute join event
    player:joinZombieEvent()
    return true
end

Paste this into data/talkactions/talkactions.xml:
Code:
<talkaction words="!zombie" separator=" " script="zombieEventCommands.lua" />

Now in data/talkactions/scripts, name it "zombieEventCommands" and paste this below:
Code:
function onSay(player, words, param)
    local split = param:split(",")

    if split[1] == "join" then
        -- If it's a staff member, just teleport inside and do not count as a participant
        if player:getGroup():getAccess() then
            player:teleportTo(ze_WaitingRoomStartPosition)
            return false
        end

        -- If the state of the event is closed or started, stop them from join
        if isInArray({ze_EVENT_CLOSED, ze_EVENT_STARTED}, getZombieEventState()) then
            return false
        end

        -- If player got pz, forbid them to join
        if player:isPzLocked() then
            player:sendCancelMessage("You cannot join while your in a fight.")
            return false
        end

        -- If there is max players joined, stop them from join
        if getZombieEventJoinedCount() >= ze_maxPlayers then
            player:sendCancelMessage("The event is already full.")
            return false
        end

        -- Execute join event
        player:joinZombieEvent()
    elseif split[1] == "start" then
        -- If not staff member, they stop them from setup a event
        if not player:getGroup():getAccess() then
            return false
        end

        local minPlayers = tonumber(split[2])
        local maxPlayers = tonumber(split[3])
        local waitTime = tonumber(split[4])

        local failStart = false
        if minPlayers == nil or minPlayers < 1 then
            failStart = true
        elseif maxPlayers == nil or maxPlayers > Game.getPlayerCount() then
            failStart = true
        elseif waitTime == nil or waitTime < 1 then
            failStart = true
        end

        if failStart then
            player:sendCancelMessage("!zombie start, [minPlayers, maxPlayers, waitTime].")
            return false
        end

        -- Set the new variables and setup the event
        setupZombieEvent(minPlayers, maxPlayers, waitTime)
    end

    return false
end

Now go to data/global.lua and paste this:
Code:
dofile('data/zombieEvent.lua')

Now create inside data folder a lua and name it "zombieEvent.lua" and paste this:
http://pastebin.com/frkjmi1v

Here is the monster file, make sure name it "Zombie Event.xml":
http://pastebin.com/3qMib0QG

Make sure add no-logout zone on the waiting room and also on the Zombie event arena.
 
Last edited:
Holy sh*t batman, time to update that legacy signature doncha think xD
Anyone got this up? I want to test for fun!
I cannot add more into my signature, there is max letters :p
Tested on 1.2

Does someone have interesting map to play zombie event on?
If someone have a map, i should link it to the thread and also configure the coordinates.
 
Sir @Printer, when is possible and you have time, please made firestorm or capture the frag.
I like your scrpts, thank you! :)
 
Sir @Printer, when is possible and you have time, please made firestorm or capture the frag.
I like your scrpts, thank you! :)
Sorry, but i have to also focus on my own server aswell.
 
Hello! I've been trying to use the !zombie start command and it doesnt start! im gona go crazy by now, i've tried all possible solutions, and nothing >.<! Any help please?

Solved.
 
Last edited:
I may even update it with optimizations to make it even faster then it is and also any suggestions. Maybe waves?
 
Well, im using your code and i find something missing. Like spawning diferent mobs, fixed time to end the event and kick all living players, waves would be nice aswell..! Great job man!
 
Hey printer, thanks for the script! But how can I start the event?

!zombie start 1, 10, 5 seems to be not working properly.. What I am doing wrong?
 
And can you show us how command !zombie start look?
I have tried !zombie start 1,10,10 and it's not working :c

Got it brow, after 30 minutes trying

Ex.: !zombie start,1,10,60

Max player number needs to be minor them (maxplayeronline)

as this line says:

Code:
elseif maxPlayers == nil or maxPlayers > Game.getPlayerCount() then
 
What's up Printer!

I have some problems with this event
First:
This appearing this error when I run the command to start the event
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/zombieEventCommands.lua:onSay
data/talkactions/scripts/zombieEventCommands.lua:32: attempt to index local 'player' (a number value) 
stack traceback:
[C]: in function '__index'
data/talkactions/scripts/zombieEventCommands.lua:32: in function

When i delete this:
Code:
        -- If not staff member, they stop them from setup a event
        if not player:getGroup():getAccess() then
            return false
        end

Then appears another error that is:
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/zombieEventCommands.lua:onSay
data/talkactions/scripts/zombieEventCommands.lua:47: attempt to index local 'player' (a number value)
stack traceback:
[C]: in function '__index'
data/talkactions/scripts/zombieEventCommands.lua:47: in function

Second:
I'm trying to put the event to start 3 times a day just by GlobalEvents however I am unable to create could help me? Because you do not have the script in your post

Thanks
 
Back
Top