Ir para conteúdo

Featured Replies

Postado

alguem ai tem algum zombie event para tfs 1.0 10.41
 
Consegui um zombie event porem da um erro no distro...
 

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

Zombie Event


\data\globalevents\scripts\zombie_think.lua
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

\data\creaturescripts\scripts\zombie_death.lua



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

\data\monster\Zombie_Event.xml



<?xml version="1.0" encoding="UTF-8"?>
<monster name="Zombie" nameDescription="a zombie" race="undead" experience="0" speed="100" manacost="0">
    <health now="500" max="500"/>
    <look type="311" corpse="0"/>
    <targetchange interval="4000" chance="10"/>
    <strategy attack="100" defense="0"/>
    <flags>
        <flag summonable="0"/>
        <flag attackable="1"/>
        <flag hostile="1"/>
        <flag illusionable="0"/>
        <flag convinceable="0"/>
        <flag pushable="0"/>
        <flag canpushitems="1"/>
        <flag canpushcreatures="1"/>
        <flag targetdistance="1"/>
        <flag staticattack="90"/>
        <flag runonhealth="0"/>
    </flags>
    <attacks>
        <attack name="melee" interval="2000" skill="9999999" attack="9999999"/>
    </attacks>
    <defenses armor="15" defense="15"/>
    <elements>
        <element firePercent="50"/>
    </elements>
    <immunities>
        <immunity death="1"/>
        <immunity energy="1"/>
        <immunity ice="1"/>
        <immunity earth="1"/>
        <immunity drown="1"/>
        <immunity drunk="1"/>
        <immunity lifedrain="1"/>
        <immunity paralyze="1"/>
    </immunities>
    <voices interval="5000" chance="10">
        <voice sentence="Mst.... klll...."/>
        <voice sentence="Whrrrr... ssss.... mmm.... grrrrl"/>
        <voice sentence="Dnnnt... cmmm... clsrrr...."/>
        <voice sentence="Httt.... hmnnsss..."/>
    </voices>
    <script>
            <event name="ZE_Mon_Death"/>
        </script>
</monster>

\data\zombie_system.lua



-- 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 = 200 --Player joined event count

-- Players Variables
zeJoinStorage = 1000 --player join storage
zeMinPlayers = 1 --min players needed when time runout
zeMaxPlayers = 30 --max players to join
zeTrophy = 7369 --trophy itemid
zeZombieCountGlobalStorage = 201 --Zombie spawned Count

-- Other Variables
zeWaitMinutes = 5 --when event has opened, how long until it starts?
zeWaitingRoomPos = Position(32365, 29021, 7) --middle of waiting room
zeZombieArena = Position(16907, 11817, 8) --when even start where should player be teleported in the zombie arena?
zeArenaFromPosition = Position(16883, 11799, 8) --pos of top left corner
zeArenaToPosition = Position(16931, 11835, 8) --pos of bottom right corner
zeMiddleZombieArena = Position(16907, 11817, 8) --Middle pos of the arena
zeWaitingRoomRadiusX = 20 --depends how big the waiting room is 20sqm to x
zeWaitingRoomRadiusY = 20 --depends how big the waiting room is 20sqm to y
zeZombieArenaRadiusX = 50 --Depends how big the zombie arena is 50sqm to x
zeZombieArenaRadiusY = 50 --Depends how big the zombie arena is 50sqm to y
zeStartedGlobalStorage = 202 -- Value: 0 == false, 1 == true, 2 == started --State of the event
zeCreateTeleportPosition = Position(32360, 32239, 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

globalevents



<globalevent name="zombie" interval="300000000" script="zombie_think.lua"/>

creaturescripts



<event type="preparedeath" name="ZE_Death" script="zombie_death.lua"/>
<event type="death" name="ZE_Mon_Death" script="zombie_death.lua"/>

monsters



<monster name="Zombie" file="Zombie_Event.xml"/>


se alguem puder dar uma mãozinha eu agradeço!!!

Editado por lrickes (veja o histórico de edições)

  • Respostas 7
  • Visualizações 783
  • Created
  • Última resposta

Top Posters In This Topic

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo