• 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 [MOD] Zombies Event w/ Rounds & Killing Quest & Killing Portal

Tachi

New Member
Joined
Aug 4, 2007
Messages
376
Reaction score
2
Location
USA, Missouri
[MOD] Zombies Event w/ Rounds & Killing Quest & Killing Portal

OKk as the title states i am working on trying to get my scripts less cluttered, and i was wondering how i could go about my script iv crafted (PLEASE NOTE: i did copy paste alot of core functionality from mulitple other zombie events, although i recodded and moved things around to work, so i guess i cannot talk 100% credit, but i did do some of the coding....) without so much coding. I figure a lot of it can be done with loops or something of the like, i am just not sure how to do it. Also i was having problems creating a separate onKill function either in a separate mod or in creature-scripts so i made a three in one mod.

One question i have is, does anyone know why i couldn't get my second onKill function working properly, im usng TFS 0.3.7 Crying Damson.?

Another thing i want to add but not sure how, is that when a player die's, or is at like 1 hp, he will get sent to temple(exit pos) and receive full hp and mana.

Also, maybe instead of 2-3 round with same level creature, each round the monster get harder, so i guess with a counter after the zombie name, to get different zombies spawning or w/e.

Well here is my script, anyone got any ideas?...

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Zombie" version="2.0" author="Gansir" enabled="yes">
<config name="ZombieConfig"><=!=[=C=D=A=T=A=[
config = {
    beginPos = {x = 1557, y = 1390, z = 7},
    temple = {x = 1307, y = 1377, z = 6},
    zombieCount = 2002, -- Global storage for counting the zombies in the event
    counts = 2004, -- Global storage for counting the zombies in the event
    zombieCounter = 2003, -- Global storage for counting the killed zombies in the event
    inGamecheck = 15000, -- Global storage for counting the players
    rounds = 2001,  -- Global storage for counting the rounds
    goblet = 18422, -- id of the gold goblet you'll get when finishing the event.
    --        {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
    moneyReward = {2160, 10, 1},
    passageKey = "start", -- Talkaction to start Zombies event
    countKey = "count", -- Talkaction to start Zombies event
    startNow = "instastart", -- Talkaction to insta start Zombies event
    zombieName = "event zombie", -- Name of the zombie that should be summoned
    zombieName2 = "event zombie2", -- Name of the zombie that should be summoned
    zombieName3 = "event zombie3", -- Name of the zombie that should be summoned
    fromPos = {x = 1274, y = 1351, z = 6}, -- Waiting Room
    toPos = {x = 1281, y = 1353, z = 6}, -- Waiting Room
    areaFromPos = {x = 1536, y = 1377, z = 7}, -- Arena
    areaToPos = {x = 1574, y = 1396, z = 7},       -- Arena
    message = "You killed a Zombie",
    bosses = { -- Monster Name, Teleport To Position, Teleport Position, UID
        ["event zombie"] = { Storage = 2003 },
    },
}


monsters = {
    --name = storage
    ["troll"] = 55004,
    ["ghoul"] = 55005,
    ["orc"] = 55006,
    ["orc beserker"] = 55006,
    ["orc leader"] = 55006,
    ["orc spearsman"] = 55006,
    ["orc warlord"] = 55006,
    ["orc warrior"] = 55006,
    ["orc rider"] = 55006,
    ["orc shaman"] = 55006,
    ["minotaur"] = 55007,
    ["minotaur mage"] = 55007,
    ["minotaur archer"] = 55007,
    ["minotaur guard"] = 55007,
    ["dwarf"] = 55008,
    ["dwarf soldier"] = 55008,
    ["dwarf guard"] = 55008,
    ["dwarf geomancer"] = 55008,
    ["dragon"] = 55010,
    ["dragon lord"] = 55010,
    ["dragon hatchling"] = 55010,
    ["dragon lord hatchling"] = 55010,
}


inqconf = {
    message = "Go into the teleporter with-in 1 minute, else it will disappear.",
    timeToRemove = 30, -- seconds
    teleportId = 1387,
    MonStor = 48000,
    monboss = { -- Monster Name, Teleport To Position, Teleport Position, UID
        ["igor the recruiter"] = { ptp={ x=1305, y=1377, z=6}, pp={ x=1470, y=1450, z=8, stackpos=1 }, uid=49100 },
    }
}
]=]=></config>


    <lib name="Zombielib"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        
        function zombieSpawn()
            if getGlobalStorageValue(config.rounds) <= 2 then
                if getGlobalStorageValue(config.zombieCount) <= 9 then
                    pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
                    doSummonCreature(config.zombieName, pos)
                    doSendMagicEffect(pos, CONST_ME_MORTAREA)
                    setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
                    setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
                else
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    if getGlobalStorageValue(config.zombieCounter) == 0 then
                                        if getGlobalStorageValue(config.rounds) == 0 then
                                            doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed the first wave of zombies. Good Job Man! The next Wave is about to begin!")
                                            setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                            setGlobalStorageValue(config.zombieCount, 0)
                                        elseif getGlobalStorageValue(config.rounds) <= 3 then
                                            doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! The next Wave is about to begin!")
                                            setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                            setGlobalStorageValue(config.zombieCount, 0)
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
                addEvent(zombieSpawn, 1 * 1000)
            elseif getGlobalStorageValue(config.rounds) <= 5 and getGlobalStorageValue(config.rounds) >= 3 then
                if getGlobalStorageValue(config.zombieCount) <= 9 then
                    pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
                    doSummonCreature(config.zombieName2, pos)
                    doSendMagicEffect(pos, CONST_ME_MORTAREA)
                    setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
                    setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
                else
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    if getGlobalStorageValue(config.zombieCounter) == 0 then
                                        if getGlobalStorageValue(config.rounds) <= 5 then
                                            doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! The next Wave is about to begin!")
                                            setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                            setGlobalStorageValue(config.zombieCount, 0)
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
                addEvent(zombieSpawn, 1 * 1000)
            elseif getGlobalStorageValue(config.rounds) <= 9 and getGlobalStorageValue(config.rounds) >= 6 then
                if getGlobalStorageValue(config.zombieCount) <= 9 then
                    pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
                    doSummonCreature(config.zombieName3, pos)
                    doSendMagicEffect(pos, CONST_ME_MORTAREA)
                    setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
                    setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
                else
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    if getGlobalStorageValue(config.zombieCounter) == 0 then
                                        if getGlobalStorageValue(config.rounds) <= 5 then
                                            doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! The next Wave is about to begin!")
                                            setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)    
                                            setGlobalStorageValue(config.zombieCount, 0)
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
                addEvent(zombieSpawn, 1 * 1000)
            else
                addEvent(endingEvent, 1 * 1000)
            end
        return true
        end
        
        function startEvent()
            for _, cid in ipairs(getPlayersOnline()) do
                if isInRange(getThingPos(cid), config.fromPos, config.toPos) then
                    doTeleportThing(cid, config.beginPos, true)
                    doPlayerSetStorageValue(cid, config.inGamecheck, 1)
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "The First round is about to begin!")
                                    addEvent(zombieSpawn, 1000)
                                    zombieSpawn()
                                end
                            end
                        end
                    end
                else
                    doBroadcastMessage(" The Zombies event has been canceled due to the lack of players.", MESSAGE_STATUS_WARNING)
                end
            end
            return true
        end


        function broadcasting()
            setGlobalStorageValue(config.NumZombieEvents, getGlobalStorageValue(config.NumZombieEvents)+1)
            addEvent(doBroadcastMessage, 1000, "Zombies will begin in 5 minutes.")
            addEvent(doBroadcastMessage, 120 * 1000, "Zombies will begin in 3 minutes.")
            addEvent(doBroadcastMessage, 240 * 1000, "Zombies will begin in 1 minute. Hurry up to the Mini-Game Waiting Room!")
            addEvent(doBroadcastMessage, 299 * 1000, "Zombie Event has started.")
            addEvent(startEvent, 300 * 1000)
            return true
        end


        function endingEvent()
            for _, cid in ipairs(getPlayersOnline()) do
                if isInRange(getThingPos(cid), config.areaFromPos, config.areaToPos) then
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just survived " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! That was the last wave!")
                                end
                            end
                        end
                    end
                    setGlobalStorageValue(config.rounds, 0)
                    setGlobalStorageValue(config.zombieCount, 0)
                    setGlobalStorageValue(config.zombieCounter, 0)
                    doPlayerSetStorageValue(cid, config.inGamecheck, 0)
                    addEventPoints(cid, 10)
                    doBroadcastMessage("The Zombies have been slayed! Congratz, thoes who lived won: 1 Event Tokens & 10 Event Points. Thoes who died earned 5 Event Points.", MESSAGE_STATUS_WARNING)
                    local goblet = doPlayerAddItem(cid, config.goblet, 1)
                    doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for surviving the Zombie event.")
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                    doTeleportThing(cid, config.temple, false)
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
                    for _,items in ipairs(config.moneyReward) do
                        if config.moneyReward[3] == 1 then
                            doPlayerAddItem(cid, config.moneyReward[1], config.moneyReward[2])
                        end
                    end
                end
                setGlobalStorageValue(config.zombieCount, 0)
            end
            return true
        end
    ]=]=></lib>
    <event type="kill" name="Zombies" event="script"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        domodlib('Zombielib')
        function onKill(cid, target)
            local name = getCreatureName(target):lower()
            local monster = monsters[getCreatureName(target):lower()]
            local t = inqconf.monboss[getCreatureName(target):lower()]
            if isInRange(getThingPos(cid), {x = 1536, y = 1377, z = 7}, {x = 1574, y = 1396, z = 7}) then
                setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)-1)
                if getGlobalStorageValue(config.zombieCounter) == 0 then
                    doCreatureSay(cid, "There are no Zombie Left. Please wait for the next round.", TALKTYPE_ORANGE_1)
                elseif getGlobalStorageValue(config.zombieCounter) == 1 then
                    doCreatureSay(cid, "There is "..getGlobalStorageValue(config.zombieCounter).. " Zombie Left.", TALKTYPE_ORANGE_1)
                else
                    doCreatureSay(cid, "There are "..getGlobalStorageValue(config.zombieCounter).. " Zombies Left.", TALKTYPE_ORANGE_1)
                end
            elseif (name == "troll" and getPlayerStorageValue(cid, 76669) == 2) then
                if getPlayerStorageValue(cid, monster) < 60 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 60 Trolls.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 60 trolls.")
                    setPlayerStorageValue(cid, 76669, 3)
                end
            elseif (name == "ghoul" and getPlayerStorageValue(cid, 76669) == 5) then
                if getPlayerStorageValue(cid, monster) < 100 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 100 Ghouls.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 100 ghouls.")
                    setPlayerStorageValue(cid, 76669, 6)
                end
            elseif ((name == "orc" or name == "orc beserker" or name == "orc leader" or name == "orc spearsman" or name == "orc warlord" or name == "orc warrior" or name == "orc rider" or name == "orc shaman") and getPlayerStorageValue(cid, 76669) == 8) then
                if getPlayerStorageValue(cid, monster) < 150 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 150 Orcs.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 150 orcs.")
                    setPlayerStorageValue(cid, 76669, 9)
                end
            elseif ((name == "minotaur" or name == "minotaur archer" or name == "minotaur guard" or name == "minotaur mage") and getPlayerStorageValue(cid, 76669) == 11) then
                if getPlayerStorageValue(cid, monster) < 200 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 200 minotaurs.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 200 minotaurs.")
                    setPlayerStorageValue(cid, 76669, 12)
                end
            elseif ((name == "dwarf" or name == "dwarf soldier" or name == "dwarf guard" or name == "dwarf geomancer") and getPlayerStorageValue(cid, 76669) == 14) then
                if getPlayerStorageValue(cid, monster) < 300 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 300 Dwarfs.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 300 dwarfs.")
                    setPlayerStorageValue(cid, 76669, 15)
                end
                elseif ((name == "dragon" or name == "dragon lord" or name == "dragon hatchling" or name == "dragon lord hatchling") and getPlayerStorageValue(cid, 76669) == 17) then
                if getPlayerStorageValue(cid, monster) < 500 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 500 Dragons.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 500 dragons.")
                    setPlayerStorageValue(cid, 76669, 18)
                end
            elseif(name == "igor the recruiter" and getPlayerStorageValue(cid, 76670) == 7) then
                local teleport = doCreateTeleport(inqconf.teleportId, t.ptp, t.pp)
                doItemSetAttribute(teleport, "uid", t.uid)
                doCreatureSay(cid, inqconf.message, TALKTYPE_ORANGE_1)
                setPlayerStorageValue(cid, 76670, 8)
                addEvent(removeTeleport, 60 * 1000)
            end
        return true
        end
        function removeTeleport()
            local teleport = getTileItemById({x=1470, y=1450, z=8, stackpos=1}, 1387)
            if teleport.uid > 0 then
                doRemoveItem(teleport.uid)
            end
        end
        
    ]=]=></event>


    <event type="login" name="Zombielog" event="script"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        domodlib('Zombielib')
        function onLogin(cid)
            registerCreatureEvent(cid, "Zombies")
            registerCreatureEvent(cid, "ZombieGlobal")
            registerCreatureEvent(cid, "ZombieGlobal2")
        return true
        end
    ]=]=></event>
    
    <talkaction log="yes" words="/zombies" access="5" event ="script"><=!=[=C=D=A=T=A=[
        domodlib("ZombieConfig")
        domodlib('Zombielib')
        function onSay(cid, words, param)
            if(string.lower(param) == string.lower(config.passageKey)) then
                doPlayerSendCancel(cid, "You have selected to start the Zombie Event!.")
                setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
                setGlobalStorageValue(config.zombieCount, 0)
                setGlobalStorageValue(config.zombieCounter, 0)
                setGlobalStorageValue(config.rounds, 0)
                setGlobalStorageValue(config.NumZombieEvents, 0)
                broadcasting()
            elseif(string.lower(param) == string.lower(config.countKey)) then
                if getGlobalStorageValue(config.counts)+1 == 0 then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The Zombies Event has not been ran yet.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The Zombies Event has been ran: "..(getGlobalStorageValue(config.counts)+1).." times.")
                end
            elseif(string.lower(param) == string.lower(config.startNow)) then
                doPlayerSendCancel(cid, "You have selected to start the Zombie Event RIGHT NOW!.")
                setGlobalStorageValue(config.zombieCount, 0)
                setGlobalStorageValue(config.zombieCounter, 0)
                setGlobalStorageValue(config.rounds, 0)
                setGlobalStorageValue(config.NumZombieEvents, 0)
                setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
                startEvent()
            else
                doPlayerSendCancel(cid, "You must say the correct word to start the Zombie Event!.")
            end
        return true
        end
    ]=]=></talkaction>


    <globalevent name="ZombieGlobal" time="17:55" event="script"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        domodlib('Zombielib')
        function onTime(time)
            setGlobalStorageValue(config.zombieCount, 0)
            setGlobalStorageValue(config.zombieCounter, 0)
            setGlobalStorageValue(config.rounds, 0)
            setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
            addEvent(broadcasting, 1 * 1000)
        end
    ]=]=></globalevent>


    <globalevent name="ZombieGlobal2" time="07:55" event="script"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        domodlib('Zombielib')
        function onTime(time)
            setGlobalStorageValue(config.zombieCount, 0)
            setGlobalStorageValue(config.zombieCounter, 0)
            setGlobalStorageValue(config.rounds, 0)
            setGlobalStorageValue(config.NumZombieEvents, 0)
            setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
            addEvent(broadcasting, 1 * 1000)
        end
    ]=]=></globalevent>


