Author Topic: No more high ping  (Read 5268 times)

VetalYA

  • Guest
No more high ping
« on: November 04, 2011, 01:26:04 pm »
Code: [Select]
g_MaxPing <- 250;  //Your value for max allowed ping

function onServerStart()
{
NewTimer("NoMoreHighPing", 5000, 0);//This timer will be executed every 5 seconds for all players
}

function NoMoreHighPing(){

local players = GetPlayers();
if (players == 0){ return false; }//if no players online, this function will stop at this point.

players += 10;

local pPlayer = null, id = 0;
while ( id < players ) {
pPlayer = FindPlayer( id );

if ( pPlayer) {
if(pPlayer.Ping > g_MaxPing){ 
Message( pPlayer.Name + " have been kicked due to high ping" );
KickPlayer( pPlayer );

} }
id += 1;
}
}
« Last Edit: January 04, 2012, 09:21:22 pm by VetalYA »

Force

  • Developer
  • Full Member
  • *****
  • Posts: 204
  • Karma: +6/-2
    • View Profile
Re: No More high ping
« Reply #1 on: November 04, 2011, 02:38:00 pm »
One suggestion, it might be better to take an average ping before kicking, that way you can take into account random ping spikes people may have.
Quote
[Tue - 20:09:35] <&VRocker> CRAP!
[Tue - 20:09:43] <&VRocker> i think i just followed through...
Quote
[Sat - 22:11:56] <~Smapy> [R3V]breSt12 killed [R3V]Jack_Bauer. (Splat)

VetalYA

  • Guest
Re: No more high ping
« Reply #2 on: November 04, 2011, 04:09:24 pm »
One suggestion, it might be better to take an average ping before kicking, that way you can take into account random ping spikes people may have.
Maybe you right  ;)

Thanks.
« Last Edit: November 09, 2011, 09:31:17 am by VetalYA »

Bob

  • Jr. Member
  • **
  • Posts: 69
  • Karma: +4/-0
    • View Profile
Re: No More high ping
« Reply #3 on: November 05, 2011, 02:07:37 am »
I take great offense to this script.

A player like me, even with decent internet, will have a ping of between 300 to 350 or so. Having a ping of less than 200 is usually only possible when the user is in the same country or close to the host. You will be unfairly shutting out a lot of people from servers just because of where they live.

The only people who deserve to be disconnected from servers are those with ping levels above 700 at the very least. This is because those people are using bad connections, some even daring to use dial up.

As a host for a game, you have to be prepared to host for people with high ping of up to 500. If your server can't handle that, you shouldn't be hosting. It almost makes you a bad admin to try to get rid of people over ping.
« Last Edit: November 05, 2011, 02:09:24 am by Ammonite »

Bob

  • Jr. Member
  • **
  • Posts: 69
  • Karma: +4/-0
    • View Profile
Re: No More high ping
« Reply #4 on: November 05, 2011, 11:01:24 am »
well only people from australia, new zeland, japan, india, china etc. will have high pings on hosted european servers and that would be around 350-450 so there is no possibility that someone can connect with normal ping 500+ because there is nothing more far then the countries i mentioned, thats why i set it like 500+ ......250 is too low VetalYa specially if you are runnning a server on your pc

Only? You just listed a lot of places.

I've met and talked to American players who have a ping ranking of around 280 to 300 and have good grade internet. Even so, you are still shutting out a significant amount of the world, and for what exactly? Even when playing with users who have high pings, I've never experience or witnessed a slowdown with the server, let alone one that hurts gameplay.

VetalYA

  • Guest
Re: No More high ping
« Reply #5 on: November 05, 2011, 12:36:02 pm »
Ok guys, calm down please.    :)

Script above and
Code: (squirrel) [Select]
g_MaxPing <- 250; my value 250 given only as an a example. You free to change Max Allowed ping whatever you want.


@Force yes you right, becuase some normal players can have unstable ping  from 170 to 350.

I have to create script like:
Code: (squirrel) [Select]
function NoMoreHighPingCalculate(){

}
This script should calculate ping, and if it exceed, then kick...  But i am too lazy to create  calculate script  :)


By the way, calculate script   will use even more CPU and RAM.

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: No More high ping
« Reply #6 on: November 06, 2011, 12:08:41 pm »
lol, a simple calculation wont eat much CPU, and very few RAM if nothing at all.

See if
( 100 + 120 + 150 + 120 + 100 + 120 ) / 6
eats ram and CPU on your computer, I hope not  :x

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: No More high ping
« Reply #7 on: November 06, 2011, 09:27:00 pm »
This is gonna be a long bit of code, but it stores every ping into a table every five seconds for each player, then adds them all together, then divides it by how many pings each player has. so here goes ...

By the way, this script might teach some people about multidimensional tables. Also, adjust the MaxPing variable to your liking:

Some credits for this:
Idea from VetalYA
GetPlayersTable() from himselfe

Code: [Select]
function onScriptLoad()
{
MaxPing <- 400;
PingTimer <- NewTimer("CalculatePingAverage",5000,0);
PingTimer.Start();
PingInfo <- {};
}

function onPlayerConnect(player)
{
PingInfo[player.ID] <- {};
PingInfo[player.ID].PingCount <- 0;
PingInfo[player.ID].Average <- 0;
PingInfo[player.ID].TotalPing <- 0;
}

