Guest User

Untitled

a guest
Nov 22nd, 2014
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 10.14 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <mod name="Zombie Event" version="1.00" author="kawon" contact="otland.net" enabled="yes">
  3. <description>
  4.     Scripts by Gatupojk
  5.     Mods by Kawon
  6. </description>
  7.  
  8. <globalevent name="zombieevent" time="15:42" event="buffer"><![CDATA[
  9. local config = {
  10.    playerCount = 2001, -- Global storage for counting the players left/entered in the event
  11.    zombieCount = 2002, -- Global storage for counting the zombies in the event
  12.    teleportActionId = 2000, -- Action id of the teleport needed for the movement script
  13.    teleportPosition = {x = 586, y = 932, z = 7, stackpos = 1}, -- Where the teleport will be created
  14.    teleportToPosition = {x = 634, y = 1038, z = 7}, -- Where the teleport will take you
  15.    teleportId = 1387, -- Id of the teleport
  16.    timeToStartEvent = 1, -- Minutes, after these minutes the teleport will be removed and the event will be declared started
  17.    timeBetweenSpawns = 20, -- Seconds between each spawn of zombie
  18.    zombieName = "Zombie", -- Name of the zombie that should be summoned
  19.    playersNeededToStartEvent = 2, -- Players needed before the zombies can spawn.
  20.  
  21.    -- Should be the same as in the creaturescript!
  22.    -- The zombies will spawn randomly inside this area
  23.    fromPosition = {x = 604, y = 1014, z = 7}, -- top left cornor of the playground
  24.    toPosition = {x = 664, y = 1065, z = 7}, -- bottom right cornor of the playground
  25. }
  26.  
  27. function onTimer()
  28.    local tp = doCreateTeleport(config.teleportId, config.teleportToPosition, config.teleportPosition)
  29.    doItemSetAttribute(tp, "aid", config.teleportActionId)
  30.    doBroadcastMessage("Zombie event starting in " .. config.timeToStartEvent .. " minutes! The teleport will be closed when the event start!", MESSAGE_STATUS_WARNING)
  31.    setGlobalStorageValue(config.playerCount, 0)
  32.    setGlobalStorageValue(config.zombieCount, 0)
  33.    addEvent(startEvent, config.timeToStartEvent * 1000 * 60)
  34.    print(getGlobalStorageValue(2001))
  35. end
  36.  
  37. function startEvent()
  38.    local get = getThingfromPos(config.teleportPosition)
  39.    if get.itemid == config.teleportId then
  40.        doRemoveItem(get.uid, 1)
  41.    end
  42.  
  43.    local fromp, top = config.fromPosition, config.toPosition
  44.  
  45.    if getGlobalStorageValue(config.playerCount) >= config.playersNeededToStartEvent then
  46.        addEvent(spawnZombie, config.timeBetweenSpawns * 1000)
  47.        doBroadcastMessage("Good luck in the zombie event people! The teleport has closed!", MESSAGE_STATUS_WARNING)
  48.      
  49.        for x = fromp.x, top.x do
  50.            for y = fromp.y, top.y do
  51.                for z = fromp.z, top.z do
  52.                    areapos = {x = x, y = y, z = z, stackpos = 253}
  53.                    getPlayers = getThingfromPos(areapos)
  54.                    if isPlayer(getPlayers.uid) then
  55.                        doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "The first zombie will spawn in " .. config.timeBetweenSpawns .. " seconds! Good luck!")
  56.                    end
  57.                end
  58.            end
  59.        end
  60.    else
  61.        doBroadcastMessage("The Zombie event could not start because of to few players participating.\n At least " .. config.playersNeededToStartEvent .. " players is needed!", MESSAGE_STATUS_WARNING)
  62.        for x = fromp.x, top.x do
  63.            for y = fromp.y, top.y do
  64.                for z = fromp.z, top.z do
  65.                    areapos = {x = x, y = y, z = z, stackpos = 253}
  66.                    getPlayers = getThingfromPos(areapos)
  67.                    if isPlayer(getPlayers.uid) then
  68.                        doTeleportThing(getPlayers.uid, getTownTemplePosition(getPlayerTown(getPlayers.uid)), false)
  69.                        doSendMagicEffect(getPlayerPosition(getPlayers.uid), CONST_ME_TELEPORT)
  70.                    end
  71.                end
  72.            end
  73.        end
  74.    end
  75. end
  76.  
  77. function spawnZombie()
  78.    if getGlobalStorageValue(config.playerCount) >= 2 then
  79.        pos = {x = math.random(config.fromPosition.x, config.toPosition.x), y = math.random(config.fromPosition.y, config.toPosition.y), z = math.random(config.fromPosition.z, config.toPosition.z)}
  80.        doSummonCreature(config.zombieName, pos)
  81.        doSendMagicEffect(pos, CONST_ME_MORTAREA)
  82.        setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
  83.        doBroadcastMessage("A zombie has spawned! There is currently " .. getGlobalStorageValue(config.zombieCount) .. " zombies in the zombie event!", MESSAGE_STATUS_CONSOLE_RED)
  84.        addEvent(spawnZombie, config.timeBetweenSpawns * 1000)
  85.    end
  86. end
  87. ]]></globalevent>
  88.  
  89. <movevent type="StepIn" actionid="3000" event="buffer"><![CDATA[
  90. local config = {
  91.    playerCount = 2001, -- Global storage for counting the players in the event
  92.    maxPlayers = 20 -- Max players who can participate
  93. }
  94.  
  95. function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
  96.    if getGlobalStorageValue(config.playerCount) < config.maxPlayers then
  97.        setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)+1)
  98.        if getGlobalStorageValue(config.playerCount) == config.maxPlayers then
  99.            doBroadcastMessage("The Zombie event is now full [" .. getGlobalStorageValue(config.playerCount) .. " players]! The event will soon start.")
  100.        else
  101.            doBroadcastMessage(getPlayerName(cid) .. " entered the Zombie event! Currently " .. getGlobalStorageValue(config.playerCount) .. " players have joined!", MESSAGE_STATUS_CONSOLE_RED)
  102.        end
  103.    else
  104.        addEvent(tpBack, 1000, cid, fromPosition)
  105.        doPlayerSendCancel(cid, "The event is full. There is already " .. config.maxPlayers .. " players participating in the quest.")
  106.        return false
  107.    end
  108.    print(getStorage(config.playerCount) .. " Players in the zombie event.")
  109.    return true
  110. end
  111.  
  112. function tpBack(cid, fromPosition)
  113.    doTeleportThing(cid, fromPosition, true)
  114.    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
  115. end
  116. ]]></movevent>
  117.  
  118. <event type="statschange" name="zombieevent" event="script"><![CDATA[
  119. local config = {
  120.    playerCount = 2001, -- Global storage for counting the players left/entered in the event
  121.  
  122.    goblet = 5805, -- id of the gold goblet you'll get when finishing the event.
  123.    rewards = {2195, 2152, 2160}, -- You will get this +  a gold goblet with your name on.
  124.    --        {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
  125.    moneyReward = {2160, 10, 1}, -- second collumn(count) 0 if you don't want money to be used. or a stackable item you want more than 1 of.
  126.  
  127.    -- Should be same as in the globalevent!
  128.    -- The zombies will spawn randomly inside this area
  129.    fromPosition = {x = 604, y = 1014, z = 7}, -- top left cornor of the playground
  130.    toPosition = {x = 664, y = 1065, z = 7} -- bottom right cornor of the playground
  131. }
  132.  
  133. function onStatsChange(cid, attacker, type, combat, value)
  134.    if isPlayer(cid) and isMonster(attacker) then
  135.        if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
  136.            if getGlobalStorageValue(config.playerCount) >= 2 then
  137.                doBroadcastMessage(getPlayerName(cid) .. " have been eated by Zombies!", MESSAGE_STATUS_CONSOLE_RED)
  138.                local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
  139.                doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
  140.                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
  141.                doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
  142.                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
  143.                setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)-1)
  144.            elseif getGlobalStorageValue(config.playerCount) == 1 then
  145.                if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
  146.                    doBroadcastMessage(getPlayerName(cid) .. " won the Zombie event! Congratulations!", MESSAGE_STATUS_WARNING)
  147.                    local goblet = doPlayerAddItem(cid, config.goblet, 1)
  148.                    doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")
  149.                    local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
  150.                    doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
  151.                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
  152.                    doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
  153.                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
  154.                    for _,items in ipairs(config.rewards) do
  155.                        doPlayerAddItem(cid, items, 1)
  156.                    end
  157.                    if config.moneyReward[3] == 1 then
  158.                        doPlayerAddItem(cid, config.moneyReward[1], config.moneyReward[2])
  159.                    end
  160.                end
  161.                      
  162.                for x = config.fromPosition.x, config.toPosition.x do
  163.                    for y = config.fromPosition.y, config.toPosition.y do
  164.                        for z = config.fromPosition.z, config.toPosition.z do
  165.                            areapos = {x = x, y = y, z = z, stackpos = 253}
  166.                            getMonsters = getThingfromPos(areapos)
  167.                            if isMonster(getMonsters.uid) then
  168.                                doRemoveCreature(getMonsters.uid)
  169.                            end
  170.                        end
  171.                    end
  172.                end
  173.            end
  174.            return false
  175.        end
  176.    end
  177.    return true
  178. end
  179. ]]></event>
  180.  
  181. <event type="login" name="zombieRegister" event="buffer"><![CDATA[
  182.    registerCreatureEvent(cid, "zombieevent")
  183. ]]></event>
  184.  
  185. </mod>
Advertisement
Add Comment
Please, Sign In to add comment