</mod>



- - - Updated - - -

BUMP, Still wanting to optimize this code...
 
Last edited:
Bump... -.- Still wanting to compress this script down, make it to where each round the monsters r stronger, not every 2-3 rounds.. and i want it to when u die you get temple tp'ed with full hp/mana.. cant anyone help?...

I figure it'd have something to do with a for loop.. but im not sure exactly how to implament it, ect
 
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Zombie" version="2.0" author="Gansir" enabled="yes">
<config name="ZombieConfig"><=!=[=C=D=A=T=A=[
config = {
    local manamax = getPlayerMaxMana(cid),
    local healthmax = getPlayerMaxHealth(cid),
    beginPos = {x = 1557, y = 1390, z = 7},
    temple = {x = 1307, y = 1377, z = 6},
    zombieCount = 2002, -- Global storage for counting the zombies in the event
    counts = 2004, -- Global storage for counting the zombies in the event
    zombieCounter = 2003, -- Global storage for counting the killed zombies in the event
    inGamecheck = 15000, -- Global storage for counting the players
    rounds = 2001,  -- Global storage for counting the rounds
    goblet = 18422, -- id of the gold goblet you'll get when finishing the event.
    --        {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
    moneyReward = {2160, 10, 1},
    passageKey = "start", -- Talkaction to start Zombies event
    countKey = "count", -- Talkaction to start Zombies event
    startNow = "instastart", -- Talkaction to insta start Zombies event
    zombieName = "event zombie", -- Name of the zombie that should be summoned
    zombieName2 = "event zombie2", -- Name of the zombie that should be summoned
    zombieName3 = "event zombie3", -- Name of the zombie that should be summoned
    fromPos = {x = 1274, y = 1351, z = 6}, -- Waiting Room
    toPos = {x = 1281, y = 1353, z = 6}, -- Waiting Room
    areaFromPos = {x = 1536, y = 1377, z = 7}, -- Arena
    areaToPos = {x = 1574, y = 1396, z = 7},       -- Arena
    message = "You killed a Zombie",
    bosses = { -- Monster Name, Teleport To Position, Teleport Position, UID
        ["event zombie"] = { Storage = 2003 },
    },
}


monsters = {
    --name = storage
    ["troll"] = 55004,
    ["ghoul"] = 55005,
    ["orc"] = 55006,
    ["orc beserker"] = 55006,
    ["orc leader"] = 55006,
    ["orc spearsman"] = 55006,
    ["orc warlord"] = 55006,
    ["orc warrior"] = 55006,
    ["orc rider"] = 55006,
    ["orc shaman"] = 55006,
    ["minotaur"] = 55007,
    ["minotaur mage"] = 55007,
    ["minotaur archer"] = 55007,
    ["minotaur guard"] = 55007,
    ["dwarf"] = 55008,
    ["dwarf soldier"] = 55008,
    ["dwarf guard"] = 55008,
    ["dwarf geomancer"] = 55008,
    ["dragon"] = 55010,
    ["dragon lord"] = 55010,
    ["dragon hatchling"] = 55010,
    ["dragon lord hatchling"] = 55010,
}


inqconf = {
    message = "Go into the teleporter with-in 1 minute, else it will disappear.",
    timeToRemove = 30, -- seconds
    teleportId = 1387,
    MonStor = 48000,
    monboss = { -- Monster Name, Teleport To Position, Teleport Position, UID
        ["igor the recruiter"] = { ptp={ x=1305, y=1377, z=6}, pp={ x=1470, y=1450, z=8, stackpos=1 }, uid=49100 },
    }
}
]=]=></config>


    <lib name="Zombielib"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        
        function zombieSpawn()
            if getGlobalStorageValue(config.rounds) <= 2 then
                if getGlobalStorageValue(config.zombieCount) <= 9 then
                    pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
                    doSummonCreature(config.zombieName, pos)
                    doSendMagicEffect(pos, CONST_ME_MORTAREA)
                    setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
                    setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
                else
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    if getGlobalStorageValue(config.zombieCounter) == 0 then
                                        if getGlobalStorageValue(config.rounds) == 0 then
                                            doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed the first wave of zombies. Good Job Man! The next Wave is about to begin!")
                                            setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                            setGlobalStorageValue(config.zombieCount, 0)
                                        elseif getGlobalStorageValue(config.rounds) <= 3 then
                                            doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! The next Wave is about to begin!")
                                            setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                            setGlobalStorageValue(config.zombieCount, 0)
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
                addEvent(zombieSpawn, 1 * 1000)
            elseif getGlobalStorageValue(config.rounds) <= 5 and getGlobalStorageValue(config.rounds) >= 1 then
                if getGlobalStorageValue(config.zombieCount) <= 9 then
                    pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
                    doSummonCreature(config.zombieName2, pos)
                    doSendMagicEffect(pos, CONST_ME_MORTAREA)
                    setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
                    setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
                else
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    if getGlobalStorageValue(config.zombieCounter) == 0 then
                                        if getGlobalStorageValue(config.rounds) <= 5 then
                                            doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! The next Wave is about to begin!")
                                            setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                            setGlobalStorageValue(config.zombieCount, 0)
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
                addEvent(zombieSpawn, 1 * 1000)
            elseif getGlobalStorageValue(config.rounds) <= 9 and getGlobalStorageValue(config.rounds) >= 6 then
                if getGlobalStorageValue(config.zombieCount) <= 9 then
                    pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
                    doSummonCreature(config.zombieName3, pos)
                    doSendMagicEffect(pos, CONST_ME_MORTAREA)
                    setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
                    setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
                else
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    if getGlobalStorageValue(config.zombieCounter) == 0 then
                                        if getGlobalStorageValue(config.rounds) <= 5 then
                                            doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! The next Wave is about to begin!")
                                            setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)    
                                            setGlobalStorageValue(config.zombieCount, 0)
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
                addEvent(zombieSpawn, 1 * 1000)
            else
                addEvent(endingEvent, 1 * 1000)
            end
        return true
        end
        
        function startEvent()
            for _, cid in ipairs(getPlayersOnline()) do
                if isInRange(getThingPos(cid), config.fromPos, config.toPos) then
                    doTeleportThing(cid, config.beginPos, true)
                    doPlayerSetStorageValue(cid, config.inGamecheck, 1)
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "The First round is about to begin!")
                                    addEvent(zombieSpawn, 1000)
                                    zombieSpawn()
                                end
                            end
                        end
                    end
                else
                    doBroadcastMessage(" The Zombies event has been canceled due to the lack of players.", MESSAGE_STATUS_WARNING)
                end
            end
            return true
        end


        function broadcasting()
            setGlobalStorageValue(config.NumZombieEvents, getGlobalStorageValue(config.NumZombieEvents)+1)
            addEvent(doBroadcastMessage, 1000, "Zombies will begin in 5 minutes.")
            addEvent(doBroadcastMessage, 120 * 1000, "Zombies will begin in 3 minutes.")
            addEvent(doBroadcastMessage, 240 * 1000, "Zombies will begin in 1 minute. Hurry up to the Mini-Game Waiting Room!")
            addEvent(doBroadcastMessage, 299 * 1000, "Zombie Event has started.")
            addEvent(startEvent, 300 * 1000)
            return true
        end


        function endingEvent()
            for _, cid in ipairs(getPlayersOnline()) do
                if isInRange(getThingPos(cid), config.areaFromPos, config.areaToPos) then
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just survived " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! That was the last wave!")
                                end
                            end
                        end
                    end
                    setGlobalStorageValue(config.rounds, 0)
                    setGlobalStorageValue(config.zombieCount, 0)
                    setGlobalStorageValue(config.zombieCounter, 0)
                    doPlayerSetStorageValue(cid, config.inGamecheck, 0)
                    addEventPoints(cid, 10)
                    doBroadcastMessage("The Zombies have been slayed! Congratz, thoes who lived won: 1 Event Tokens & 10 Event Points. Thoes who died earned 5 Event Points.", MESSAGE_STATUS_WARNING)
                    local goblet = doPlayerAddItem(cid, config.goblet, 1)
                    doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for surviving the Zombie event.")
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                    doTeleportThing(cid, config.temple, false)
	    doPlayerAddMana(cid, manamax)
	    doCreatureAddHealth(cid, healthmax)
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
                    for _,items in ipairs(config.moneyReward) do
                        if config.moneyReward[3] == 1 then
                            doPlayerAddItem(cid, config.moneyReward[1], config.moneyReward[2])
                        end
                    end
                end
                setGlobalStorageValue(config.zombieCount, 0)
            end
            return true
        end
    ]=]=></lib>
    <event type="kill" name="Zombies" event="script"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        domodlib('Zombielib')
        function onKill(cid, target)
            local name = getCreatureName(target):lower()
            local monster = monsters[getCreatureName(target):lower()]
            local t = inqconf.monboss[getCreatureName(target):lower()]
            if isInRange(getThingPos(cid), {x = 1536, y = 1377, z = 7}, {x = 1574, y = 1396, z = 7}) then
                setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)-1)
                if getGlobalStorageValue(config.zombieCounter) == 0 then
                    doCreatureSay(cid, "There are no Zombie Left. Please wait for the next round.", TALKTYPE_ORANGE_1)
                elseif getGlobalStorageValue(config.zombieCounter) == 1 then
                    doCreatureSay(cid, "There is "..getGlobalStorageValue(config.zombieCounter).. " Zombie Left.", TALKTYPE_ORANGE_1)
                else
                    doCreatureSay(cid, "There are "..getGlobalStorageValue(config.zombieCounter).. " Zombies Left.", TALKTYPE_ORANGE_1)
                end
            elseif (name == "troll" and getPlayerStorageValue(cid, 76669) == 2) then
                if getPlayerStorageValue(cid, monster) < 60 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 60 Trolls.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 60 trolls.")
                    setPlayerStorageValue(cid, 76669, 3)
                end
            elseif (name == "ghoul" and getPlayerStorageValue(cid, 76669) == 5) then
                if getPlayerStorageValue(cid, monster) < 100 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 100 Ghouls.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 100 ghouls.")
                    setPlayerStorageValue(cid, 76669, 6)
                end
            elseif ((name == "orc" or name == "orc beserker" or name == "orc leader" or name == "orc spearsman" or name == "orc warlord" or name == "orc warrior" or name == "orc rider" or name == "orc shaman") and getPlayerStorageValue(cid, 76669) == 8) then
                if getPlayerStorageValue(cid, monster) < 150 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 150 Orcs.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 150 orcs.")
                    setPlayerStorageValue(cid, 76669, 9)
                end
            elseif ((name == "minotaur" or name == "minotaur archer" or name == "minotaur guard" or name == "minotaur mage") and getPlayerStorageValue(cid, 76669) == 11) then
                if getPlayerStorageValue(cid, monster) < 200 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 200 minotaurs.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 200 minotaurs.")
                    setPlayerStorageValue(cid, 76669, 12)
                end
            elseif ((name == "dwarf" or name == "dwarf soldier" or name == "dwarf guard" or name == "dwarf geomancer") and getPlayerStorageValue(cid, 76669) == 14) then
                if getPlayerStorageValue(cid, monster) < 300 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 300 Dwarfs.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 300 dwarfs.")
                    setPlayerStorageValue(cid, 76669, 15)
                end
                elseif ((name == "dragon" or name == "dragon lord" or name == "dragon hatchling" or name == "dragon lord hatchling") and getPlayerStorageValue(cid, 76669) == 17) then
                if getPlayerStorageValue(cid, monster) < 500 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 500 Dragons.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 500 dragons.")
                    setPlayerStorageValue(cid, 76669, 18)
                end
            elseif(name == "igor the recruiter" and getPlayerStorageValue(cid, 76670) == 7) then
                local teleport = doCreateTeleport(inqconf.teleportId, t.ptp, t.pp)
                doItemSetAttribute(teleport, "uid", t.uid)
                doCreatureSay(cid, inqconf.message, TALKTYPE_ORANGE_1)
                setPlayerStorageValue(cid, 76670, 8)
                addEvent(removeTeleport, 60 * 1000)
            end
        return true
        end
        function removeTeleport()
            local teleport = getTileItemById({x=1470, y=1450, z=8, stackpos=1}, 1387)
            if teleport.uid > 0 then
                doRemoveItem(teleport.uid)
            end
        end
        
    ]=]=></event>


    <event type="login" name="Zombielog" event="script"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        domodlib('Zombielib')
        function onLogin(cid)
            registerCreatureEvent(cid, "Zombies")
            registerCreatureEvent(cid, "ZombieGlobal")
            registerCreatureEvent(cid, "ZombieGlobal2")
        return true
        end
    ]=]=></event>
    
    <talkaction log="yes" words="/zombies" access="5" event ="script"><=!=[=C=D=A=T=A=[
        domodlib("ZombieConfig")
        domodlib('Zombielib')
        function onSay(cid, words, param)
            if(string.lower(param) == string.lower(config.passageKey)) then
                doPlayerSendCancel(cid, "You have selected to start the Zombie Event!.")
                setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
                setGlobalStorageValue(config.zombieCount, 0)
                setGlobalStorageValue(config.zombieCounter, 0)
                setGlobalStorageValue(config.rounds, 0)
                setGlobalStorageValue(config.NumZombieEvents, 0)
                broadcasting()
            elseif(string.lower(param) == string.lower(config.countKey)) then
                if getGlobalStorageValue(config.counts)+1 == 0 then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The Zombies Event has not been ran yet.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The Zombies Event has been ran: "..(getGlobalStorageValue(config.counts)+1).." times.")
                end
            elseif(string.lower(param) == string.lower(config.startNow)) then
                doPlayerSendCancel(cid, "You have selected to start the Zombie Event RIGHT NOW!.")
                setGlobalStorageValue(config.zombieCount, 0)
                setGlobalStorageValue(config.zombieCounter, 0)
                setGlobalStorageValue(config.rounds, 0)
                setGlobalStorageValue(config.NumZombieEvents, 0)
                setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
                startEvent()
            else
                doPlayerSendCancel(cid, "You must say the correct word to start the Zombie Event!.")
            end
        return true
        end
    ]=]=></talkaction>


    <globalevent name="ZombieGlobal" time="17:55" event="script"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        domodlib('Zombielib')
        function onTime(time)
            setGlobalStorageValue(config.zombieCount, 0)
            setGlobalStorageValue(config.zombieCounter, 0)
            setGlobalStorageValue(config.rounds, 0)
            setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
            addEvent(broadcasting, 1 * 1000)
        end
    ]=]=></globalevent>


    <globalevent name="ZombieGlobal2" time="07:55" event="script"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        domodlib('Zombielib')
        function onTime(time)
            setGlobalStorageValue(config.zombieCount, 0)
            setGlobalStorageValue(config.zombieCounter, 0)
            setGlobalStorageValue(config.rounds, 0)
            setGlobalStorageValue(config.NumZombieEvents, 0)
            setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
            addEvent(broadcasting, 1 * 1000)
        end
    ]=]=></globalevent>


