So I am making a mod to a tool i like very much called NPC Spawn Plateform 2.2
I wanted to make it so the npcs the platform spawns only do so if a player is within 2000 units.
well it works, but it only works for me and it wont trigger for any other players.
PS. please note I have tried player.GetAll() and I have tried find in sphere ( find in sphere had odd broken results too )
here is the code: found in the init.lua of the platform entity of the spawn platformer.
function ENT:Think() if (self.Spawned < 0) then self.Spawned = 0 end if (self._WireSpawnedActive) then Wire_TriggerOutput(self, "OnNPCSpawned", 0); self._WireSpawnedActive = nil; end for k, v in pairs(ents.GetAll()) do // please note I have tried player.GetAll() and I have tried find in sphere ( find in sphere had odd broken results too ) if v:IsValid() and v:IsPlayer() then if(v:GetPos():Distance(self:GetPos()) < 2000) and self.Spawned < self.k_maximum and self.LastSpawn + self.k_delay < CurTime() then self:SpawnOne(); else return end end end end