PVP zones or Safe zone

Hi all. I want to do In gm_bigcity where player spawn there is kill procetion or people can’t kill in spawn zone Like Pvp Zones.
Please help.

Here you go :


local function PlayerSpawnProtection(victim, attacker)
	local BoxCorner = Vector(0,0,0)
	local OppositeCorner = Vector(1000,1000,-1000)
	local PlayersInArea = ents.FindInBox(BoxCorner,OppositeCorner)
	return not table.HasValue(PlayersInArea,victim)
end
 hook.Add( "PlayerShouldTakeDamage", "PlayerSpawnProtection", PlayerSpawnProtection)

Find the right positions to use with the getpos console command.

I am not good at lua So can you do the folder and lua file too ? :expressionless:

No. That’s just being lazy. A lua file is a normal text file (Except you save it as .lua instead of .txt) and you can just place the file in lua/autorun/server.

Can you say where x y z ? or how to set ?

To the first: No, he can’t. He doesn’t know the positions on your map or the specific areas you want marked. You do.

The second, he already answered:

Use the getpos console command to get the x y z coordinates for the corners of the box that you want to make and insert them into the code snippet he gave you.

Stand on the corner, type getpos in console, stand on other corner, type getpos in console, profit.

EDIT: Guess that was misleading… since there’s a z vector, you’d need to make a 3D box, which means noclipping into the air, not just standing on the ground. Donkie wins. :v:


local function PlayerSpawnProtection(victim, attacker)
	local BoxCorner = Vector(1429.562134 -3981.804932 -11071.968750)
	local OppositeCorner = Vector(-3256.810547 1424.031250 -11071.968750)
	local PlayersInArea = ents.FindInBox(BoxCorner,OppositeCorner)
	return not table.HasValue(PlayersInArea,victim)
end
 hook.Add( "PlayerShouldTakeDamage", "PlayerSpawnProtection", PlayerSpawnProtection)

And people can kill people’s… Why it’s not working ?

Because you made a flat box, both Z values are the same, whereas you are to make a 3D box. Bottomcorner for one, Topcorner for the other.

Changed Z but it’s not working :\

for one you have missed the commas between the numbers, here, let me fix that for you c:
also rounded the messy numbers

You should make an addon that gets the box(hud drawline) for you and then all you have to do is change the values so you can see how tall and wide the box is.