Zombie Event BETA! [Tfs 1.0] Vers: 0.5

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by Printer, Apr 24, 2014.

  1. Mister mox

    Mister mox New Member

    Joined:
    Mar 3, 2010
    Messages:
    6
    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

    dofile('data/zombie_system.lua')

    function onThink(interval, lastExecution, thinkInterval)
    if Game.getStorageValue(zeStartedGlobalStorage) < 1 then
    local teleport = Game.createItem(1387, 1, zeCreateTeleportPosition)
    if teleport then
    teleport:setAttribute(ITEM_ATTRIBUTE_UNIQUEID, 7000)
    end
    Game.setStorageValue(zeStartedGlobalStorage, 1)
    print('Zombie Event has started & waiting for players to join! Min: '.. zeMinPlayers ..'/'.. zeMaxPlayers ..'.')
    Game.broadcastMessage('The Zombie Event has started! You have '.. zeWaitMinutes ..' minutes to join!', MESSAGE_STATUS_WARNING)
    addEvent(startZombie, zeWaitMinutes * 60 * 1000)
    end
    return true
    end
     
  2. davidmemo

    davidmemo Member

    Joined:
    Mar 28, 2011
    Messages:
    37
    i have one problem
    [​IMG]
    and this is the code

    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
     
  3. Mister mox

    Mister mox New Member

    Joined:
    Mar 3, 2010
    Messages:
    6
    using this modification my server kept sending error message, but now broadcast message, i solved the problem removed the initial "Game." before every broadcast command
    ex:
    Game.broadcastMessage (string.format ('% s has joined the Zombie Event [% s /!' .. ZeMaxPlayers .. '].' Player: GetName (), Game.getStorageValue (zeJoinedCountGlobalStorage)), MESSAGE_STATUS_WARNING)

    Should be:
    broadcastMessage (string.format ('% s has joined the Zombie Event [% s /!' .. zeMaxPlayers .. '].' player: GetName (), Game.getStorageValue (zeJoinedCountGlobalStorage)), MESSAGE_STATUS_WARNING)

    and if you only have two or fewer characters in the event does not work

    now everything is running nice, thx everyone
     
  4. Oscar Eriksson

    Oscar Eriksson SWE

    Joined:
    Sep 7, 2014
    Messages:
    10
    What Version are you using? TFS 1.0?
     
  5. Oscar Eriksson

    Oscar Eriksson SWE

    Joined:
    Sep 7, 2014
    Messages:
    10
    Same question to you.. what version are you using?
     
  6. davidmemo

    davidmemo Member

    Joined:
    Mar 28, 2011
    Messages:
    37
    emm theforgottenserver 1.0 but i solved this problem thanks :D
     
  7. Mister mox

    Mister mox New Member

    Joined:
    Mar 3, 2010
    Messages:
    6
    tfs 1.0 to, using the code that I said everything is ok, thx for the code ^^
     
  8. login12

    login12 void newbie scripter()

    Joined:
    Feb 26, 2011
    Messages:
    139
    I have this is error..

    Lua Script Error: [GlobalEvent Interface]
    data/globalevents/scripts/zombie_think.lua:eek:nThink
    data/globalevents/scripts/zombie_think.lua:4: attempt to compare nil with number
    stack traceback:
    [C]: ?
    data/globalevents/scripts/zombie_think.lua:4: in function <data/globalevents/scripts/zombie_think.lua:3>
    [Error - GlobalEvents::think] Failed to execute event: zombie

    Lua Script Error: [GlobalEvent Interface]
    data/globalevents/scripts/zombie_think.lua:eek:nThink
    data/globalevents/scripts/zombie_think.lua:4: attempt to compare nil with number
    stack traceback:
    [C]: ?
    data/globalevents/scripts/zombie_think.lua:4: in function <data/globalevents/scripts/zombie_think.lua:3>
    [Error - GlobalEvents::think] Failed to execute event: zombie
     
    Oravake likes this.
  9. Oravake

    Oravake New Member

    Joined:
    Nov 22, 2014
    Messages:
    4
    I got the same problem @Printer. What could cause this ?
     
  10. Printer

    Printer if Printer then print("LUA") end Premium User

    Joined:
    Dec 27, 2009
    Messages:
    5,556
    I will make a new Zombie Event. Even more optimized, more features and etc.. You can also suggest what you want :D
     
    Codinablack, Oravake and Evil Puncker like this.
  11. Oravake

    Oravake New Member

    Joined:
    Nov 22, 2014
    Messages:
    4
    What can I say, you are the golden star of Otland :D
     
    Codinablack likes this.
  12. Colors

    Colors

    Joined:
    Mar 22, 2013
    Messages:
    904
    If I remember correctly this system had a -big- bug/exploit in TFS 1.0, The player would be able to win every single zombie event with it... I might test it later.
     
  13. Printer

    Printer if Printer then print("LUA") end Premium User

    Joined:
    Dec 27, 2009
    Messages:
    5,556
    Cheers mate :p
    If you find out how, please tell me :p
     
  14. Alek

    Alek ᵀᴴᴱ ᴼᴿᴵᴳᴵᴻᴬᴸs

    Joined:
    Feb 15, 2008
    Messages:
    697
    Code:
    Lua Script Error: [TalkAction Interface]
    data/talkactions/scripts/zombie_join.lua:onSay
    data/talkactions/scripts/zombie_join.lua:11: attempt to compare nil with number
    stack traceback:
            [C]: ?
            data/talkactions/scripts/zombie_join.lua:11: in function <data/talkactio
    ns/scripts/zombie_join.lua:3>
     
  15. povedijah

    povedijah Member

    Joined:
    Jan 11, 2010
    Messages:
    91
    Thank your printer, thats a good works, after some errors little, for a missing functions, i get it on gitbub added to global.lua and working 100% , you do a perfect work bro, i see all of your scripts and you do it very good, im expected for your pet system , See more of your scripts! thanks!:)

    TFS : 1.0
     
  16. Tropix

    Tropix Like a BAuZZ

    Joined:
    Jan 6, 2009
    Messages:
    116
    Can you make it workable for 0.3.6tfs?
     
  17. Lordaeron

    Lordaeron Member

    Joined:
    Mar 15, 2014
    Messages:
    106
    Hm does it work with latest tfs?
     
  18. douglasscherner

    douglasscherner New Member

    Joined:
    Aug 15, 2014
    Messages:
    10
    What is the correct the first post or of the comment?
     
  19. douglasscherner

    douglasscherner New Member

    Joined:
    Aug 15, 2014
    Messages:
    10
    Sorry. second part
     
  20. darkjav

    darkjav Senior Developer

    Joined:
    Apr 29, 2008
    Messages:
    179
    Hello, i have this problem:

    Code:
    Lua Script Error: [CreatureScript Interface]
    data/creaturescripts/scripts/zombie_death.lua:eek:nDeath
    data/creaturescripts/scripts/zombie_death.lua:5: attempt to index local 'monster' (a nil value)
    stack traceback:
            [C]: in function '__index'
            data/creaturescripts/scripts/zombie_death.lua:5: in function <data/creaturescripts/scripts/zombie_death.lua:3>
    My zombie_death.lua is:

    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)
                    local reward = winner:addItem(zeReward, 1)
                   
                    if trophy then
                        trophy:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, '['.. winner:getName() ..'] has won the Zombie Event.')
                    end
                     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
    Thanks for help.
     

Share This Page