• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Zombie Event MOD

dex93

New Member
Joined
May 31, 2015
Messages
57
Reaction score
3
Hi,
I have Zombie Event MOD and I tried to add command to run this event by GM,CM,GOD.

Everything is working but...
I can't run again this event.
No errors in distro, no errors in game, nothing happened.

My code:

Code:
<?xml version='1.0' encoding='ISO-8859-1'?>
<mod name='Zombie Event' version='2.0' author='Oskar' contact='[email protected]' enabled='yes'>
<config name='zombieEvent_conf'><![CDATA[
zombieRewards = {
                random = false, --czy ma losowac nagrode
                rew = {2160,5} --nagrody, wypelniamy w ten sposob {itemId1, count1, itemId2, count2 ...}
                }
zombieMaxPlayers = 5 --ilosc graczy wymaganych do rozpoczecia eventu
zombieMinPlayers = 1 --minimalna ilosc graczy
zombieAccesToIgnore = 4 --acces ktory nie jest liczony jako osoba uczestniczaca w evencie
timeOnJoinToEvent = 1 --ilosc minut ktora czeka skrypt na wymagana ilosc graczy
zombieJoinType = 'booth' --movement, talkaction lub oba, sposob dolaczania sie do eventu
-- POSITIONS
zombieKickPosition = {x=1000,y=1004,z=4} --gdzie wyrzuca graczy po wyrzuceniu z eventu (przegranej)
zombieEnterPosition = {x=1354,y=650,z=4} --pozycja gdzie teleportuje graczy po rozpoczeciu eventu
zombieCenterRoomPosition = {x=1354,y=650,z=4} --idealny srodek pomieszczenia
zombieRangeX_RangeY = {30,30} --szerokosc oraz wysokosc pomieszczenia dzielona przez dwa (liczone w najszerszych miejscach)
zombieStorageStatus = 13300 --storage uzywane do eventu
ZOMBIE = {
          --UWAGA! NAZWY POTWORÓW KONIECZNIE PISANE Z MALYCH LITER!
          --['nazwa potwora'] = {szansa na stworzenie, szansa na zainfekowanie}
            ['horned mutant'] = {20,1},
            ['vile centurion'] = {15,2},
            ['daidalost'] = {10,4},
            ['mongrel man'] = {5,8},
            ['propell zombie'] = {2,16},
            ['scrathclaw'] = {1,32}
            }
function chooseZombieMonster()
local monster = false
for k, v in pairs(ZOMBIE) do
    monster = monster or (math.random(100) <= v[1] and k or false)
end
return monster or chooseZombieMonster()
end
function isWalkable(pos, creature, proj, pz)
if getTileThingByPos({x=pos.x,y=pos.y,z=pos.z,stackpos=0}).itemid == 0 then return false end
if getTopCreature(pos).uid > 0 and creature then return false end
if getTileInfo(pos).protection and pz then return false, true end
local n = not proj and 3 or 2
for i = 0, 255 do
    pos.stackpos = i
    local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
end
return true
end
local _f = doTeleportThing
function doTeleportThing(cid, newpos, ignoreBlocking)
    return (ignoreBlocking or isWalkable(newpos, true, true, false) or false) and _f(cid, newpos, true)
end
function getZombiesEventPlayers()
    local players = {}
    for _, cid in pairs(getPlayersOnline()) do
        if getCreatureStorage(cid, zombieStorageStatus) == 1 and getPlayerAccess(cid) < zombieAccesToIgnore then
            table.insert(players, cid)
        end
    end
    return players
end
function kickPlayerFromZombiesArea(cid)
    doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
    doTeleportThing(cid, zombieKickPosition, true)
    doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
    return doCreatureSetStorage(cid, zombieStorageStatus, 0) and doCreatureSetNoMove(cid, false)
end
function loseOnZombieArena(cid)
    local players, msg = getZombiesEventPlayers(), ''
    doCreatureSetStorage(cid, zombieStorageStatus+1, 0)
    kickPlayerFromZombiesArea(cid)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You are dead.')
    if(#getZombiesEventPlayers() <= 1) then
        local winner = getZombiesEventPlayers()[1] or players[1]
        if winner then
            if zombieRewards.random then
                local i = math.random(#zombieRewards.rew/2)
                local rewardItem = doPlayerAddItem(winner, zombieRewards.rew[i*2-1], zombieRewards.rew[i*2], true)
            else
                for i = 1, #zombieRewards.rew/2 do
                    doPlayerAddItem(winner, zombieRewards.rew[i*2-1], zombieRewards.rew[i*2], true)
                end
            end
            doPlayerSendTextMessage(winner, MESSAGE_INFO_DESCR, 'You won Zombie Event.')
            msg = getCreatureName(winner) .. ' won Zombie Event.'
            kickPlayerFromZombiesArea(winner)
        else
            msg = 'Zombie Event finished! No one win!'
        end
        if getSpectators(zombieCenterRoomPosition, zombieRangeX_RangeY[1], zombieRangeX_RangeY[2]) then
            for _, v in ipairs(getSpectators(zombieCenterRoomPosition, zombieRangeX_RangeY[1], zombieRangeX_RangeY[2])) do
                if isMonster(v) then
                    doRemoveThing(v)
                elseif isPlayer(v) then
                    kickPlayerFromZombiesArea(v)
                end
            end
        end
        doSetStorage(zombieStorageStatus, 0)
    end
return (msg ~= '' and doBroadcastMessage(msg) or true)
end
function addPlayerToZombiesArea(cid, block)
doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
doTeleportThing(cid, zombieEnterPosition, true)
doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
return doCreatureSetStorage(cid, zombieStorageStatus, 1) and doCreatureSetNoMove(cid, block)
end
function spawnNewZombie(fromPosition, n)
local n, pos = n or 0, {x = zombieCenterRoomPosition.x + math.random(-zombieRangeX_RangeY[1],zombieRangeX_RangeY[1]), y = zombieCenterRoomPosition.y + math.random(-zombieRangeX_RangeY[2],zombieRangeX_RangeY[2]), z = zombieCenterRoomPosition.z}
if isWalkable(pos, true, true, true) then
    local monster = chooseZombieMonster()
    local cid = doCreateMonster((monster == '' and 'horned mutant' or monster), pos, false)
    doSendMagicEffect(pos, CONST_ME_MORTAREA)
    return (isMonster(cid) and registerCreatureEvent(cid, 'zombieEventDeath') and registerCreatureEvent(cid, 'zombieEventThink')) and (fromPosition and doSendDistanceShoot(fromPosition, pos, CONST_ANI_SUDDENDEATH) or true)
end
return (n < 200 and spawnNewZombie(fromPosition, n+1) or true)
end
function setZombieEventStart()
if getStorage(zombieStorageStatus) < 1 then
    doSetStorage(zombieStorageStatus, 1)
    doBroadcastMessage('Zombie Arena Event is started. If you want join to event say !zombie join or enter the teleport in depot. We wait on '..zombieMaxPlayers..' players.')
    if getSpectators(zombieCenterRoomPosition, zombieRangeX_RangeY[1], zombieRangeX_RangeY[2]) then
        for _, cid in pairs(getSpectators(zombieCenterRoomPosition, zombieRangeX_RangeY[1], zombieRangeX_RangeY[2])) do
            if isMonster(cid) then doRemoveThing(cid) end
        end
    end
end
return true
end
]]></config>
<event type='death' name='zombieEventDeath' event='script'><![CDATA[
domodlib('zombieEvent_conf')
function onDeath(cid)
    for i = 1, math.random(2) do
        spawnNewZombie(getThingPos(cid))
    end
    doSendMagicEffect(getThingPos(cid), CONST_ME_MORTAREA)
    return doCreatureSay(cid, 'I\'ll be back!', TALKTYPE_ORANGE_1)
end
]]></event>
<event type='think' name='zombieEventThink' event='script'><![CDATA[
domodlib('zombieEvent_conf')
function onThink(cid)
local name, target = getCreatureName(cid):lower(), getCreatureTarget(cid)
if isMonster(cid) and ZOMBIE[name] and target and isPlayer(target) then
    if getCreatureStorage(target, zombieStorageStatus+1) < os.time() and getDistanceBetween(getThingPos(target), getThingPos(cid)) <= 1 and math.random(100) <= ZOMBIE[name][2] then
        doSendAnimatedText(getThingPos(target), 'INFECTED!', COLOR_LIGHTGREEN)
        doCreatureSetStorage(target, zombieStorageStatus+1, os.time() + 3)
        doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_BLUE, 'You are infected. You can cure, just say "disable infection", but remember, you have only three seconds on it.')
        return addEvent(function()
                                if isPlayer(target) then
                                    if getCreatureStorage(target, zombieStorageStatus+1) ~= os.time() then
                                        return false
                                    end
                                    doCreatureAddHealth(target, getCreatureMaxHealth(target))
                                    return loseOnZombieArena(target)
                                end return true end,
                                3000,
                                target)
    end
end
return true
end
]]></event>
<talkaction words='disable' event='script'><![CDATA[
domodlib('zombieEvent_conf')
function onSay(cid, words, param, channel)
if getCreatureStorage(cid, zombieStorageStatus+1) < os.time() or param ~= 'infection' then
    return false
end
doSendAnimatedText(getThingPos(cid), 'CURE!', COLOR_LIGHTBLUE)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You use an antidote on infection.')
return doCreatureSetStorage(cid, zombieStorageStatus+1, 0)
end
]]></talkaction>
<event type='statschange' name='zombieEventStatsChange' event='script'><![CDATA[
domodlib('zombieEvent_conf')
function onStatsChange(cid, attacker, type, combat, value)
if isMonster(attacker) and isPlayer(cid) and ZOMBIE[getCreatureName(attacker):lower()] and type == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(cid) then
    doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
    return loseOnZombieArena(cid) and false
end
return true
end
]]></event>
<globalevent name='zombieStart' type='start' event='script'><![CDATA[
domodlib('zombieEvent_conf')
function onStartup()
    return doSetStorage(zombieStorageStatus, 0)
end
]]></globalevent>
<moveevent type='stepIn' uniqueid='3000' event='script'><![CDATA[
domodlib('zombieEvent_conf')
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if zombieJoinType == 'talkaction' then
    return doTeleportThing(cid, fromPosition, true) end
local msg = ''
if isPlayer(cid) then
    if getCreatureCondition(cid, CONDITION_INFIGHT) and getPlayerAccess(cid) < zombieAccesToIgnore then
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have a PZ! You have to get rid of it. Somehow.')
    end
    if getPlayerAccess(cid) >= zombieAccesToIgnore then
        setZombieEventStart()
        return doTeleportThing(cid, zombieEnterPosition, true)
    elseif #getZombiesEventPlayers() < zombieMaxPlayers and getStorage(zombieStorageStatus) == 1 then
        addPlayerToZombiesArea(cid, true)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You are player of number '..#getZombiesEventPlayers()..', which join to event.')
        if #getZombiesEventPlayers() == zombieMaxPlayers then
            doSetStorage(zombieStorageStatus, 2)
            for i = 1, math.random(2) do
                spawnNewZombie(getThingPos(cid))
            end
            for _, v in pairs(getZombiesEventPlayers()) do
                addPlayerToZombiesArea(v, false)
            end
            msg = 'Zombie Event is started. We have ' .. zombieMaxPlayers .. ' players, which joined to event. Have fun!'
        else
            msg = getCreatureName(cid) .. ' has entered a Zombie Arena. We still need ' .. zombieMaxPlayers - #getZombiesEventPlayers() .. ' players.'
        end
        return (msg ~= '' and doBroadcastMessage(msg) or true)
    else
        return doTeleportThing(cid, fromPosition, true) and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Arena is full.')
    end
end
return true
end
]]></moveevent>
<talkaction words='!zombie' event='script'><![CDATA[
domodlib('zombieEvent_conf')
function onSay(cid, words, param, channel)
if zombieJoinType == 'movement' then
    return false end
local msg = ''
if isInArray({'join','add','go','joined'}, param:lower()) then
    if getCreatureCondition(cid, CONDITION_INFIGHT) and getPlayerAccess(cid) <= zombieAccesToIgnore then
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have a PZ! You have to get rid of it. Somehow.')
    end
    if getPlayerAccess(cid) >= zombieAccesToIgnore then
        setZombieEventStart()
        return doTeleportThing(cid, zombieEnterPosition, true)
    elseif #getZombiesEventPlayers() < zombieMaxPlayers and getStorage(zombieStorageStatus) == 1 then
        addPlayerToZombiesArea(cid, true)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You are player of number '..#getZombiesEventPlayers()..', which join to event.')
        if #getZombiesEventPlayers() == zombieMaxPlayers then
            doSetStorage(zombieStorageStatus, 2)
            for i = 1, math.random(2) do
                spawnNewZombie(getThingPos(cid))
            end
            for _, v in pairs(getZombiesEventPlayers()) do
                addPlayerToZombiesArea(v, false)
            end
            msg = 'Zombie Event is started. We have ' .. zombieMaxPlayers .. ' players, which joined to event. Have fun!'
        else
            msg = getCreatureName(cid) .. ' has entered a Zombie Arena. We still need ' .. zombieMaxPlayers - #getZombiesEventPlayers() .. ' players.'
        end
        return (msg ~= '' and doBroadcastMessage(msg) or true)
    else
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, (getStorage(zombieStorageStatus) == -1 and 'Event is no started.' or 'Event is no started.'))
    end
elseif isInArray({'leave','abort','delete'}, param:lower()) then
    if getStorage(zombieStorageStatus) < 2 then
        doCreatureSetStorage(cid, zombieStorageStatus, 0)
        doCreatureSetNoMove(cid, false)
        return doTeleportThing(cid, getCreatureLastPosition(cid), true)
    end
    return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You can\'t leave from arena if event is already running.')
elseif isInArray({'start'}, param:lower()) and getPlayerAccess(cid) > 4 then
    addEvent(function()
                        if getStorage(zombieStorageStatus) == 2 then return true end
                        if getStorage(zombieStorageStatus) == 1 and #getZombiesEventPlayers() >= zombieMinPlayers then
                            doSetStorage(zombieStorageStatus, 2)
                            for i = 1, math.random(2) do
                                spawnNewZombie(getThingPos(cid))
                            end
                            for _, v in ipairs(getZombiesEventPlayers()) do
                                addPlayerToZombiesArea(v, false)
                            end
                            return doBroadcastMessage('Zombie Event is started. We have '..#getZombiesEventPlayers()..' players on area')
                        end
                        for _, v in ipairs(getZombiesEventPlayers()) do
                            kickPlayerFromZombiesArea(v)
                        end
                        return doBroadcastMessage('Zombie Event is stopped. We could not find enough players.')
                        end,
                        timeOnJoinToEvent * 1000 * 60)
                   
    return setZombieEventStart()
end
return true
end
]]></talkaction>

