High Ping kicker help?

Hello I am working on a High Ping kicker for Gmod.

but i need some help

This is what i have so far

[cpp]count = 0
timer.Create( “auto_ping_kicker”, 5, 0, function()
for k, v in pairs(player.GetAll()) do
v.pingsum += v:Ping()
count += 1
if count == 5 then
for k, v in pairs(player.GetAll()) do
curping = (v.pingsum/count)
if curping >= 350 then
v:Kick(“Autokick: Please fix your ping!”)
count = 0
end )[/cpp]

2 things

  1. Why are you kicking for high ping??
  2. What do you need help with?

Disseminate, “high-ping players lag the server”. Didn’t you know? :v:

@OP: What is the count variable you are using? Is it some sort of “check-5-times-and-kick-if-still-too-high”-system?

Umm well kicking the player for high ping and i need help because it wont work

Well, im not an expert, but this code is terrible.

I dont think you can use += instead use var = var +<whatever>

Also, it looks like your count variable is outside your loop.

For one, the += operator isn’t part of Lua. If you wish to perform an addition operation, it must be in the format of a=a+b not a+=b. Secondly, you are trying to perform arithmetic operations upon a variable that appears to be uninitialized, v.pingsum, which must already be holding number value before you can start using it in calculations. Third, assuming you fix those two problems, you will eventually kick all of the players on your server, since you are not resetting the players’ pingsums and they will continue to accumulate. Fourth, for the love of god, localize count and curping, there is no reason for them to be global variables. Fifth, there is literally no reason to kick for high pings, unless you are running a highly popular server with few slots and you feel it is necessary to remove high-ping players, who can barely play the game due to their latency, so someone else can get in. Source games use a server/client network architecture, high-ping players only cause lag for other players in peer-to-peer architecture networks. And sixth, for future reference, the help and questions section is over here.

you could do something like(Not saying this’d work because I haven’t done anything like ths):
for _,v in pairs(player.GetAll()) do
if v:Ping() > amounthere then
v:Kick(“Your ping exceeds the highest amount”)

Didn’t notice the var was set on the player.

if SERVER then
local MaxPingCVar = CreateConVar(“sv_max_ping”,25,FCVAR_NOTIFY+FCVAR_ARCHIVE+FCVAR_REPLICATED,“Change the max ping for players”);
local MaxViolationsCVar = CreateConVar(“sv_max_ping_violations”,25,FCVAR_NOTIFY+FCVAR_ARCHIVE+FCVAR_REPLICATED,“Change the max ping for players”);
local tbl = {};
local maxping = MaxPingCVar:GetInt();
local maxpingviolations = MaxViolationsCVar:GetInt();

	maxping = new;

	maxpingviolations = new;

	for k,v in pairs(player.GetAll()) do
		if(v:Ping() &gt; maxping) then
				tbl[v] = tbl[v] +1;
				if(!tbl[v]) then
				elseif(maxpingviolations&gt;tbl[v]) then
				elseif(maxpingviolations&lt;=tbl[v]) then
					timer.Simple(3,_R.Player.Kick,v,"Ping too high!");

local val = um:ReadShort();
if(val == -1) then
chat.AddText(“You ping was too high over a too long period of time, you will now be kicked”);
chat.AddText(“Warning, your ping is too high, you have “,tostring(val),” violations left!”);

A players ping dosent lag the server or other clients, it just laggs the client.

You -> Server -> Other Clients
If you are lagging its like…
You [15ms]-> Server -> Clients

If you shoot at someone lagging it will register on the server because the server hasnt yet received the command that that player moved. If you are lagging and shoot your bullet wont register but the others will.


The server doesn’t wait for the client, and it doesn’t keep resending data. There’s no big deal.

Does he think this will stop speedhacking?

Players with high ping in games such as CSS can actually effect the game since there movement is very choppy making them harder to hit.