</mod>
give that a try. changed so they get harder after every wave and added so it adds full mana/hp
 
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Zombie" version="2.0" author="Gansir" enabled="yes">
<config name="ZombieConfig"><=!=[=C=D=A=T=A=[
config = {
    local manamax = getPlayerMaxMana(cid),
    local healthmax = getPlayerMaxHealth(cid),
    beginPos = {x = 1557, y = 1390, z = 7},
    temple = {x = 1307, y = 1377, z = 6},
    zombieCount = 2002, -- Global storage for counting the zombies in the event
    counts = 2004, -- Global storage for counting the zombies in the event
    zombieCounter = 2003, -- Global storage for counting the killed zombies in the event
    inGamecheck = 15000, -- Global storage for counting the players
    rounds = 2001,  -- Global storage for counting the rounds
    goblet = 18422, -- id of the gold goblet you'll get when finishing the event.
    --        {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
    moneyReward = {2160, 10, 1},
    passageKey = "start", -- Talkaction to start Zombies event
    countKey = "count", -- Talkaction to start Zombies event
    startNow = "instastart", -- Talkaction to insta start Zombies event
    zombieName = "event zombie", -- Name of the zombie that should be summoned
    zombieName2 = "event zombie2", -- Name of the zombie that should be summoned
    zombieName3 = "event zombie3", -- Name of the zombie that should be summoned
    fromPos = {x = 1274, y = 1351, z = 6}, -- Waiting Room
    toPos = {x = 1281, y = 1353, z = 6}, -- Waiting Room
    areaFromPos = {x = 1536, y = 1377, z = 7}, -- Arena
    areaToPos = {x = 1574, y = 1396, z = 7},       -- Arena
    message = "You killed a Zombie",
    bosses = { -- Monster Name, Teleport To Position, Teleport Position, UID
        ["event zombie"] = { Storage = 2003 },
    },
}


monsters = {
    --name = storage
    ["troll"] = 55004,
    ["ghoul"] = 55005,
    ["orc"] = 55006,
    ["orc beserker"] = 55006,
    ["orc leader"] = 55006,
    ["orc spearsman"] = 55006,
    ["orc warlord"] = 55006,
    ["orc warrior"] = 55006,
    ["orc rider"] = 55006,
    ["orc shaman"] = 55006,
    ["minotaur"] = 55007,
    ["minotaur mage"] = 55007,
    ["minotaur archer"] = 55007,
    ["minotaur guard"] = 55007,
    ["dwarf"] = 55008,
    ["dwarf soldier"] = 55008,
    ["dwarf guard"] = 55008,
    ["dwarf geomancer"] = 55008,
    ["dragon"] = 55010,
    ["dragon lord"] = 55010,
    ["dragon hatchling"] = 55010,
    ["dragon lord hatchling"] = 55010,
}


inqconf = {
    message = "Go into the teleporter with-in 1 minute, else it will disappear.",
    timeToRemove = 30, -- seconds
    teleportId = 1387,
    MonStor = 48000,
    monboss = { -- Monster Name, Teleport To Position, Teleport Position, UID
        ["igor the recruiter"] = { ptp={ x=1305, y=1377, z=6}, pp={ x=1470, y=1450, z=8, stackpos=1 }, uid=49100 },
    }
}
]=]=></config>


    <lib name="Zombielib"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        
        function zombieSpawn()
            if getGlobalStorageValue(config.rounds) <= 2 then
                if getGlobalStorageValue(config.zombieCount) <= 9 then
                    pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
                    doSummonCreature(config.zombieName, pos)
                    doSendMagicEffect(pos, CONST_ME_MORTAREA)
                    setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
                    setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
                else
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    if getGlobalStorageValue(config.zombieCounter) == 0 then
                                        if getGlobalStorageValue(config.rounds) == 0 then
                                            doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed the first wave of zombies. Good Job Man! The next Wave is about to begin!")
                                            setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                            setGlobalStorageValue(config.zombieCount, 0)
                                        elseif getGlobalStorageValue(config.rounds) <= 3 then
                                            doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! The next Wave is about to begin!")
                                            setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                            setGlobalStorageValue(config.zombieCount, 0)
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
                addEvent(zombieSpawn, 1 * 1000)
            elseif getGlobalStorageValue(config.rounds) <= 5 and getGlobalStorageValue(config.rounds) >= 1 then
                if getGlobalStorageValue(config.zombieCount) <= 9 then
                    pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
                    doSummonCreature(config.zombieName2, pos)
                    doSendMagicEffect(pos, CONST_ME_MORTAREA)
                    setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
                    setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
                else
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    if getGlobalStorageValue(config.zombieCounter) == 0 then
                                        if getGlobalStorageValue(config.rounds) <= 5 then
                                            doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! The next Wave is about to begin!")
                                            setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                            setGlobalStorageValue(config.zombieCount, 0)
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
                addEvent(zombieSpawn, 1 * 1000)
            elseif getGlobalStorageValue(config.rounds) <= 9 and getGlobalStorageValue(config.rounds) >= 6 then
                if getGlobalStorageValue(config.zombieCount) <= 9 then
                    pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
                    doSummonCreature(config.zombieName3, pos)
                    doSendMagicEffect(pos, CONST_ME_MORTAREA)
                    setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
                    setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
                else
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    if getGlobalStorageValue(config.zombieCounter) == 0 then
                                        if getGlobalStorageValue(config.rounds) <= 5 then
                                            doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! The next Wave is about to begin!")
                                            setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)    
                                            setGlobalStorageValue(config.zombieCount, 0)
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
                addEvent(zombieSpawn, 1 * 1000)
            else
                addEvent(endingEvent, 1 * 1000)
            end
        return true
        end
        
        function startEvent()
            for _, cid in ipairs(getPlayersOnline()) do
                if isInRange(getThingPos(cid), config.fromPos, config.toPos) then
                    doTeleportThing(cid, config.beginPos, true)
                    doPlayerSetStorageValue(cid, config.inGamecheck, 1)
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "The First round is about to begin!")
                                    addEvent(zombieSpawn, 1000)
                                    zombieSpawn()
                                end
                            end
                        end
                    end
                else
                    doBroadcastMessage(" The Zombies event has been canceled due to the lack of players.", MESSAGE_STATUS_WARNING)
                end
            end
            return true
        end


        function broadcasting()
            setGlobalStorageValue(config.NumZombieEvents, getGlobalStorageValue(config.NumZombieEvents)+1)
            addEvent(doBroadcastMessage, 1000, "Zombies will begin in 5 minutes.")
            addEvent(doBroadcastMessage, 120 * 1000, "Zombies will begin in 3 minutes.")
            addEvent(doBroadcastMessage, 240 * 1000, "Zombies will begin in 1 minute. Hurry up to the Mini-Game Waiting Room!")
            addEvent(doBroadcastMessage, 299 * 1000, "Zombie Event has started.")
            addEvent(startEvent, 300 * 1000)
            return true
        end


        function endingEvent()
            for _, cid in ipairs(getPlayersOnline()) do
                if isInRange(getThingPos(cid), config.areaFromPos, config.areaToPos) then
                    for x = config.areaFromPos.x, config.areaToPos.x do
                        for y = config.areaFromPos.y, config.areaToPos.y do
                            for z = config.areaFromPos.z, config.areaToPos.z do
                                areapos = {x = x, y = y, z = z, stackpos = 253}
                                getPlayers = getThingfromPos(areapos)
                                if isPlayer(getPlayers.uid) then
                                    doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just survived " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! That was the last wave!")
                                end
                            end
                        end
                    end
                    setGlobalStorageValue(config.rounds, 0)
                    setGlobalStorageValue(config.zombieCount, 0)
                    setGlobalStorageValue(config.zombieCounter, 0)
                    doPlayerSetStorageValue(cid, config.inGamecheck, 0)
                    addEventPoints(cid, 10)
                    doBroadcastMessage("The Zombies have been slayed! Congratz, thoes who lived won: 1 Event Tokens & 10 Event Points. Thoes who died earned 5 Event Points.", MESSAGE_STATUS_WARNING)
                    local goblet = doPlayerAddItem(cid, config.goblet, 1)
                    doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for surviving the Zombie event.")
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                    doTeleportThing(cid, config.temple, false)
        doPlayerAddMana(cid, manamax)
        doCreatureAddHealth(cid, healthmax)
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
                    for _,items in ipairs(config.moneyReward) do
                        if config.moneyReward[3] == 1 then
                            doPlayerAddItem(cid, config.moneyReward[1], config.moneyReward[2])
                        end
                    end
                end
                setGlobalStorageValue(config.zombieCount, 0)
            end
            return true
        end
    ]=]=></lib>
    <event type="kill" name="Zombies" event="script"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        domodlib('Zombielib')
        function onKill(cid, target)
            local name = getCreatureName(target):lower()
            local monster = monsters[getCreatureName(target):lower()]
            local t = inqconf.monboss[getCreatureName(target):lower()]
            if isInRange(getThingPos(cid), {x = 1536, y = 1377, z = 7}, {x = 1574, y = 1396, z = 7}) then
                setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)-1)
                if getGlobalStorageValue(config.zombieCounter) == 0 then
                    doCreatureSay(cid, "There are no Zombie Left. Please wait for the next round.", TALKTYPE_ORANGE_1)
                elseif getGlobalStorageValue(config.zombieCounter) == 1 then
                    doCreatureSay(cid, "There is "..getGlobalStorageValue(config.zombieCounter).. " Zombie Left.", TALKTYPE_ORANGE_1)
                else
                    doCreatureSay(cid, "There are "..getGlobalStorageValue(config.zombieCounter).. " Zombies Left.", TALKTYPE_ORANGE_1)
                end
            elseif (name == "troll" and getPlayerStorageValue(cid, 76669) == 2) then
                if getPlayerStorageValue(cid, monster) < 60 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 60 Trolls.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 60 trolls.")
                    setPlayerStorageValue(cid, 76669, 3)
                end
            elseif (name == "ghoul" and getPlayerStorageValue(cid, 76669) == 5) then
                if getPlayerStorageValue(cid, monster) < 100 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 100 Ghouls.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 100 ghouls.")
                    setPlayerStorageValue(cid, 76669, 6)
                end
            elseif ((name == "orc" or name == "orc beserker" or name == "orc leader" or name == "orc spearsman" or name == "orc warlord" or name == "orc warrior" or name == "orc rider" or name == "orc shaman") and getPlayerStorageValue(cid, 76669) == 8) then
                if getPlayerStorageValue(cid, monster) < 150 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 150 Orcs.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 150 orcs.")
                    setPlayerStorageValue(cid, 76669, 9)
                end
            elseif ((name == "minotaur" or name == "minotaur archer" or name == "minotaur guard" or name == "minotaur mage") and getPlayerStorageValue(cid, 76669) == 11) then
                if getPlayerStorageValue(cid, monster) < 200 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 200 minotaurs.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 200 minotaurs.")
                    setPlayerStorageValue(cid, 76669, 12)
                end
            elseif ((name == "dwarf" or name == "dwarf soldier" or name == "dwarf guard" or name == "dwarf geomancer") and getPlayerStorageValue(cid, 76669) == 14) then
                if getPlayerStorageValue(cid, monster) < 300 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 300 Dwarfs.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 300 dwarfs.")
                    setPlayerStorageValue(cid, 76669, 15)
                end
                elseif ((name == "dragon" or name == "dragon lord" or name == "dragon hatchling" or name == "dragon lord hatchling") and getPlayerStorageValue(cid, 76669) == 17) then
                if getPlayerStorageValue(cid, monster) < 500 then 
                    local killedMonsters = getPlayerStorageValue(cid, monster)
                    if(killedMonsters == -1) then
                        killedMonsters = 1
                    end
                    if(killedMonsters == 0) then
                        killedMonsters = 1
                    end
                    setPlayerStorageValue(cid, monster, killedMonsters + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 500 Dragons.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 500 dragons.")
                    setPlayerStorageValue(cid, 76669, 18)
                end
            elseif(name == "igor the recruiter" and getPlayerStorageValue(cid, 76670) == 7) then
                local teleport = doCreateTeleport(inqconf.teleportId, t.ptp, t.pp)
                doItemSetAttribute(teleport, "uid", t.uid)
                doCreatureSay(cid, inqconf.message, TALKTYPE_ORANGE_1)
                setPlayerStorageValue(cid, 76670, 8)
                addEvent(removeTeleport, 60 * 1000)
            end
        return true
        end
        function removeTeleport()
            local teleport = getTileItemById({x=1470, y=1450, z=8, stackpos=1}, 1387)
            if teleport.uid > 0 then
                doRemoveItem(teleport.uid)
            end
        end
        
    ]=]=></event>


    <event type="login" name="Zombielog" event="script"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        domodlib('Zombielib')
        function onLogin(cid)
            registerCreatureEvent(cid, "Zombies")
            registerCreatureEvent(cid, "ZombieGlobal")
            registerCreatureEvent(cid, "ZombieGlobal2")
        return true
        end
    ]=]=></event>
    
    <talkaction log="yes" words="/zombies" access="5" event ="script"><=!=[=C=D=A=T=A=[
        domodlib("ZombieConfig")
        domodlib('Zombielib')
        function onSay(cid, words, param)
            if(string.lower(param) == string.lower(config.passageKey)) then
                doPlayerSendCancel(cid, "You have selected to start the Zombie Event!.")
                setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
                setGlobalStorageValue(config.zombieCount, 0)
                setGlobalStorageValue(config.zombieCounter, 0)
                setGlobalStorageValue(config.rounds, 0)
                setGlobalStorageValue(config.NumZombieEvents, 0)
                broadcasting()
            elseif(string.lower(param) == string.lower(config.countKey)) then
                if getGlobalStorageValue(config.counts)+1 == 0 then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The Zombies Event has not been ran yet.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The Zombies Event has been ran: "..(getGlobalStorageValue(config.counts)+1).." times.")
                end
            elseif(string.lower(param) == string.lower(config.startNow)) then
                doPlayerSendCancel(cid, "You have selected to start the Zombie Event RIGHT NOW!.")
                setGlobalStorageValue(config.zombieCount, 0)
                setGlobalStorageValue(config.zombieCounter, 0)
                setGlobalStorageValue(config.rounds, 0)
                setGlobalStorageValue(config.NumZombieEvents, 0)
                setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
                startEvent()
            else
                doPlayerSendCancel(cid, "You must say the correct word to start the Zombie Event!.")
            end
        return true
        end
    ]=]=></talkaction>


    <globalevent name="ZombieGlobal" time="17:55" event="script"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        domodlib('Zombielib')
        function onTime(time)
            setGlobalStorageValue(config.zombieCount, 0)
            setGlobalStorageValue(config.zombieCounter, 0)
            setGlobalStorageValue(config.rounds, 0)
            setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
            addEvent(broadcasting, 1 * 1000)
        end
    ]=]=></globalevent>


    <globalevent name="ZombieGlobal2" time="07:55" event="script"><=!=[=C=D=A=T=A=[
        domodlib('ZombieConfig')
        domodlib('Zombielib')
        function onTime(time)
            setGlobalStorageValue(config.zombieCount, 0)
            setGlobalStorageValue(config.zombieCounter, 0)
            setGlobalStorageValue(config.rounds, 0)
            setGlobalStorageValue(config.NumZombieEvents, 0)
            setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
            addEvent(broadcasting, 1 * 1000)
        end
    ]=]=></globalevent>