<globalevent name="zombieTime" interval="600000" event="script"><![CDATA[
domodlib("zombieEvent_conf")
function onThink()
    addEvent(function()
                        if getStorage(zombieStorageStatus) == 2 then return true end
                        if getStorage(zombieStorageStatus) == 1 and #getZombiesEventPlayers() >= zombieMinPlayers then
                            doSetStorage(zombieStorageStatus, 2)
                            for i = 1, math.random(2) do
                                spawnNewZombie(getThingPos(cid))
                            end
                            for _, v in ipairs(getZombiesEventPlayers()) do
                                addPlayerToZombiesArea(v, false)
                            end
                            return doBroadcastMessage('Zombie Event is started. We have '..#getZombiesEventPlayers()..' players on area')
                        end
                        for _, v in ipairs(getZombiesEventPlayers()) do
                            kickPlayerFromZombiesArea(v)
                        end
                        return doBroadcastMessage('Zombie Event is stopped. We could not find enough players.')
                        end,
                        timeOnJoinToEvent * 1000 * 60)
                   
    return setZombieEventStart()
end
]]></globalevent>
<event type="login" name="zombieEventLogin" event="script"><![CDATA[
function onLogin(cid)
    doCreatureSetStorage(cid, zombieStorageStatus, 0)
    return registerCreatureEvent(cid, 'zombieEventStatsChange')
end
]]></event>
</mod>


Problem must be there:
Code:
<talkaction words='!zombie' event='script'><![CDATA[
domodlib('zombieEvent_conf')
function onSay(cid, words, param, channel)
if zombieJoinType == 'movement' then
    return false end
local msg = ''
if isInArray({'join','add','go','joined'}, param:lower()) then
    if getCreatureCondition(cid, CONDITION_INFIGHT) and getPlayerAccess(cid) <= zombieAccesToIgnore then
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have a PZ! You have to get rid of it. Somehow.')
    end
    if getPlayerAccess(cid) >= zombieAccesToIgnore then
        setZombieEventStart()
        return doTeleportThing(cid, zombieEnterPosition, true)
    elseif #getZombiesEventPlayers() < zombieMaxPlayers and getStorage(zombieStorageStatus) == 1 then
        addPlayerToZombiesArea(cid, true)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You are player of number '..#getZombiesEventPlayers()..', which join to event.')
        if #getZombiesEventPlayers() == zombieMaxPlayers then
            doSetStorage(zombieStorageStatus, 2)
            for i = 1, math.random(2) do
                spawnNewZombie(getThingPos(cid))
            end
            for _, v in pairs(getZombiesEventPlayers()) do
                addPlayerToZombiesArea(v, false)
            end
            msg = 'Zombie Event is started. We have ' .. zombieMaxPlayers .. ' players, which joined to event. Have fun!'
        else
            msg = getCreatureName(cid) .. ' has entered a Zombie Arena. We still need ' .. zombieMaxPlayers - #getZombiesEventPlayers() .. ' players.'
        end
        return (msg ~= '' and doBroadcastMessage(msg) or true)
    else
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, (getStorage(zombieStorageStatus) == -1 and 'Event is no started.' or 'Event is no started.'))
    end
elseif isInArray({'leave','abort','delete'}, param:lower()) then
    if getStorage(zombieStorageStatus) < 2 then
        doCreatureSetStorage(cid, zombieStorageStatus, 0)
        doCreatureSetNoMove(cid, false)
        return doTeleportThing(cid, getCreatureLastPosition(cid), true)
    end
    return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You can\'t leave from arena if event is already running.')
elseif isInArray({'start'}, param:lower()) and getPlayerAccess(cid) > 4 then
    addEvent(function()
                        if getStorage(zombieStorageStatus) == 2 then return true end
                        if getStorage(zombieStorageStatus) == 1 and #getZombiesEventPlayers() >= zombieMinPlayers then
                            doSetStorage(zombieStorageStatus, 2)
                            for i = 1, math.random(2) do
                                spawnNewZombie(getThingPos(cid))
                            end
                            for _, v in ipairs(getZombiesEventPlayers()) do
                                addPlayerToZombiesArea(v, false)
                            end
                            return doBroadcastMessage('Zombie Event is started. We have '..#getZombiesEventPlayers()..' players on area')
                        end
                        for _, v in ipairs(getZombiesEventPlayers()) do
                            kickPlayerFromZombiesArea(v)
                        end
                        return doBroadcastMessage('Zombie Event is stopped. We could not find enough players.')
                        end,
                        timeOnJoinToEvent * 1000 * 60)
                   
    return setZombieEventStart()
end
return true
end
]]></talkaction>


