Guest User

Untitled

a guest
Apr 26th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.48 KB | None | 0 0
  1. function loseOnZombieArena(cid)
  2.     kickPlayerFromZombiesArea(cid)
  3.     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "BOOM! You are dead.")
  4.     local players = getZombiesEventPlayers()
  5.      
  6.     if(#players <= 1) then
  7.         local winner = players[1]
  8.           if(winner) then
  9.             local ITEM = doPlayerAddItem(winner, 5805, 1)
  10.             doPlayerAddItem(winner, 2160, 400)
  11.             doSetItemAttribute(ITEM, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")
  12.             doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "You won zombies arena event.")
  13.             doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " seconds of fight " .. getCreatureName(winner) .. " won Zombie Arena Event in game versus " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies!")
  14.             kickPlayerFromZombiesArea(winner)
  15.                 else
  16.             doBroadcastMessage("Zombie arena event finished! No one win?!?!?! WTF!")
  17.           end
  18.     doSetStorage(ZE_STATUS, 0)
  19.     doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
  20.     doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
  21.     doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
  22.  
  23.     local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1
  24.     local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1
  25.     local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}
  26.  
  27.         for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do
  28.            centerPos.z = z
  29.              for i, uid in pairs(getSpectators(centerPos, width, height, false)) do
  30.                 if(isMonster(uid)) then
  31.                    doRemoveCreature(uid)
  32.                 end
  33.             end
  34.         end
  35.     end
  36. end
  37.  
  38. function onStatsChange(target, cid, changetype, combat, value)
  39.  
  40.     if isMonster(cid) and getCreatureName(cid) == "Zombie Event" or isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target) then
  41.         doCreatureAddHealth(target, getCreatureMaxHealth(target))
  42.         loseOnZombieArena(target)
  43.     return false
  44.     end
  45.  
  46.     return true
  47. end
Advertisement
Add Comment
Please, Sign In to add comment