</mod>
give that a try. changed so they get harder after every wave and added so it adds full mana/hp



OK i also wanted it to ondeath send the player to temple and add hp/mana, although the adding after the game is a good idea too... Other then that how did you change the zombie spawn AT ALL?...... its still checking how many rounds ect.. and i dont want to sit there a repeate TONS of code.. i want to turn the spawning of the zombies into something like this
Code:
if getGlobalStorageValue(config.rounds) ~= 10 then
    for getGlobalStorageValue(config.zombieCount) < 10 then
        pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
        doSummonCreature(config.zombieName, pos)
        doSendMagicEffect(pos, CONST_ME_MORTAREA)
        setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
        setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
    else
        for x = config.areaFromPos.x, config.areaToPos.x do
            for y = config.areaFromPos.y, config.areaToPos.y do
                for z = config.areaFromPos.z, config.areaToPos.z do
                    areapos = {x = x, y = y, z = z, stackpos = 253}
                    getPlayers = getThingfromPos(areapos)
                    if isPlayer(getPlayers.uid) then
                        if getGlobalStorageValue(config.zombieCounter) == 0 then
                            if getGlobalStorageValue(config.rounds) == 0 then
                                doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed the first wave of zombies. Good Job Man! The next Wave is about to begin!")
                                setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                setGlobalStorageValue(config.zombieCount, 0)
                            elseif getGlobalStorageValue(config.rounds) <= 3 then
                                doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! The next Wave is about to begin!")
                                setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                setGlobalStorageValue(config.zombieCount, 0)
                            end
                        end
                    end
                end
            end
        end
    end
        zombieName = zombieName + '1' -- ADD's A # BEHIND THE zombieName, each round/wave completed it'll add 1 to that number, changing what monster it'll spawn..
    addEvent(zombieSpawn, 1 * 1000)
