• Nlr code help
    2 replies, posted
Well my Nlr code isn't workin PERIOD nothing is happening I might be missing a hook I just don't know [CODE] function GM:PlayerDeath( victim, weapon, killer ) local deathpos = 0 if victim:IsPlayer() and killer:IsPlayer then if !victim.died then victim.deathpos = victim:GetPos() print("You have been slayed because you passed your nlr line come back in 5 mins") end end end timer.Create( "nlrtimer", 1, 500, function() local deathpos = 0 for k,v in pairs(player.GetAll()) do if v == playernlr then local deathpos2 = v:GetPos() if deathpos2:Distance(v.deathpos2) < 800 and v:Alive then ply:Kill() print("Sorry you have been slayed for nlring") end end end end) [/CODE]
Untested, but it should do something valuable. [CODE] function SetNLRZone( ply ) --Making a function for this because I said so. if SERVER then ply.deathpos = ply:GetPos() timer.Destroy(ply:EntIndex() .. "NLRTimer") -- We don't want a billion timers floating around. timer.Create(ply:EntIndex() .. "NLRTimer", 1, 300, function() -- 5 minutes is only 300 seconds. howdoimath.org if not IsValid(ply) then return end -- Because dead players are invalid. This'll spam errors unless we only run if the player is alive... I think. local playerpos = ply:GetPos() local targetpos = ply.deathpos -- Not sure if continually defining this is efficient, but I do what I want. if playerpos:Distance( targetpos ) < 800 && not ply.nlrimmune && ply:Alive() then -- nlrimmune is to make sure a player isn't continually spawn-killed for dying at a spawn point. ply:Kill() ply:ChatPrint("You got too close to your death zone, and have been slain! (Don't do it again or I'll cut you. (again.))") end end) end end hook.Add("PlayerDeath", "NLR.DeathZone", function( ply, inflictor, killer ) if not killer == ply then if killer:IsPlayer() then -- Only run the function if the killer was a player. Otherwise, why would we care? SetNLRZone( ply ) -- I've only ever ran functions like this with C#, so forgive me if this is incorrect. end timer.Destroy(ply:EntIndex() .. "nlrimmune") -- Simple timers cannot be stopped as far as I am aware. And we need to stop this end end) hook.Add("PlayerSpawn", "NLR.SpawnImmunity", function( ply ) if SERVER then ply.nlrimmune = true timer.Create(ply:EntIndex() .. "nlrimmune", 30, 1, function() -- Creating a timer here because we want to be able to end it. ply.nlrimmune = false end) end end) [/CODE] [editline]2nd November 2013[/editline] Why am I being rated dumb? I tested the code and it works exactly as intended?
I too was having issues with a NLR module/addon, and yours doesn't even seem to do anything xD I might be putting it in the wrong place 0.0 idk
Sorry, you need to Log In to post a reply to this thread.