Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local round_status = 0
- local activeRound = 1
- local t = 0
- local interval = 2
- local zombieCount = 3
- local isSpawning = false
- local spawnPos = {
- Vector(-100.734840,-1274.259888,-79.968750),
- Vector(-1803.711670,-1491.910645,-79.968750),
- Vector(-1890.346436,975.450745,-79.392471)
- }
- util.AddNetworkString("UpdateRoundStatus")
- function beginRound()
- round_status = 1
- updateClientRoundStatus()
- isSpawning = true
- end
- function endRound()
- round_status = 0
- updateClientRoundStatus()
- end
- function getRoundStatus()
- return round_status
- end
- local mextWaveWaiting = false
- function getBestSpawn()
- local bestSpawn = Vector(0,0,0)
- local closestDistance = 0
- if table.Count(ents.FindByClass("npc_zombie")) == 0 then
- return spawnPos[math.random(1,table.Count(spawnPos)]
- end
- for k, v in pairs(spawnPos) do
- local closestZombieDistance = 1000000
- for a, b in pairs(ents.FindByClass("npc_zomebie")) do
- if b:GetPos():Distance(v) < closestZombieDistance then
- closestZombieDistance = b:GetPos():Distance(v)
- end
- end
- end
- if closestZombieDistance > closestDistance then
- closestDistance = closestZombieDistance
- bestSpawn = v
- end
- end
- hook.Add("Think", "WaveThink", function()
- if round_status == 1 and isSpawning == true then
- nextWaveWaiting = false
- if t < CurTime() then
- t = CurTime() + interval
- player.GetAll()[1]:ChatPrint("A zombie has spawned!")
- local temp = ents.Create("npc_zombie")
- temp:SetPos(spawnPos)
- temp:Spawn()
- temp:SetHealth(50 * activeRound)
- zombieCount = zombieCount - 1
- if zombieCount <= 0 then
- isSpawning = false
- end
- end
- end
- if round_status == 1 and isSpawning == false and table.Count(ents.FindByClass("npc_zombie")) == 0 and nextWaveWaiting == false then
- activeRound = activeRound + 1
- nextWaveWaiting = true
- timer.Simple(10,function()
- zombieCount = 3 * activeRound
- isSpawning = true
- end)
- end
- end)
- function updateClientRoundStatus()
- net.Start("UpdateRoundStatus")
- net.WriteInt(round_status, 4)
- net.Broadcast()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement