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

[mod]Zombie event don't summoned zombie

wujush

New Member
Joined
Jan 15, 2011
Messages
11
Reaction score
0
Hi. I have problem because when event started and are all players, script don't summoned zombies. There are no errors in console and i don't know fix this.

Code:
<?xml version='1.0' encoding='ISO-8859-1'?>
<mod name='Zombie Event' version='2.0' author='Oskar' contact='http://tibia.net.pl/members/oskar.html' 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 = 2 --ilosc graczy wymaganych do rozpoczecia eventu
zombieMinPlayers = 1 --minimalna ilosc graczy
zombieAccesToIgnore = 5 --acces ktory nie jest liczony jako osoba uczestniczaca w evencie
timeOnJoinToEvent = 10 --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=1000,z=7} --gdzie wyrzuca graczy po wyrzuceniu z eventu (przegranej)
zombieEnterPosition = {x=1500,y=825,z=7} --pozycja gdzie teleportuje graczy po rozpoczeciu eventu

zombieCenterRoomPosition = {x=1601,y=1503,z=7} --idealny srodek pomieszczenia
zombieRangeX_RangeY = {22,18} --szerokosc oraz wysokosc pomieszczenia dzielona przez dwa (liczone w najszerszych miejscach)

zombieStorageStatus = 13300 --storage uzywane do eventu

ZOMBIE = {
            ['horned mutant'] = {20,1}, --['nazwa potwora'] = {szansa na stworzenie, szansa na zainfekowanie}
            ['vile centurion'] = {15,2},
            ['daidalost'] = {10,4},
            ['mongrel man'] = {5,8},
            ['propell zombie'] = {2,16},
            ['scrathclaw'] = {1,32}
            }

function chooseMonster()
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 chooseMonster()
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, 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)
            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
        else
            msg = 'Zombie Event finished! No one win!'
        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 = chooseMonster()
    local cid = doCreateMonster((monster == '' and 'horned mutant' or monster), pos, false, false, 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 'Arena is full.'))
    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.')
end
return true
end
]]></talkaction>

<globalevent name="zombieTime" time="14:25" event="script"><![CDATA[
domodlib("zombieEvent_conf")
function onTime(time)
    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[
domodlib("zombieEvent_conf")
function onLogin(cid)
    doCreatureSetStorage(cid, zombieStorageStatus, 0)
    return registerCreatureEvent(cid, 'zombieEventStatsChange')
end
]]></event>
</mod>

Sorry for my bad english.
 
XML:
<?xml version='1.0' encoding='ISO-8859-1'?>
<mod name='Zombie Event' version='2.0' author='Oskar' contact='http://tibia.net.pl/members/oskar.html' 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 = 2 --ilosc graczy wymaganych do rozpoczecia eventu
zombieMinPlayers = 1 --minimalna ilosc graczy
zombieAccesToIgnore = 5 --acces ktory nie jest liczony jako osoba uczestniczaca w evencie
timeOnJoinToEvent = 10 --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=1000,z=7} --gdzie wyrzuca graczy po wyrzuceniu z eventu (przegranej)
zombieEnterPosition = {x=1500,y=825,z=7} --pozycja gdzie teleportuje graczy po rozpoczeciu eventu

zombieCenterRoomPosition = {x=1601,y=1503,z=7} --idealny srodek pomieszczenia
zombieRangeX_RangeY = {22,18} --szerokosc oraz wysokosc pomieszczenia dzielona przez dwa (liczone w najszerszych miejscach)

zombieStorageStatus = 13300 --storage uzywane do eventu

ZOMBIE = {
            ['horned mutant'] = {20,1}, --['nazwa potwora'] = {szansa na stworzenie, szansa na zainfekowanie}
            ['vile centurion'] = {15,2},
            ['daidalost'] = {10,4},
            ['mongrel man'] = {5,8},
            ['propell zombie'] = {2,16},
            ['scrathclaw'] = {1,32}
            }

function chooseMonster()
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 chooseMonster()
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, 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)
            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
        else
            msg = 'Zombie Event finished! No one win!'
        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 = chooseMonster()
    local cid = doCreateMonster((monster == '' and 'Zombie' or monster), pos, false, false, 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 'Arena is full.'))
    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.')
end
return true
end
]]></talkaction>

<globalevent name="zombieTime" time="14:25" event="script"><![CDATA[
domodlib("zombieEvent_conf")
function onTime(time)
    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(getZombieEventPlayers()) do
                                addPlayerToZombiesArea(v, false)
                            end
                            return doBroadcastMessage('Zombie Event is started. We have '..#getZombiesEventPlayers()..' players on area')
                        end
                        for _, v in ipairs(getZombieEventPlayers()) do
                            kickPlayerFromZombieArea(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[
domodlib("zombieEvent_conf")
function onLogin(cid)
    doCreatureSetStorage(cid, zombieStorageStatus, 0)
    return registerCreatureEvent(cid, 'zombieEventStatsChange')
end
]]></event>
</mod>
I think you can try this.
 
Back
Top