How can I freeze or kill other players in a radius of x



I’m trying to find out how to make a script that freeze’s or kills other players in a radius of x from GetPlayerPed(-1)

I have the freeze and kill part done but I don’t know how to make the radius thing. I tried looking at the LocalChat script to get some inspiration.

function isPlayerInRangeOfPoint(player,x,y,z,range)
   local px,py,pz=GetElementPosition(player)
   return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range

I think I’ve seen a server admin doing it on his server but instead of freezing players he deleted cars in a area of 20 meter radius and could just walk around.

Where should one start?


Loop through all players check their distance according to your point. If it’s closer then x kill them.

That’s a rough explanation


Can’t you share a small code example?

How would I call isPlayerInRangeOfPoint or should I even use that method?
If a include it in client_side and try to call it with GetPlayer(-1) it code breaks.


@kanersps How do U develop stuff? Is there a way to not close the server down each time -> delete cache -> restart server -> start game. Is there a way to avoid this and debug directly in-game?


Can I use IsPlayerInArea instead? And where do I put this function. client or server? Because I still keep getting code fail when I use either one. And do I have to loop the players if I call it with a explicit player ID?




@COndor You can only run these functions on the client. Just loop through all the players and check their XYZ coords to your own ones.