and I found second problem...
When I say !zombie start players get this broadcast msg:
11:59 Zombie Arena Event is started. If you want join to event say !zombie join or enter the teleport in depot. We wait on 5 players.

well...
but when nobody are there players get this msg:
12:00 Zombie Event is stopped. We could not find enough players.

well...
but after this players should get info about Zombie Arena Event Started bla bla but is again same info:

12:00 Zombie Event is stopped. We could not find enough players.
12:00 Zombie Event is stopped. We could not find enough players.
12:07 Zombie Event is stopped. We could not find enough players.
12:09 Zombie Event is stopped. We could not find enough players.


What's wrong?

EDIT
ahh and did I set good interval? event=script and function onThink?

Distro OTX for 8.6 Tibia
 
Last edited:
function onSay(cid, words, param, channel)
if(getStorage(ZE_STATUS) ~= 2) then
local players_on_arena_count = #getZombiesEventPlayers()
if(param == 'force') then
if(players_on_arena_count > 0) then
setZombiesEventPlayersLimit(players_on_arena_count )
addZombiesEventBlockEnterPosition()
doSetStorage(ZE_STATUS, 2)
doBroadcastMessage("Zombie Arena Event started.")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Zombies event started.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Cannot start Zombies event. There is no players on arena.")
end
else
if(param ~= '' and tonumber(param) > 0) then
setZombiesEventPlayersLimit(tonumber(param))
end
removeZombiesEventBlockEnterPosition()
doSetStorage(ZE_STATUS, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Event started.")
doPlayerBroadcastMessage(cid, "Zombie Arena Event teleport is opened. We are waiting for " .. getZombiesEventPlayersLimit() - players_on_arena_count .. " players to start.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Zombies event is already running.")
end
return true
end



This MY Zombie talkaction script try it ^_^
 
Back
Top