Advertisement
hammond312

Untitled

Dec 22nd, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. 0) then
  2. table.insert(players, cid)
  3. end
  4. end-- CONFIG
  5. ZE_DEFAULT_NUMBER_OF_PLAYERS = 1
  6. ZE_ACCESS_TO_IGNORE_ARENA = 3
  7. -- POSITIONS
  8. ZE_blockEnterItemPosition = {x= 32391, y=31916, z=7}
  9. ZE_enterPosition = {x = 32129, y = 32242, z = 7}
  10. ZE_kickPosition = {x=32386, y=31913, z=7}
  11. ZE_spawnFromPosition = {x = 32135, y = 32241, z = 7}
  12. ZE_spawnToPosition = {x = 32134, y = 32237, z = 7}
  13. -- ITEM IDS
  14. ZE_blockEnterItemID = 2700
  15. -- STORAGES
  16. -- - player
  17. ZE_isOnZombieArea = 39970
  18. -- - global
  19. ZE_STATUS = 39970 -- =< 0 - off, 1 - waiting for players, 2 - is running
  20. ZE_PLAYERS_NUMBER = 39971
  21. ZE_ZOMBIES_TO_SPAWN = 39972
  22. ZE_ZOMBIES_SPAWNED = 39973
  23.  
  24. -- FUNCTION
  25.  
  26. function setZombiesEventPlayersLimit(value)
  27. doSetStorage(ZE_PLAYERS_NUMBER, value)
  28. end
  29.  
  30. function getZombiesEventPlayersLimit()
  31. return getStorage(ZE_PLAYERS_NUMBER)
  32. end
  33.  
  34. function addPlayerToZombiesArea(cid)
  35. doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
  36. doTeleportThing(cid, ZE_enterPosition, true)
  37. doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
  38. if(getPlayerAccess(cid) < ZE_ACCESS_TO_IGNORE_ARENA) then
  39. setPlayerZombiesEventStatus(cid, os.time())
  40. end
  41. end
  42.  
  43. function kickPlayerFromZombiesArea(cid)
  44. doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
  45. doTeleportThing(cid, ZE_kickPosition, true)
  46. doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
  47. setPlayerZombiesEventStatus(cid, 0)
  48. end
  49.  
  50. function getPlayerZombiesEventStatus(cid)
  51. return getCreatureStorage(cid, ZE_isOnZombieArea)
  52. end
  53.  
  54. function setPlayerZombiesEventStatus(cid, value)
  55. doCreatureSetStorage(cid, ZE_isOnZombieArea, value)
  56. end
  57.  
  58. function getZombiesEventPlayers()
  59. local players = {}
  60. for i, cid in pairs(getPlayersOnline()) do
  61. if(getPlayerZombiesEventStatus(cid) >
  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. print("spawning..")
  128. local ret = (type(doCreateMonster("Zombie_Event", {x=posx[lowest_i], y=posy[lowest_i], z=posz[lowest_i]}, true, true, true)) == 'number')
  129. if(ret) then
  130. addZombiesCount()
  131. end
  132. return ret
  133. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement