Disallowing props being spawned where spawn is?

How would I go about not allowing people to make props near the spawn area? Thanks.

Add a function to these hooks:

Then in the function check if they are inside the spawn area and return false if they are.

I made a function for checking if they are inside a vector box, but it could probably be more efficient if anyone wants to improve it:

function inrange( v, v2, v3 )
	local minV = Vector()
	local maxV = Vector()
	if v2.x < v3.x then
		minV.x = v2.x
		maxV.x = v3.x
		minV.x = v3.x
		maxV.x = v2.x
	if v2.y < v3.y then
		minV.y = v2.y
		maxV.y = v3.y
		minV.y = v3.y
		maxV.y = v2.y
	if v2.z < v3.z then
		minV.z = v2.z
		maxV.z = v3.z
		minV.z = v3.z
		maxV.z = v2.z
	if v.x > minV.x and v.x < maxV.x and v.y > minV.y and v.y < maxV.y and v.z > minV.z and v.z < maxV.z then
		return true
		return false

Basically, use it as this:

inrange( The player’s position, one corner of the box, the other corner of the box)
ex: inrange( ply:GetPos(), v1, v2 )

If the spawn is a round area you could just check the distance from the center.

Feel free to ask more questions if something is unclear :slight_smile:

or simply **[Ents.FindInBox


The problem with that is that it doesn’t return the LocalPlayer() if run clientside in my testing. This makes prediction harder, but I guess it could be easy to just write another batch of code using LocalPlayer() instead for the client only. I used that function for other code as well, so that’s why I needed it. Guess I overcomplicated it though.

Yeah, but this pretty much solves the OP’s problem. Check if there are entities in the “spawning box” (or sphere if need be) and remove them.

Yeah, I didn’t think of that when I posted the first one.

You could just use Distance with the spawn coordinates and the object being spawned.

That gives you a sphere; what if the spawn is a box?