# Kick if speed is over x?

Can anyone point me in the right direction on how I could write something to kick a player if they are going faster than the default gamemode speed?

What if the player is blown away from an explosion and goes aver the gamemode’s run speed?

check the lenght of the speed

[lua]if ply:GetVelocity():Length() >= maxSpeed then ply:Kick(“kk ked”) end[/lua]

good point, trying to figure something out for EFT

Sniparoni

falling

Just check if they were recently damaged by an explosion, if so then don’t kick them after a certain time (then kick them) otherwise kick them after two seconds of such, since you never know if they’re on a slope.

Preferably you just proof it so you don’t have to worry about kicking anyway, which is a poor solution.

If you’re doing this to stop speedhacks, it won’t work. They don’t make your velocity go higher.

What do they do then?

Apply there velocity more frequently. I’d check the command rate in is higher than it should be in GM:Move. Or get CAC.

Check how fast their client is sending StartCommand. Each player should send StartCommand to the server once per tick (sometimes a little above, so add some lenience to it).

This means that every second, the player should have sent StartCommand an equal number of times to engine.TickInterval().

StartCommmand is called before each StartMove, so even PSpeed would be detected by this.

``````
HEAT = {}
HEAT.SpeedHackBias = 20 // How much faster the client can be ticking than the server
HEAT.SpeedHackTime = 8 // Time a player has to disable speedhack

////////////////////////////////////////////////
///////SPEED HACK DETECTION/////////////////////
////////////////////////////////////////////////
do

local function punishplayer(ply)
ply:Kick("pls sped hak no mor.")
end

function pun(ply)
punishplayer(ply)
end

local SERVERTICK = 1/engine.TickInterval() // Find our tickrate
timer.Create("HeatSpeedHackCheck",1,0,function()
for k,ply in pairs(player.GetHumans()) do
if !ply.Tick then ply.Tick = 0 end
if !ply.SpeedHackTrigger then ply.SpeedHackTrigger = 0 end

if ply.Tick > SERVERTICK + HEAT.SpeedHackBias then
if !ply.SpeedHackTrigger then ply.SpeedHackTrigger = 0 end
ply.SpeedHackTrigger = ply.SpeedHackTrigger + 1

else
ply.SpeedHackTrigger = 0
end
if ply.SpeedHackPunishing==true then
ply.SpeedHackTrigger = 0
end

if ply.SpeedHackTrigger > 2 then
if !ply.SHWarnings then ply.SHWarnings = HEAT.SpeedHackTime end
if ply.SHWarnings == 0 then
punishplayer(ply)
return false
end
if !ply.SpeedHackNotified then

ply.SpeedHackNotified = true

end

print( ply,nil,"CLIENT OUT OF SYNC. Removal of client in " .. ply.SHWarnings .. "sec. "  ) )

ply.SHWarnings = ply.SHWarnings - 1

end

ply.Tick = 0

end

end)
function HEAT.SpeedHackCheck(ply)
if !ply.Tick then ply.Tick = 0 end
ply.Tick = ply.Tick + 1

end
hook.Add("StartCommand","HeatCheckSpeedhack",HEAT.SpeedHackCheck)

end

``````

As somebody mentioned before, they don’t make your velocity faster. They make your client execute more often. StartCommand gives a good idea of how fast a client is executing.

One of the problems with very old games is they bound movement, etc… to fps instead of to time… You could easily bind their speed ( read as ▲Pos ) to time so that, regardless of frequency, you can get their true speed. Once you have their true speed, you can compare it to the maximum speed plus some buffer to account for speed gained while strafing, etc… and then you can throttle them down so instead of them moving faster they’d move at the same speed as everyone else…

Guys guys, that’s no way to protect yourself from hackers…

Just use this hook here:

EDIT:
Excuse me for helping. u jerks.

I know I am going to sound like the hugest retard in the universe, but I have waited long enough to figure this out:

What do you mean, and/or what is the purpose of this “-snip-” thing?

it means they took back what they said and/or don’t want people to see it

The other thing I just realized is if people are spectating it would probably do something to them also I would assume?

A friend of mine actually wrote a script that prevents you from flying beyond a designated speed in the first place, as a job for some bhop server I think.

He used a Move hook IIRC