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

Solved zombie event error

newlegacy

New Member
Joined
Dec 15, 2012
Messages
44
Reaction score
0
Location
Dominican Republic
hi friends of otland i have this error in console with the zombie event start

339unhs.png


i use tfs 1.1 i need add some code in global.lua or compat.lua if anyone can help me plis thanks
 
Code:
-- Zombie Variables
zeZombieName = 'Zombie Event' --Zombie Name
zombieSpawnInterval = 5 --how many seconds until a new zombie spawns
zeMaxZombies = 50 --max zombies in the arena?
zeJoinedCountGlobalStorage = 60009 --Player joined event count

-- Players Variables
zeJoinStorage = 60010 --player join storage
zeMinPlayers = 1 --min players needed when time runout
zeMaxPlayers = 5 --max players to join
zeTrophy = 7369 --trophy itemid
zeJoinedCountGlobalStorage = 60011 --Zombie spawned Count

-- Other Variables
zeWaitMinutes = 2 --when event has opened, how long until it starts?
zeWaitingRoomPos = Position(31959, 32369, 6) --middle of waiting room
zeZombieArena = Position(31959, 32365, 7) --when even start where should player be teleported in the zombie arena?
zeArenaFromPosition = Position(31896, 32322, 7) --pos of top left corner
zeArenaToPosition = Position(32016, 32469, 7) --pos of bottom right corner
zeMiddleZombieArena = Position(31955, 32400, 7) --Middle pos of the arena
zeWaitingRoomRadiusX = 11 --depends how big the waiting room is 20sqm to x
zeWaitingRoomRadiusY = 15 --depends how big the waiting room is 20sqm to y
zeZombieArenaRadiusX = 103 --Depends how big the zombie arena is 50sqm to x
zeZombieArenaRadiusY = 149 --Depends how big the zombie arena is 50sqm to y
zeStartedGlobalStorage = 60012 -- Value: 0 == false, 1 == true, 2 == started --State of the event
zeCreateTeleportPosition = Position(32243, 32206, 7) --Where should the teleport be created?

function startZombie()
    local specs = Game.getSpectators(zeWaitingRoomPos, false, true, 0, zeWaitingRoomRadiusX, 0, zeWaitingRoomRadiusY)
        if Game.getStorageValue(zeJoinedCountGlobalStorage) < zeMinPlayers then
            for i = 1, #specs do
                    specs[i]:teleportTo(specs[i]:getTown():getTemplePosition(), false)
                    specs[i]:setStorageValue(zeJoinStorage, 0)
            end
            resetVariables()
            Game.broadcastMessage('Zombie Event failed to start, because of to little players joined the event!', MESSAGE_STATUS_WARNING)
            return true
        end
        for i = 1, #specs do
            specs[i]:teleportTo(zeZombieArena)
        end
        Game.broadcastMessage("Zombie Event has started, good luck to all participant.", MESSAGE_STATUS_WARNING)
        Game.setStorageValue(zeStartedGlobalStorage, 2)
        doStartZombieEvasion()
end

function doSummonZombie()
        if Game.getStorageValue(zeZombieCountGlobalStorage) > zeMaxZombies then
            return false
        end
        local zombie = Game.createMonster(zeZombieName, {x = math.random(zeArenaFromPosition.x, zeArenaToPosition.x), y = math.random(zeArenaFromPosition.y, zeArenaToPosition.y), z = math.random(zeArenaFromPosition.z, zeArenaToPosition.z)})
        if zombie then
            Game.createMonster(zeZombieName, {x = math.random(zeArenaFromPosition.x, zeArenaToPosition.x), y = math.random(zeArenaFromPosition.y, zeArenaToPosition.y), z = math.random(zeArenaFromPosition.z, zeArenaToPosition.z)})
        end
        Game.setStorageValue(zeZombieCountGlobalStorage, Game.getStorageValue(zeZombieCountGlobalStorage) + 1)
end

function doStartZombieEvasion()
        if Game.getStorageValue(zeStartedGlobalStorage) == 2 then
               doSummonZombie()
            addEvent(doStartZombieEvasion, 5 * 1000)
        end
end

function resetVariables()
        Game.setStorageValue(zeJoinedCountGlobalStorage, 0)
        Game.setStorageValue(zeZombieCountGlobalStorage, 0)
        Game.setStorageValue(zeStartedGlobalStorage, 0)
end

function doClearZombieArena()
        local specs = Game.getSpectators(zeMiddleZombieArena, false, false, 0, zeZombieArenaRadiusX, 0, zeZombieArenaRadiusY)
        for i = 1, #specs do
            if specs[i]:getName() == zeZombieName then
                    specs[i]:remove()
            end
        end
end


and the line 172 in global.lua

Code:
function Game.setStorageValue(key, value)
    globalStorageTable[key] = value
end
 
This isn't set in the code
Code:
zeZombieCountGlobalStorage

Also you have 2 definitions of zeJoinedCountGlobalStorage
Code:
zeJoinedCountGlobalStorage = 60009 --Player joined event count

zeJoinedCountGlobalStorage = 60011 --Zombie spawned Count