function CalculatePingAverage()
{
local players = GetPlayersTable();
foreach(player in players)
{
PingInfo[player.ID].PingCount <- PingInfo[player.ID].PingCount + 1;
local pingcount = PingInfo[player.ID].PingCount;
PingInfo[player.ID].Pings <- {};
PingInfo[player.ID].Pings[pingcount] <- {};
PingInfo[player.ID].Pings[pingcount].Ping <- player.Ping;
PingInfo[player.ID].TotalPing <- PingInfo[player.ID].TotalPing + PingInfo[player.ID].Pings[pingcount].Ping
PingInfo[player.ID].Average <- PingInfo[player.ID].TotalPing / pingcount;
if(PingInfo[player.ID].Average > MaxPing)
{
KickPlayer(player);
}
}
}

function GetPlayersTable()
{
        local players = {};
        
        for(local player,id = 0,count=GetMaxPlayers();id<count;id++)
{
if((player = FindPlayer(id)))
{
players.rawset(player.Name,player);
}
}
        
        return players;
}

function onPlayerPart(player,reason)
{
PingInfo[player.ID] <- null;
}

stormeus

  • No-Lifer
  • Developer
  • Full Member
  • *****
  • Posts: 112
  • Karma: +13/-2
    • View Profile
Re: No More high ping
« Reply #8 on: November 07, 2011, 01:52:51 am »
All that code for a ping-average based kicker? Seems excessive. While we're at it, I might as well throw together some code.

The following code is also based on himselfe's GetPlayersTable().

Code: (squirrel) [Select]
maxPingDeviation <- 100; // How much higher a player's ping can be than the average without getting kicked.
players <- {}; // A table of players

// Add a player to the players table when they join
function onPlayerJoin( player ) { players.rawset( player.ID, player ); }

// And remove them when they leave
function onPlayerPart( player, reason ) { players.rawdelete( player.ID ); }

// The good stuff. Use this however you want.
// Timers, on events, however you want.
function pingKicker()
{
    local total = 0; // Initialize a variable for the sum of all players' pings
    local average = 0; // Initialize a variable for the average ping

    // Go through every player and add their ping to the total
    foreach( player in players ) { total += player.Ping; }

    // Get the average ping
    // Add the max deviation for less math processing
    average = (total / players.len()) + maxPingDeviation;

    // Now go through every player and kick them if their ping is unacceptable
    foreach( player in players )
    {
        // If their ping is too much higher than the average, kick them.
        if( player.Ping > average )
        {
            // Post a message saying they were kicked and why.
            Message( player.Name + " kicked. (Excessive Ping)", Colour( 255, 0, 0 ) );

            // And then actually kick them.
            KickPlayer( player );
        }
    }
}
Quote
Morphine says:
    them LU devs ranting about how LU doesn't have client pickups
    while us VC:MPers don't have client anything
    ;_;

Stormeus Argo says:
    we have client crashes though
    ohohohohoho

Morphine says:
    LU DOESN'T HAVE THAT

Stormeus Argo says:
    LU - 0
    VC:MP - 1

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: No More high ping
« Reply #9 on: November 07, 2011, 02:16:31 am »
That snippet you created won't be very efficient to kicking those with high ping, as you are calculating everybody's ping together. What if somebody has like 400 ping and another has 50? It wouldn't be fair for the person with low ping to get punished for another persons connection.

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: No More high ping
« Reply #10 on: November 07, 2011, 12:17:30 pm »
it only checks pings above the average, so low ping players are not punished.

Bob

  • Jr. Member
  • **
  • Posts: 69
  • Karma: +4/-0
    • View Profile
Re: No More high ping
« Reply #11 on: November 07, 2011, 12:33:41 pm »
A max ping of 400 seems reasonable. Though ethically I still think there is a bit of an issue with this script.

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: No More high ping
« Reply #12 on: November 07, 2011, 03:20:05 pm »
Quote
it only checks pings above the average, so low ping players are not punished.

Yes I know, but I was talking about how the average is calculated using everybody's ping together, rendering it inefficient if somebody has a high ping and somebody else has a low ping.

stormeus

  • No-Lifer
  • Developer
  • Full Member
  • *****
  • Posts: 112
  • Karma: +13/-2
    • View Profile
Re: No More high ping
« Reply #13 on: November 07, 2011, 09:28:37 pm »
Yes I know, but I was talking about how the average is calculated using everybody's ping together

That's how mean averages are calculated.
Code: (squirrel) [Select]
average = (total / players.len()) + maxPingDeviation;

Total ping divided by number of players, plus the maximum ping deviation. If I only used the average and no deviation, everyone with the highest ping would be kicked.
« Last Edit: November 07, 2011, 09:32:35 pm by stormeus »
Quote
Morphine says:
    them LU devs ranting about how LU doesn't have client pickups
    while us VC:MPers don't have client anything
    ;_;

Stormeus Argo says:
    we have client crashes though
    ohohohohoho

Morphine says:
    LU DOESN'T HAVE THAT

Stormeus Argo says:
    LU - 0
    VC:MP - 1

 

© Liberty Unleashed Team.