[Question] Auto Slay based on previous map coordinates


Objective: Create a script to auto slay a player if they enter an area they were previously within a predetermined time limit.

Use: This would be used for Dark RP and auto NLR enforcement in case admins aren’t available.

I have done some lua scripting in the past and I have kind of whiteboarded this thing out but before I started diving into it I wanted to ask the more experienced coders if it was possible. If not then I won’t invest my time in it.

Thank you

Objective: Get this thread moved to requests section.

Use: Get higher quality replies.

He only wanted to know if it was possible, and probably a nudge of how to do it. lrn2read

Most things are possible with lua, it just depends on how advanced you want to go. Either you could do a few traces and see if the players enter that same “room”, or you could just do a findInSphere. But it got its flaws, what happens if a guy were killed just at spawn by some randomer? Then he will just die over and over again.

you wil just have to create a more advanced system where it checks to make sure you not in spawn and that it makes sure it wasent a rdm.

A way you could get around it randomly killing you when you enter the area is by doing something like what battlefield does where if you go in the restricted zone a countdown appears then you die so it give them a chance to get out

[lua]local NLRLocs = {}
local NLRWarns = {}
local NLRReset = {}
hook.Add( “PlayerDeath”, “NLRSet”, function(ply, wep, killer)
local _ID = ply:SteamID()
NLRLocs[_ID] = ply:GetPos()
NLRReset[_ID] = CurTime()+300

function CheckLocation()
for k,v in pairs(player.GetAll()) do
if v:GetPos():Distance(NLRLocs[v:SteamID()]) <= 500 then
if NLRWarns[v:SteamID()] == 1 then
if NLRReset[v:SteamID()] >= CurTime() then
NLRWarns[v:SteamID()] = 0
NLRWarns[v:SteamID()] = 0
NLRWarns[v:SteamID()] = 1
v:PrintMessage( HUD_PRINTCENTER, “You are entering your NLR area, leave this area for 5 minutes or be slayed”)
timer.Simple(10, function() CheckLocation() end))

timer.Simple(10, function() CheckLocation() end))

That is probably not going to work but its worth a try.

Your comparing everyone’s distance in the server to the player who has just died. Not only that if anyone in the server is further then 500 away they will get the message you are entering your NLR area and checking every 10 seconds is to much, should be more like 2.

You never defined the value so if they get into the area before this is run it will throw a nill value.

Im pretty sure thats not how a timer.Simple works from what I remember you just put the function name not function()?? then the function name,
a timer.Create() which just runs forever would work better I think

The tabbing also seems abit strange, trying to read this is quite confusing

I may have read this wrong and rate my dumb if I have but skimming over it, this seems like what will happen