Try renaming this one
Code:
zeJoinedCountGlobalStorage = 60011 --Zombie spawned Count
to this
Code:
zeZombieCountGlobalStorage = 60011 --Zombie spawned Count
 
movement
Code:
dofile('data/zombie_system.lua')

function onStepIn(cid, item, position, fromPosition)
        local player = Player(cid)
    if not player then
            return false
        end

        if Game.getStorageValue(zeStartedGlobalStorage) == 2 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'The Zombie Event has already started.')
            player:teleportTo(fromPosition, true)
            return false
        end

        if Game.getStorageValue(zeStartedGlobalStorage) == 0 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'The Zombie Event has not started yet.')
            player:teleportTo(fromPosition, true)
            return false
        end

       if Game.getStorageValue(zeJoinedCountGlobalStorage) > zeMaxPlayers then
            player:teleportTo(fromPosition, true)
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'The Zombie Event is already full! ['.. Game.getStorageValue(zeJoinedCountGlobalStorage) ..'/'.. zeMaxPlayers ..']')
            return false
        end

        player:teleportTo(zeWaitingRoomPos)
        Game.setStorageValue(zeJoinedCountGlobalStorage, Game.getStorageValue(zeJoinedCountGlobalStorage) + 1)
        Game.broadcastMessage(string.format('%s has joined the Zombie Event! [%s/'.. zeMaxPlayers ..'].', player:getName(), Game.getStorageValue(zeJoinedCountGlobalStorage)), MESSAGE_STATUS_WARNING)
        player:setStorageValue(zeJoinStorage, 1)
        return true
end

creaturescript
Code:
dofile('data/zombie_system.lua')

function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    local monster = Monster(cid)
    monster:say("I WILL BE BACK!", TALKTYPE_MONSTER_YELL)
    monster:getPosition():sendMagicEffect(CONST_ME_MORTAREA)
    doSummonZombie()
    Game.setStorageValue(zeZombieCountGlobalStorage, Game.getStorageValue(zeZombieCountGlobalStorage) - 1)
end

function onPrepareDeath(cid, killer)
    local player = Player(cid)
    local winner = 0
    if player:getStorageValue(zeJoinStorage) == 1 then
        Game.setStorageValue(zeJoinedCountGlobalStorage, Game.getStorageValue(zeJoinedCountGlobalStorage) - 1)
        player:teleportTo(player:getTown():getTemplePosition())
        player:setStorageValue(zeJoinStorage, 0)
        player:addHealth(player:getMaxHealth())
        if Game.getStorageValue(zeJoinedCountGlobalStorage) <= 1 then --Event ended, someone won!
            local players = Game.getPlayers()
            for _, tmpPlayer in ipairs(players) do
                local stor = tmpPlayer:getStorageValue(zeJoinStorage)
                if stor == 1 then
                    winner = tmpPlayer:getId()
                    break
                end
            end
            winner = Player(winner)
            if winner then
                winner:teleportTo(winner:getTown():getTemplePosition())
                local trophy = winner:addItem(zeTrophy, 1)
                if trophy then
                    trophy:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, '['.. winner:getName() ..'] has won the Zombie Event.')
                end
                 Game.broadcastMessage(string.format('%s is the winner of Zombie Event Versus %s Zombies.', winner:getName(), Game.getStorageValue(zeZombieCountGlobalStorage)), MESSAGE_STATUS_WARNING)
            end
            doClearZombieArena()
            resetVariables()
        end
        return false
    end
    return true
end

talkation
Code:
dofile('data/zombie_system.lua')

function onSay(cid, words, param)
    local player = Player(cid)

    if Game.getStorageValue(zeStartedGlobalStorage) == 2 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'The Zombie Event has already started.')
        return false
    end

   if Game.getStorageValue(zeStartedGlobalStorage) < 1 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "The Zombie Event has not started yet.")
        return false
    end

    if Game.getStorageValue(zeJoinedCountGlobalStorage) > zeMaxPlayers then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'The Zombie Event is already full! ['.. Game.getStorageValue(zeJoinedCountGlobalStorage) ..'/'.. zeMaxPlayers ..']')
        return false
    end

    if player:isPzLocked() then
        player:sendCancelMessage('You can\'t join the zombie while you are in a fight!')
        return false
    end
   
    player:teleportTo(zeWaitingRoomPos)
    if not player:getGroup():getAccess() then
        Game.setStorageValue(zeJoinedCountGlobalStorage, Game.getStorageValue(zeJoinedCountGlobalStorage) + 1)
        Game.broadcastMessage(string.format('%s has joined the Zombie Event! [%s/'.. zeMaxPlayers ..'].', player:getName(), Game.getStorageValue(zeJoinedCountGlobalStorage)), MESSAGE_STATUS_WARNING)
        player:setStorageValue(zeJoinStorage, 1)
    end
    return false
end
 
The only reason I can see why it would list 0/5 when 1 player joins is because a storage value by default holds -1 not 0, 1 + (-1) = 0

This needs to be set to 0 initially
Code:
zeJoinedCountGlobalStorage
 
Back
Top