Advertisement
Bkamahl

Full code

Sep 19th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. local round_status = 0
  2. local activeRound = 1
  3. local t = 0
  4. local interval = 2
  5. local zombieCount = 3
  6. local isSpawning = false
  7. local spawnPos = {
  8. Vector(-100.734840,-1274.259888,-79.968750),
  9. Vector(-1803.711670,-1491.910645,-79.968750),
  10. Vector(-1890.346436,975.450745,-79.392471)
  11. }
  12.  
  13. util.AddNetworkString("UpdateRoundStatus")
  14.  
  15. function beginRound()
  16. round_status = 1
  17. updateClientRoundStatus()
  18.  
  19. isSpawning = true
  20. end
  21.  
  22. function endRound()
  23. round_status = 0
  24. updateClientRoundStatus()
  25. end
  26.  
  27. function getRoundStatus()
  28. return round_status
  29. end
  30.  
  31. local mextWaveWaiting = false
  32.  
  33. function getBestSpawn()
  34. local bestSpawn = Vector(0,0,0)
  35. local closestDistance = 0
  36. if table.Count(ents.FindByClass("npc_zombie")) == 0 then
  37. return spawnPos[math.random(1,table.Count(spawnPos)]
  38. end
  39.  
  40. for k, v in pairs(spawnPos) do
  41. local closestZombieDistance = 1000000
  42. for a, b in pairs(ents.FindByClass("npc_zomebie")) do
  43. if b:GetPos():Distance(v) < closestZombieDistance then
  44. closestZombieDistance = b:GetPos():Distance(v)
  45. end
  46. end
  47. end
  48. if closestZombieDistance > closestDistance then
  49. closestDistance = closestZombieDistance
  50. bestSpawn = v
  51. end
  52. end
  53.  
  54. hook.Add("Think", "WaveThink", function()
  55. if round_status == 1 and isSpawning == true then
  56. nextWaveWaiting = false
  57. if t < CurTime() then
  58. t = CurTime() + interval
  59.  
  60. player.GetAll()[1]:ChatPrint("A zombie has spawned!")
  61. local temp = ents.Create("npc_zombie")
  62. temp:SetPos(spawnPos)
  63. temp:Spawn()
  64. temp:SetHealth(50 * activeRound)
  65.  
  66. zombieCount = zombieCount - 1
  67.  
  68. if zombieCount <= 0 then
  69. isSpawning = false
  70. end
  71. end
  72. end
  73. if round_status == 1 and isSpawning == false and table.Count(ents.FindByClass("npc_zombie")) == 0 and nextWaveWaiting == false then
  74. activeRound = activeRound + 1
  75. nextWaveWaiting = true
  76. timer.Simple(10,function()
  77. zombieCount = 3 * activeRound
  78. isSpawning = true
  79. end)
  80. end
  81. end)
  82.  
  83. function updateClientRoundStatus()
  84. net.Start("UpdateRoundStatus")
  85. net.WriteInt(round_status, 4)
  86. net.Broadcast()
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement