Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free! Click here to download the new Pastebin App for iOS.
Guest

Untitled

By: a guest on Feb 19th, 2012  |  syntax: Lua  |  size: 6.97 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse
This paste has a previous version, view the difference. Copied
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <mod name="Zombie Event" version="1.00" author="kawon" contact="otland.net" enabled="no">
  3. <description>
  4.         Scripts by Gatupojk
  5.         Mods by Kawon
  6. </description>
  7.  
  8. <globalevent name="zombieevent" interval="36000" event="script"><![CDATA[
  9. local config = {
  10.         zombieCount = 2002, -- Global storage for counting the zombies in the event
  11.        active = 4444,
  12.         timeToStartEvent = 1, -- Minutes, after these minutes the teleport will be removed and the event will be declared started
  13.         timeBetweenSpawns = 20, -- Seconds between each spawn of zombie
  14.         zombieName = "Zombie", -- Name of the zombie that should be summoned
  15.         playersNeededToStartEvent = 1, -- Players needed before the zombies can spawn.
  16.        
  17.         -- Should be the same as in the creaturescript!
  18.         -- The zombies will spawn randomly inside this area
  19.         fromPosition = {x = 73, y = 135, z = 9}, -- top left cornor of the playground
  20.         toPosition = {x = 78, y = 139, z = 9}, -- bottom right cornor of the playground
  21. }
  22.  
  23. function onThink()
  24.         doBroadcastMessage("Zombie event starting in " .. config.timeToStartEvent .. " minutes!!", MESSAGE_STATUS_WARNING)
  25.         setGlobalStorageValue(config.zombieCount, 0)
  26.         setGlobalStorageValue(config.active, 2)
  27.         addEvent(startEvent, config.timeToStartEvent * 1000 * 10)
  28.         print(getGlobalStorageValue(2001))
  29. end
  30.  
  31. function startEvent()  
  32.         local fromp, top = config.fromPosition, config.toPosition
  33.  
  34.         if getGlobalStorageValue(config.playerCount) >= config.playersNeededToStartEvent then
  35.                 addEvent(spawnZombie, config.timeBetweenSpawns * 1000)
  36.                 doBroadcastMessage("Good luck in the zombie event people! The teleport has closed!", MESSAGE_STATUS_WARNING)
  37.                
  38.                 for x = fromp.x, top.x do
  39.                         for y = fromp.y, top.y do
  40.                                 for z = fromp.z, top.z do
  41.                                         areapos = {x = x, y = y, z = z, stackpos = 253}
  42.                                         getPlayers = getThingfromPos(areapos)
  43.                                         if isPlayer(getPlayers.uid) then
  44.                                                 doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "The first zombie will spawn in " .. config.timeBetweenSpawns .. " seconds! Good luck!")
  45.                                         end
  46.                                 end
  47.                         end
  48.                 end
  49.         else
  50.                 doBroadcastMessage("The Zombie event could not start because of to few players participating.\n At least " .. config.playersNeededToStartEvent .. " players is needed!", MESSAGE_STATUS_WARNING)
  51.                 for x = fromp.x, top.x do
  52.                         for y = fromp.y, top.y do
  53.                                 for z = fromp.z, top.z do
  54.                                         areapos = {x = x, y = y, z = z, stackpos = 253}
  55.                                         getPlayers = getThingfromPos(areapos)
  56.                                         if isPlayer(getPlayers.uid) then
  57.                                                 doTeleportThing(getPlayers.uid, getTownTemplePosition(getPlayerTown(getPlayers.uid)), false)
  58.                                                 doSendMagicEffect(getPlayerPosition(getPlayers.uid), CONST_ME_TELEPORT)
  59.                                         end
  60.                                 end
  61.                         end
  62.                 end
  63.         end
  64. end
  65.  
  66. function spawnZombie()
  67.         if getGlobalStorageValue(config.playerCount) >= 2 then
  68.                 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)}
  69.                 doSummonCreature(config.zombieName, pos)
  70.                 doSendMagicEffect(pos, CONST_ME_MORTAREA)
  71.                 setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
  72.                 doBroadcastMessage("A zombie has spawned! There is currently " .. getGlobalStorageValue(config.zombieCount) .. " zombies in the zombie event!", MESSAGE_STATUS_CONSOLE_RED)
  73.                 addEvent(spawnZombie, config.timeBetweenSpawns * 1000)
  74.         end
  75. end
  76. ]]></globalevent>
  77.  
  78. <event type="statschange" name="zombieevent" event="script"><![CDATA[
  79. local config = {
  80.         playerCount = 3333, -- Global storage for counting the players left/entered in the event
  81.        
  82.         goblet = 5805, -- id of the gold goblet you'll get when finishing the event.
  83.         rewards = {2195, 2152, 2160}, -- You will get this +  a gold goblet with your name on.
  84.         --        {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
  85.         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.
  86.        
  87.         -- Should be same as in the globalevent!
  88.         -- The zombies will spawn randomly inside this area
  89.         fromPosition = {x = 73, y = 135, z = 9}, -- top left cornor of the playground
  90.         toPosition = {x = 78, y = 139, z = 9}, -- bottom right cornor of the playground
  91. }
  92.  
  93. function onStatsChange(cid, attacker, type, combat, value)
  94.         if isPlayer(cid) and isMonster(attacker) then
  95.                 if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
  96.                         if getGlobalStorageValue(config.playerCount) >= 2 then
  97.                                 doBroadcastMessage(getPlayerName(cid) .. " have been eated by Zombies!", MESSAGE_STATUS_CONSOLE_RED)
  98.                                 local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
  99.                                 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")..".")
  100.                                 doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
  101.                                 doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
  102.                                 doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
  103.                                 setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)-1)
  104.                         elseif getGlobalStorageValue(config.playerCount) == 1 then
  105.                                 if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
  106.                                         doBroadcastMessage(getPlayerName(cid) .. " won the Zombie event! Congratulations!", MESSAGE_STATUS_WARNING)
  107.                                         local goblet = doPlayerAddItem(cid, config.goblet, 1)
  108.                                         doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")
  109.                                         local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
  110.                                         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")..".")
  111.                                         doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
  112.                                         doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
  113.                                         doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
  114.                                         for _,items in ipairs(config.rewards) do
  115.                                                 doPlayerAddItem(cid, items, 1)
  116.                                         end
  117.                                         if config.moneyReward[3] == 1 then
  118.                                                 doPlayerAddItem(cid, config.moneyReward[1], config.moneyReward[2])
  119.                                         end
  120.                                 end
  121.                                                
  122.                                 for x = config.fromPosition.x, config.toPosition.x do
  123.                                         for y = config.fromPosition.y, config.toPosition.y do
  124.                                                 for z = config.fromPosition.z, config.toPosition.z do
  125.                                                         areapos = {x = x, y = y, z = z, stackpos = 253}
  126.                                                         getMonsters = getThingfromPos(areapos)
  127.                                                         if isMonster(getMonsters.uid) then
  128.                                                                 doRemoveCreature(getMonsters.uid)
  129.                                                         end
  130.                                                 end
  131.                                         end
  132.                                 end
  133.                         end
  134.                         return false
  135.                 end
  136.         end
  137.         return true
  138. end
  139. ]]></event>
  140.  
  141. <event type="login" name="zombieRegister" event="buffer"><![CDATA[
  142.         registerCreatureEvent(cid, "zombieevent")
  143. ]]></event>
  144.  
  145. </mod>