• [WIP] New Life Rule (simple, efficient, configurable)
    35 replies, posted
[b] New Life Rule is an addon for Garry's Mod.[/b] [b] Features [/b] [i] - Tons of commands to configure it the way you want - efficient, won't take a minute to do everything - spawn protection, if you die at spawn and respawn, you'll still have time to get away.[/i] [b] Commands nlr_enabled 1/0 - enables/disables the New Life Rule addon. nlr_wait - the amount of time to wait before New Life Rule stops and you can go back nlr_warnings - the amount of warnings until you get a ban (time configurable) nlr_bantime - if you reach the amount of warnings to get a ban, this will decide how long the ban is for nlr_spawnprotection 1/0 - enables/disables the spawn protection nlr_spawnprotection_time - if spawnprotection is enabled, this will decide how long its on for[/b] [i]What does it do?[/i] [b]If you die by a player, New Life Rule starts. This will detect if you go back to your death position, if you do then it will slay you. If you break all the warnings then you will get a ban (time depending on nlr_bantime)[/b] [i]So is there any commands?[/i] [b]Many, six to be exact[/b] [i]So this all works?[/i] [b]Although it works, it is still a work in progress. Please report any bugs.[/b] [i]So that's it? What now?[/i] [b] Well, if you want, you can download the addon and then install it by placing it to your addons folder[/b] [b]Download: garrysmod.org: [url]http://www.garrysmod.org/downloads/?a=view&id=133532[/url] workshop: [url]http://steamcommunity.com/sharedfiles/filedetails/?id=125866322[/url] [/b] [b] Any problems tell me! [/b] [b]All I ask is that you don't say you made it, and give me credit![/b]
Hm, I can't get it to work. Tried using garrys mod and workshop. I dont see any errors, and it seems to be loading it okay. There is just not any command called "nlr_enabled 1".
try putting rcon before it
[QUOTE=Sam7100;39523910]Hm, I can't get it to work. Tried using garrys mod and workshop. I dont see any errors, and it seems to be loading it okay. There is just not any command called "nlr_enabled 1".[/QUOTE] put rcon before it. it's using ConVars in the serverside file
That went a little better. Stil no NLR reminder, but atleast it doesen't say anything about unknown command.
Is it really necessary for such a little script to have own thread ?
Looks interesting, I'll wait and see if anyone gets it to work before I try it out.
Hm, i still don't have any luck on getting it to work.
[QUOTE=Sam7100;39526725]Hm, i still don't have any luck on getting it to work.[/QUOTE] You need to install it to addons, then use rcon and set nlr_enabled to 1 if it's at 0. If that doesn't work, keep trying. It works for me and everyone else.
do admins can lets say bypass is? in case they need to administrate?
Also, the NLR_Wait doesnt seem to work. I have no problem entering the command but it never stops slaying people when they go back no matter how long they wait
[QUOTE=Ferin Sha;39563704]Also, the NLR_Wait doesnt seem to work. I have no problem entering the command but it never stops slaying people when they go back no matter how long they wait[/QUOTE] not sure. If it takes ages to end (the nlr) then lower it down [quote=Chacky]do admins can lets say bypass is? in case they need to administrate?[/quote] Never thought of that
Yes, admins should have the power to administrate themselves no wait times so they can break NLR. Great idea! I applaud you.
[LUA]local NLR = {} NLR.Players = {} CreateConVar("NLR_Wait", 500, {FCVAR_REPLICATED, FCVAR_SERVER_CAN_EXECUTE}) function NLR.Notify(Filter, Type, Length, Message) umsg.Start("_Notify", Filter) umsg.String(Message) umsg.Short(Type) umsg.Long(Length) umsg.End() end function NLR.Tick() for Player, Info in pairs(NLR.Players) do if IsValid(Player) then if Info[1] >= CurTime() then if Player:GetPos():Distance(Info[2]) <= 700 && Player:Alive() && Info[4] && Info[2]:Distance(Info[4]) >= 2500 && Info[5] then if !Info[6] then local Admins = {} for k,v in pairs(player.GetAll()) do if v:IsAdmin() then table.insert(Admins, v) end end NLR.Notify(Admins, 0,4, Player:Nick() .. " entered an NLR zone with " .. math.floor(Info[1] - CurTime()) .. " seconds left.") NLR.Notify(Player,0,4, "Please leave this zone, because you are under NLR.") Info[6] = 0 else if not timer.Exists("NLR_" .. Player:UserID()) && Info[6] then timer.Create("NLR_" .. Player:UserID(), 1, 10, function() if IsValid(Player) then if Player:GetPos():Distance(Info[2]) <= 500 then Info[6] = Info[6] + 1 else Info[6] = nil NLR.Notify(Player,0,4, "Thank you for abiding by the rules.") timer.Destroy("NLR_" ..Player:UserID()) return end end if Info[6] >= 10 then NLR.Notify(Player,0,4, "You have been forcefully moved out of the area, please follow New Life Rule.") Player:Freeze(true) timer.Simple(1, function() Player:Freeze(false) end) Player:SetPos(Info[5]) Info[6] = nil timer.Destroy("NLR_" ..Player:UserID()) return end end) end end elseif Info[6] && Player:GetPos():Distance(Info[2]) >= 500 then local Admins = {} for k,v in pairs(player.GetAll()) do if v:IsAdmin() then table.insert(Admins, v) end end NLR.Notify(Admins, 0,4, Player:Nick() .. " exited an NLR zone with " .. math.floor(Info[1] - CurTime()) .. " seconds left.") Info[6] = nil else Info[5] = Player:GetPos() end else NLR.Notify(Player,0,4, "You are no longer under NLR.") NLR.Players[Player] = nil end else NLR.Players[Player] = nil end end end timer.Create("DRP_NLR", 1, 0, NLR.Tick) function NLR.PlayerDeath(Player, Killer) NLR.Players[Player] = {CurTime() + GetConVarNumber("NLR_Wait"), Player:GetPos(), 0} end hook.Add("PlayerDeath", "DRP_NLR", NLR.PlayerDeath) function NLR.PlayerSpawn(Player) if NLR.Players[Player] then NLR.Players[Player][4] = Player:GetPos() end end hook.Add("PlayerSpawn", "DRP_NLR", NLR.PlayerSpawn) [/LUA] Not sure why you are going through the players, when it may be simpler just to put them in their own table. Also, if people really want me to expand on this, I can. Only reason I made it is to offer an alternative to getting slain for entering an area, which I think is a bit much. By the way, this is for DarkRP.
I appreciate your effort to fix NLR, but there's a lot wrong with this script. The script contains a bunch of mistakes, but much more worrying is the fact that a good minge can ban people with this script. - If a player dies at spawn and and spawn protection is off, he'll get a warning, and he'll get banned eventually - Only one player can have this NLR thing going on. The script really only allows one player in it. So if two people die and respawn, the first one who respawns will never get a warning - If a player dies in the street, this entire street will be blocked for 500 seconds by default. If he wants to pass through the street to go somewhere else, he'll get slayed/banned - There's a small chance of nlr_spawnprotection to fail (namely when "nlr_timer" is called after the PlayerSpawn event and before the function that is called 0.02 seconds after the PlayerSpawn event. [b]How to ban people using this script without needing admin access:[/b] 1. if nlr_spawnprotection == 0 - Kill people at spawn repeatedly otherwise, if nlr_spawnprotection_time < nlr_wait 2. block spawn 3. Get a good gun 4. Kill them repeatedly 5. Make sure they don't go outside of spawn. I haven't tested this myself, I just read the script.
[QUOTE=FPtje;39576522]I appreciate your effort to fix NLR, but there's a lot wrong with this script. The script contains a bunch of mistakes, but much more worrying is the fact that a good minge can ban people with this script. - If a player dies at spawn and and spawn protection is off, he'll get a warning, and he'll get banned eventually - Only one player can have this NLR thing going on. The script really only allows one player in it. So if two people die and respawn, the first one who respawns will never get a warning - If a player dies in the street, this entire street will be blocked for 500 seconds by default. If he wants to pass through the street to go somewhere else, he'll get slayed/banned - There's a small chance of nlr_spawnprotection to fail (namely when "nlr_timer" is called after the PlayerSpawn event and before the function that is called 0.02 seconds after the PlayerSpawn event. [b]How to ban people using this script without needing admin access:[/b] 1. if nlr_spawnprotection == 0 - Kill people at spawn repeatedly otherwise, if nlr_spawnprotection_time < nlr_wait 2. block spawn 3. Get a good gun 4. Kill them repeatedly 5. Make sure they don't go outside of spawn. I haven't tested this myself, I just read the script.[/QUOTE] Thanks for the review. I always thought about the spawn thing but inevitably the least I could do was add the spawn protection. But in reference to Lua, what is wrong with the code? (besides the global variable that I should have considered)
Indenting is inconsistent (minor) ConVar values are only registered at the start of the server (minor) Top variables protection, warnings, deathpos, died are declared but never used (minor) playernlr is set to a player object, but line 57 implies you think it's a name. Line 34 as well, since you set its initial value to an empty string (this is pretty major) NLR is reset for EVERYONE every "wait" seconds. If someone spawns 10 seconds second before the NLR thing, he probably won't get punished for breaking NLR. A whole pyramid of scopes (function, for, if if if if if if if if timerfunction if if if if end end end end end end ......) I can tell you're new with Lua. Good luck!
This is something that just can't be done using one script. Say the player got shot in his own home, most servers allow that you remember trivial things such as home and your name, so you wouldn't be allowed to go back to your home in 500 seconds. Imagine the roleplay scene, "Hi darling, come back to bed~. Uh, I can't, I'm not allowed to enter my house for 400 seconds because god will kill me otherwise"
I'd be impressed if a script could effectively handle NLR to the degree a human could. It's a bit of a judgement call at times, ie if they died on the street, can they cross that area to go somewhere else? Most people would say yes that's not an issue. Proper administration will always be better than a script trying to administrate for you. A better thing to do would be to warn online admins that someone has entered an "NLR Zone" as you say. The admin can then spectate the player and take action if needed. Scripts are great as helping tools, but they can not and should not try to replace admins.
Going on with what FPtje said, you could try to make it so certain areas can't have the NLR script applied to them.
[QUOTE=FPtje;39576961]Indenting is inconsistent (minor) ConVar values are only registered at the start of the server (minor) Top variables protection, warnings, deathpos, died are declared but never used (minor) playernlr is set to a player object, but line 57 implies you think it's a name. Line 34 as well, since you set its initial value to an empty string (this is pretty major) NLR is reset for EVERYONE every "wait" seconds. If someone spawns 10 seconds second before the NLR thing, he probably won't get punished for breaking NLR. A whole pyramid of scopes (function, for, if if if if if if if if timerfunction if if if if end end end end end end ......) I can tell you're new with Lua. Good luck![/QUOTE] Thanks, I'll keep these into consideration the next time I code
---Snip Nvm i found what the issue was
One interesting idea, perhaps you could use the <can see sky> method, to detect if they are outside (just an idea), One cool thing (maybe) would be this: [img]http://cloud-2.steampowered.com/ugc/578951959414868464/CC2CDC0690F9CD87E015E0896E778DAA0A409FDB/[/img] I made that a long time ago, it's one of those text thingos that always faces you, and slowly appears as you move closer to it. Maybe adding a spawn radius protection sort of thing, so when a player spawns, it removes any NLR things from a RADIUS around them? Based on what FPtje said, maybe you should be storing the NLR locations on the player, not in a global? (i didn't read the script) Another abusable idea, but maybe !NLR <name>, so people can type that if they think you are abuing NLR, or something? Or, on the other hand, maybe if instead of banning people, it showed an admin where you died, and how close you got? Then they can judge if it was abusing NLR, or not...
how to avoid New Life Rule? Need: 2 players • Have a little amount of health • both jump off a building • ... • PROFIT! You have full health and avoid New Life Rule. btw, script requires a lot of improvements ty
Wow, you're such a wizard for being able to get past a seriously old script. Congrats!
[QUOTE=tyguy;40366215]Wow, you're such a wizard for being able to get past a seriously old script. Congrats![/QUOTE] No need to be belligerent. You may not plan on updating/remaking it, but somebody who is might see his post, and add in a fix for it in their own script.
Made a variation of this that simply warns administrators on currently, if someone is in a "NLR Zone" where they died. Also notifies the player that they are in an NLR Zone and when they leave. I could pastebin it, if people would like. Just seemed like a less intrusive option for DarkRP servers that want to enforce NLR.
Could you share it if possible Divinity? I like the idea of it warning administrators.
Stop interaction in the death area ( spawning props, moving props, buying stuff, changing jobs, killing people ). This is simply too hacky and exploitable to have people banned / slayed / kicked for.
I think the best option is this: There should be a marker for the player like in ash47's picture. There should be a timer on the corner of the players screen. Admin's should get notified when a player breaks NLR. I can manage making a timer and notifier. It would be awesome if TheDivinity pastebins the notifier code. Much easier for me...but I'm wondering how will I go about making the marker Does anyone have any idea on where I should look on the wiki to make a marker that only the player can see.
Sorry, you need to Log In to post a reply to this thread.