else
    ENDING GAME W/ REWARDS AND TP
end

Although i know the above code wont work, i want to make it workable, using for statements to keep looping untill it's spawed 10 zombies(I think it might be the Do while statments... Not sure what to do, to do this how im wanting to do it..), then it'll wait for the zombies to all die, and then goto next round....

ALSO I NEED IT TO SEND PLAYER TO A POS WHEN THE PLAYER DIES IN THE EVENT/AREA, WITH FULL HP/MANA....


---- UPDATE ----

DO WHILE EXAMPLE.........
Code:
if getGlobalStorageValue(config.rounds) ~= 10 then
    if getGlobalStorageValue(config.zombieCount) ~= 10 then
        do
            pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
            doSummonCreature(config.zombieName, pos)
            doSendMagicEffect(pos, CONST_ME_MORTAREA)
            setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
            setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
        while(getGlobalStorageValue(config.zombieCount) < 10)
    else
        for x = config.areaFromPos.x, config.areaToPos.x do
            for y = config.areaFromPos.y, config.areaToPos.y do
                for z = config.areaFromPos.z, config.areaToPos.z do
                    areapos = {x = x, y = y, z = z, stackpos = 253}
                    getPlayers = getThingfromPos(areapos)
                    if isPlayer(getPlayers.uid) then
                        if getGlobalStorageValue(config.zombieCounter) == 0 then
                            if getGlobalStorageValue(config.rounds) == 0 then
                                doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed the first wave of zombies. Good Job Man! The next Wave is about to begin!")
                                setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                setGlobalStorageValue(config.zombieCount, 0)
                            elseif getGlobalStorageValue(config.rounds) <= 3 then
                                doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! The next Wave is about to begin!")
                                setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                setGlobalStorageValue(config.zombieCount, 0)
                            end
                        end
                    end
                end
            end
        end
    end
    zombieName = zombieName + '1' -- ADD's A # BEHIND THE zombieName, each round it'll add 1 to that number, changing what monster it'll spawn..
    addEvent(zombieSpawn, 1 * 1000)
