Reworked Noob-Prevention Script

Same script, different functionality. Serverside only.

If a player has less than x hours of playtime he can’t do anything on the server unless he loses his initial rank.
He gets notified whats wrong and cant spawn anything nor acess noclip.
It should really just prevent those who come to spam for those who need. And it’s mostly the people with no playtime doing it.

The rest is up to the server admins to use my script properly.
Combines well with rank-by-playtime scripts.

If thats not your style then consider my Antispam (http://forum.facepunch.com/showthread.php?t=1426428) (which is yet to be completed but no time… maybe soon)

Evolve compatibility included, ulx etc. requires the addition of 1 line after line 31… for the server devs or people with a clue.

Updated:


if SERVER then
	
	local days = 2
	local hours = 0
	local min = 0
	
	local req_h = days*24+hours+min/60
	
	print("[+]ANTINOOB TIME: "..string.NiceTime( req_h*3600 ))
	
	local WhiteList = {
		["STEAM_0:1:7099"] = true,


	}


	util.AddNetworkString("noobcheck_playtime")
	
	local function can(ply)
		if ply == nil or not IsValid(ply) then return end
		
		if ply:IsBot() then return true end
		if ply:IsAdmin() then return true end
		if WhiteList[ply:SteamID()] ~= nil then return true end
		
		if evolve and ply.EV_GetRank and ply:EV_GetRank() ~= "guest" then return true end
		--if ulx and bla then return true
		--...
		
		--prevent spamming when dead:
		if ply.noobcheckpassed ~= true and not ply:Alive() then return false end
	end
	
	local function check_recursively(ply)
		if can(ply) then return end
		timer.Simple(15,function()
			check_recursively(ply)
		end)
		ply:SendLua("net.Start( 'noobcheck_playtime'); net.WriteFloat(achievements.GetCount( 5 )); net.SendToServer()")
	end
	
	hook.Add( "PlayerInitialSpawn", "noobcheck_playtime_initializer",function(ply) check_recursively(ply) --[[ply.noob_init = true]] end)
	
	--for updating the script at runtime:
	/*for k,v in ipairs(player.GetAll()) do
		v.noobcheckpassed = nil
		check_recursively(v)
		v.noob_init = true
	end*/
	--for updating at runtime without rejoin (requires external script to reset PLAYER.noob_init = nil):
	--hook.Add( "PlayerSpawn", "noobcheck_playtime_initializer",function(ply) if not ply.noob_init then return end check_recursively(ply) end)


	hook.Add("PlayerSpawnEffect","noobcheck",function(ply)
		return can(ply)
	end)
	hook.Add("PlayerSpawnNPC","noobcheck",function(ply)
		return can(ply)
	end)
	hook.Add("PlayerSpawnObject","noobcheck",function(ply)
		return can(ply)
	end)
	hook.Add("PlayerSpawnProp","noobcheck",function(ply)
		return can(ply)
	end)
	hook.Add("PlayerSpawnRagdoll","noobcheck",function(ply)
		return can(ply)
	end)
	hook.Add("PlayerSpawnSENT","noobcheck",function(ply)
		return can(ply)
	end)
	hook.Add("PlayerSpawnSWEP","noobcheck",function(ply)
		return can(ply)
	end)
	hook.Add("PlayerSpawnVehicle","noobcheck",function(ply)
		return can(ply)
	end)
	
	hook.Add("PlayerLoadout","noobcheck",function(ply)
		if can(ply) ~= true then return true end
	end)
	
	hook.Add("PlayerNoClip","noobcheck",function(ply,desstate)
		return can(ply)
	end)
	
	hook.Add("PlayerSpawn","noobcheck",function(ply)
		if not can(ply) then 
			ply.nc_col = ply:GetColor()
			ply.nc_mat = ply:GetMaterial()
			
			ply:SetColor(Color(255,0,0))
			ply:SetMaterial( "models/debug/debugwhite", true )
		else
			if ply.nc_col and ply.nc_col ~= ply:GetColor() then
				ply:SetColor(ply.nc_col)
				ply.nc_col = nil
			end
			
			if ply.nc_mat and ply.nc_mat ~= ply:GetMaterial() then
				ply:SetMaterial( ply.nc_mat, true )
				ply.nc_mat = nil
			end
		end
	end)
	
	hook.Add("PlayerGiveSWEP","noobcheck",function(ply)
		return can(ply)
	end)
	
	hook.Add("PlayerUse","noobcheck",function(ply)
		if not can(ply) then return false end
	end)
	
	net.Receive( "noobcheck_playtime" , function(ley, ply)
		if not IsValid(ply) then return end 


		local ti = math.floor(net.ReadFloat()/6)/10
		print(ply:Name().." ("..ply:SteamID()..") played GMod for "..ti.." / "..req_h.." hours.")
		
		ply:PrintMessage(3,"You actively played on servers for "..ti.." / "..req_h.." hours. ("..string.NiceTime( req_h*3600 ).." needed to play here)")
		
		if ti >= req_h then
			ply.noobcheckpassed = true
			
			ply:SetColor(ply.nc_col)
			ply:SetMaterial( ply.nc_mat, true )
			
			ply.nc_col = nil
			ply.nc_mat = nil
			
			ply:Spawn()
		end
	end)
end

What I did take in consideration: Your feedback from last time. ( http://forum.facepunch.com/showthread.php?t=1422077 )

What the fuck is this? It’s awful.



	function check_recursively(ply)
		if ply:IsBot() then return end
		timer.Simple(3,function()
			if ply and IsValid(ply) and ply.noobcheckpassed ~= true then
				check_recursively(ply)
			end
		end)
		ply:SendLua("net.Start( \"noobcheck_playtime\"); net.WriteFloat(achievements.GetCount( 5 )); net.SendToServer()")
	end
	
	hook.Add( "PlayerInitialSpawn", "noobcheck_playtime_initializer",check_recursively,ply)


Well I released the code too early anyways it should be fixed now.

Also please give some reasons if you think you need to give feedback. Else it’s completely useless.
If you think you can do it better why do you expect me knowing what you mean right away when I obviously did it wrong?

Okay. First, SendLua. The way you’re using it is bullshit. Just send a netmessage to a client to request an update that will send data to the server. Second, why do this stupid recursive thing with timer.Simple and not use timer.Create?

Stop using SendLua.

Ok whats wrong with sendlua? It works just fine for simple code like this. If you’re refering to being more efficient with the server resources. I can’t confirm a gain of built in c functions over c interpreted lua code.

The previous thread mentioned a vulnerability against hackers, which is theoretically also there if you use netmessages. Except you know the source code of both in c.

I wanted the code to be solely serverside.

The second thing is just a personal preference. Performance wise it shouldn’t make difference, it’s linear.

Edit:

Thats your opinion and no reason. Also it doesn’t seem to be very respectful tbh. (which I know is a general problem upon this forum but please not in my threads)

Edit2:
Just rating my posts without giving reasons is also useless. If I don’t even know what you mean how could I learn? And just because I disagree with you doesn’t mean I can’t be convinced if you could be reasonable.

Secondly did you even fully understand my code to question my style that quickly?

Thanks for this feedback! These are no huge problems. I just didn’t see them.

The second one is true but practically it just sends the data once, well it should. So theres no real gain over a shared script.

I personally don’t see the problem in trusting the client here.
In terms of reliability gmod is good enough. (At least 100% success rate for me with this script)
In terms of people deliberately trying to bypass each security measure… this isn’t the tool to deal with them. Because most people with less than 48h didn’t even get to see gmod lua. And if they are mostly clever enough not to spam the server to death. (Thats statistically just a minor risk. At least on the servers I play on. (custom build, Wire, own e2 extensions etc…))

Think of it this way:
It’s like applying a second lock to your door. It will prevent intruders with less clue. But those more sophisticated will get in. And then there are the ones that just got a door breacher… manually perma ban by admins.

Anyways I’m working on it.

Edit:
Updated to not unnecessarily interfere with propprotection or other scripts hooks anymore.

While talking about hooks, the hooks which each have their individual functions can be reduced to hook.Add(“hookname”,“uniqueident”, can) besides the ones for PlayerLoadout and PlayerSpawn

I still don’t get this whole “Anti-noob” stuff that has been going on for a while on these forums. It’s really unfair to treat people differently or even worse than other players just because they don’t have many hours.

I understand the whole “Anti-spammer” or “Anti-alt-accounts”, but I don’t know if jumping only on the hour count is the way to go. People that are marginalized because of their hour count will probably leave, to never come back, and probably will give a bad name to the server.

agreed

you should ban people for their actions, not by “prevention” (especially something as obtuse as play time)

have fun growing a community with shit like this on your server

Yeah, let’s just ban half of the Garry’s Mod population because they’re new and want to learn.

And why? Are new players even more likely to cause trouble in the first place? Surely the biggest trouble comes from the people who know precisely how the game works? Sure, beginners may make mistakes, but it’s easier to correct ignorance than willful abuse.

how about hackers on alternate accounts

[editline]1st October 2016[/editline]

I mean I’m not sure why you would use a VAC detectable cheat but people do it

i’ve never understood what server owners and have against new players

just as you said, most mingers are the more experienced bunch who know how to fuck with your server through 1000 different ways through first-hand mingery knowledge and experience

the worst new players could do to you is annoying you by asking you dead simple questions; and even then it wouldn’t hurt to be helpful

If you want a filter, make new joiners solve a linear algebra puzzle.

I started writing an addon for that but abandoned it.

It’s not an intelligence test, but it does check people’s ability to comprehend things which will come in handy when receiving instructions from an admin. Also, most people get taught that at around age 15.

Again; it’s not a cure-all but it’s something.

-snip-

sure it works, but your code is shit


(User was banned for this post ("That's not nice" - Blazyd))