Advertisement
hammond312

Untitled

Dec 20th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. -- CONFIG
  2. ZE_DEFAULT_NUMBER_OF_PLAYERS = 1
  3. ZE_ACCESS_TO_IGNORE_ARENA = 3
  4. -- POSITIONS
  5. ZE_blockEnterItemPosition = {x= 32391, y=31916, z=7}
  6. ZE_enterPosition = {x = 32129, y = 32242, z = 7}
  7. ZE_kickPosition = {x=32386, y=31913, z=7}
  8. ZE_spawnFromPosition = {x = 32113, y = 32230, z = 7}
  9. ZE_spawnToPosition = {x = 32147, y = 32253, z = 7}
  10. -- ITEM IDS
  11. ZE_blockEnterItemID = 2700
  12. -- STORAGES
  13. -- - player
  14. ZE_isOnZombieArea = 39970
  15. -- - global
  16. ZE_STATUS = 39970 -- =< 0 - off, 1 - waiting for players, 2 - is running
  17. ZE_PLAYERS_NUMBER = 39971
  18. ZE_ZOMBIES_TO_SPAWN = 39972
  19. ZE_ZOMBIES_SPAWNED = 39973
  20.  
  21. -- FUNCTION
  22.  
  23. function setZombiesEventPlayersLimit(value)
  24. doSetStorage(ZE_PLAYERS_NUMBER, value)
  25. end
  26.  
  27. function getZombiesEventPlayersLimit()
  28. return getStorage(ZE_PLAYERS_NUMBER)
  29. end
  30.  
  31. function addPlayerToZombiesArea(cid)
  32. doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
  33. doTeleportThing(cid, ZE_enterPosition, true)
  34. doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
  35. if(getPlayerAccess(cid) < ZE_ACCESS_TO_IGNORE_ARENA) then
  36. setPlayerZombiesEventStatus(cid, os.time())
  37. end
  38. end
  39.  
  40. function kickPlayerFromZombiesArea(cid)
  41. doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
  42. doTeleportThing(cid, ZE_kickPosition, true)
  43. doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
  44. setPlayerZombiesEventStatus(cid, 0)
  45. end
  46.  
  47. function getPlayerZombiesEventStatus(cid)
  48. return getCreatureStorage(cid, ZE_isOnZombieArea)
  49. end
  50.  
  51. function setPlayerZombiesEventStatus(cid, value)
  52. doCreatureSetStorage(cid, ZE_isOnZombieArea, value)
  53. end
  54.  
  55. function getZombiesEventPlayers()
  56. local players = {}
  57. for i, cid in pairs(getPlayersOnline()) do
  58. if(getPlayerZombiesEventStatus(cid) > 0) then
  59. table.insert(players, cid)
  60. end
  61. end
  62. return players
  63. end
  64.  
  65. function getZombiesCount()
  66. return getStorage(ZE_ZOMBIES_SPAWNED)
  67. end
  68.  
  69. function addZombiesCount()
  70. doSetStorage(ZE_ZOMBIES_SPAWNED, getStorage(ZE_ZOMBIES_SPAWNED)+1)
  71. end
  72.  
  73. function resetZombiesCount()
  74. doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
  75. end
  76.  
  77. function getZombiesToSpawnCount()
  78. return getStorage(ZE_ZOMBIES_TO_SPAWN)
  79. end
  80.  
  81. function setZombiesToSpawnCount(count)
  82. doSetStorage(ZE_ZOMBIES_TO_SPAWN, count)
  83. end
  84.  
  85. function addZombiesEventBlockEnterPosition()
  86. if(getTileItemById(ZE_blockEnterItemPosition, ZE_blockEnterItemID).uid == 0) then
  87. doCreateItem(ZE_blockEnterItemID, 1, ZE_blockEnterItemPosition)
  88. end
  89. end
  90.  
  91. function removeZombiesEventBlockEnterPosition()
  92. local item = getTileItemById(ZE_blockEnterItemPosition, ZE_blockEnterItemID)
  93. if(item.uid ~= 0) then
  94. doRemoveItem(item.uid)
  95. end
  96. end
  97.  
  98. function spawnNewZombie()
  99. local posx = {}
  100. local posy = {}
  101. local posz = {}
  102. local pir = {}
  103. for i=1, 5 do
  104. local posx_tmp = math.random(ZE_spawnFromPosition.x ,ZE_spawnToPosition.x)
  105. local posy_tmp = math.random(ZE_spawnFromPosition.y ,ZE_spawnToPosition.y)
  106. local posz_tmp = math.random(ZE_spawnFromPosition.z ,ZE_spawnToPosition.z)
  107. local pir_tmp = 0
  108. local spec = getSpectators({x=posx_tmp, y=posy_tmp, z=posz_tmp}, 3, 3, true)
  109. if(spec and #spec > 0) then
  110. for z, pid in pairs(spec) do
  111. if(isPlayer(pid)) then
  112. pir_tmp = pir_tmp + 1
  113. end
  114. end
  115. end
  116. posx[i] = posx_tmp
  117. posy[i] = posy_tmp
  118. posz[i] = posz_tmp
  119. pir[i] = pir_tmp
  120. end
  121. local lowest_i = 1
  122. for i=2, 5 do
  123. if(pir[i] < pir[lowest_i]) then
  124. lowest_i = i
  125. end
  126. end
  127. local ret = (type(doCreateMonster("Snorlax", {x=posx[lowest_i], y=posy[lowest_i], z=posz[lowest_i]}, true, true, true)) == 'number')
  128. if(ret) then
  129. addZombiesCount()
  130. end
  131. return ret
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement