Synchronized hook

I was wondering if there was a hook of which calls consistently between the server an client (Same amount of executions / s).

I’ve recently been having troubles with users speedhacking on my server, and wanted to make a quick check for it (Just to get the stupid people out, I understand it’d be easy to get past.)

I’ve tried “Tick”, though the problem is, not only does your tickrate on the client spike MASSIVELY upon spawn, it doesn’t become large enough (when your clients timescale is changed) to contrast from the server, and can sometimes even drop below the server’s tick.

I’ve also tried “Think” but sense “Think” seems to be triggered by CurTime(), the client’s speedhack isn’t really speeding up the real worlds time.
(Same thing applies for timers)

I’m honestly at a loss here, I can’t think of a way to detect if a client is running too fast.

Any ideas?

Tick is supposed to be kind of synched. What are you trying to do? Detect speedhackers?

Correct, I am trying to detect speedhackers

local serverticks = 66
local slack = 2
local timeslack = 90000
local failcount = 12
local averagebase = 10
	P.__HAverageTable = {}
	timer.Simple(120,function()  // fallback, just in case.
		P.__EnableSHDetector = true 

	for k,pl in pairs(player.GetAll()) do
		if !pl.__HackFailCount then pl.__HackFailCount = 0 end
		if !pl.__LastHackCheck then pl.__LastHackCheck = CurTime() end
		if pl.__EnableSHDetector==true then 
			local tdelta = CurTime() - pl.__LastHackCheck 
			if tdelta > timeslack then 
				pl.__HackFailCount = pl.__HackFailCount + 1
				MsgC(Color(255,0,0,255),"[HACK]: ") MsgN(pl:Nick() .. " didn't respond to checker!")
				if pl.__HackFailCount > failcount then 
					MsgC(Color(255,0,0,255),"[HACK]: ") MsgN("Too many failures, kicking " .. pl:Nick())
					pl:Kick([[Your client seems to have failed to respond to the speedhack check.]]) 
	if pl.__EnableSHDetector==true then
		if !pl.__HAverageTable then pl.__HAverageTable={} end
		local ticks = net.ReadFloat()
		local distance = ticks - serverticks
		print(ticks .. " : " .. serverticks)
		pl.__HAverageTable[#pl.__HAverageTable + 1] = distance
		if #pl.__HAverageTable > averagebase then
		local adist = 0
		for k,v in pairs(pl.__HAverageTable) do
			adist = adist + v
		adist = adist / #pl.__HAverageTable
		//print(pl:Nick() .. " AVERAGE IS " .. adist)
		//distance = 0
		if adist > slack then 
			//for k,v in pairs(player.GetAll()) do v:ChatPrint(pl:Nick() .. " trigger!") end
			//pl:Kick([[Your client is running too fast. (Speedhacking) ]] .. distance)

		pl.__LastHackCheck = CurTime()
		pl.__HackFailCount = 0
	pl.__EnableSHDetector = true 

(This is just a test file, not what I was going to implement into the server). Also, some variables within the code may look stupid (making the code inoperable) because I was testing this on a live server :P. This is just to give you the idea of how i’m going about this.

Basicly, each client has an “AVERAGE” number of ticks.

	local shticks = 0
		shticks = shticks + 1

		print("Responded to detector " .. shticks)
		shticks = 0
	print("Halo Warld!")

Every second, the client sends a float to the server containing the number of ticks executed within that second.

If their average rises over a set amount, it boots them from the server. (Once again, these are test files, not the complete issue, if its even possible)

The tick hook drops too low (unexplicably) on the client, therefore if their client does begin to execute too swiftly, it doesn’t indicate an abnormality.


I assume comparing player speeds on the server is out of the question?

There’s a lot of factors you’d have to account for, like noclipping, ladders, slops, bunnyhopping, latency, speed differences across servers, maps which boost your speed, determining how much extra speed is “too much” and also other mods which might affect how fast you can run etc. He said he was trying to figure out if the client is running faster than the server internally (a sort of “Cheat Engine” speedhack) by seeing if their tickrate is higher than the server’s tickrate (I’m not even sure how the engine is affected by such behavior.)

EDIT: I see the problem he’s having, the timers are also being effected, and because the game is running faster than normal (2-3x times) the “ticks per second” are actually going down not up. But that can also happen if your PC is slow, so it’s hard to detect using that method. What you could actually do is detect the time inbetween each “timestamp” when this was sent. So if you put the timer on a 10 second interval and you’re getting it once ever 20, or 15 seconds they’re probably using a “speedhack.”

I guess so, that’s kind of dissapointing :(.

Hook the “move” hook serverside. Compare the # of them you receive from client. No clientside needed