diff options
Diffstat (limited to 'gamemode/init.lua')
| -rw-r--r-- | gamemode/init.lua | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gamemode/init.lua b/gamemode/init.lua index 5a5c72a..40587fd 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -788,6 +788,13 @@ function GM:GetZombieClass() end function GM:NPCRespawnThink() + --Pick a random player, sort spawns based on where they are + local allplayers = player.GetAll() + local rngplayer = allplayers[math.random(#allplayers)] + --Randomize our spawn list based on the palyer we chose + GAMEMODE.NPCSpawns = table.sort(GAMEMODE.NPCSpawns, function(a,b) + return a:GetPos():Distance(rngplayer:GetPos()) < b:GetPos():Distance(rngplayer:GetPos()) + end) for k,v in pairs( ( GAMEMODE.NPCSpawns or {} ) ) do |