else
    ENDING GAME W/ REWARDS AND TP
end

- - - Updated - - -

OK, well since no one is helping i tryed to do it myself...

Code:
		function zombieSpawn()
			if getGlobalStorageValue(config.rounds) <= 9 then
				if getGlobalStorageValue(config.zombieCount) <= 9 then
					for i = 0, 10, 1 do
						pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
						doCreateMonster("Event Zombie", pos)
						doSendMagicEffect(pos, CONST_ME_MORTAREA)
						setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
						setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
					end
				elseif getGlobalStorageValue(config.zombieCounter) <= 0 then
					for x = config.areaFromPos.x, config.areaToPos.x do
						for y = config.areaFromPos.y, config.areaToPos.y do
							for z = config.areaFromPos.z, config.areaToPos.z do
								areapos = {x = x, y = y, z = z, stackpos = 253}
								getPlayers = getThingfromPos(areapos)
								if isPlayer(getPlayers.uid) then
									if getGlobalStorageValue(config.rounds) == 0 then
										doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed the first wave of zombies. Good Job Man! The next Wave is about to begin!")
										setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
										setGlobalStorageValue(config.zombieCount, 0)
										i = 0
									elseif getGlobalStorageValue(config.rounds) >= 1 then
										doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! The next Wave is about to begin!")
										setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
										setGlobalStorageValue(config.zombieCount, 0)
										i = 0
									end
								end
							end
						end
					end
				end
				addEvent(zombieSpawn, 1 * 1000)
			else
				addEvent(endingEvent, 1 * 1000)
			end
			return true
		end
ALTHOUGH Each time its ran i get this error, although it spawns all the required zombies...
Code:
(luaInterface::luaDoCreateMonster) Cannot create monster: Event Zombie

- - - Updated - - -

The only Thign it does not do is make the zombies stronger..
Figure i change the "Event Zombie" to zombie, and make it a local variable/string.
I could do a HUGE if statement like
Code:
					for i = 0, 10, 1 do
						if getGlobalStorageValue(config.rounds) ~= 1 then
							zombie = "Event Zombie"
						elseif getGlobalStorageValue(config.rounds) == 1 then
							zombie = "Event Zombie2"
						elseif getGlobalStorageValue(config.rounds) == 2 then
							zombie = "Event Zombie3"
						elseif getGlobalStorageValue(config.rounds) == 3 then
							zombie = "Event Zombie4"
						elseif getGlobalStorageValue(config.rounds) == 4 then
							zombie = "Event Zombie5"
						elseif getGlobalStorageValue(config.rounds) == 5 then
							zombie = "Event Zombie6"
						elseif getGlobalStorageValue(config.rounds) == 6 then
							zombie = "Event Zombie7"
						elseif getGlobalStorageValue(config.rounds) == 7 then
							zombie = "Event Zombie8"
						elseif getGlobalStorageValue(config.rounds) == 8 then
							zombie = "Event Zombie9"
						elseif getGlobalStorageValue(config.rounds) == 9 then
							zombie = "Event Zombie10"
						end
						pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
						doCreateMonster(zombie, pos)
						doSendMagicEffect(pos, CONST_ME_MORTAREA)
						setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
						setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
					end
 
Last edited:
Back
Top Bottom