• Welcome to Vice City Multiplayer.
 

Kick to High Ping by Madara

Started by Madara, March 27, 2011, 10:15:54 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Madara

Hi all, today i will show how to create a function which will serve to "kick"a player with high ping.

First, define a "enum" where will be the ticket send player:

enum playerInfo
{
   CheckPing,
}


Now define a "new",which refers to the "enum" and whether to use the ticket "CheckPing":
NOTE: These last two should go to the top of your script.

new SpInfo[MAX_PLAYERS][playerInfo];

Now, get to "public OnGameModeInt()" and put a timer wich is function to check player ping:

public OnGameModeInit()
{
SetTimer("AntiLaag",500,1);

return 1;
}


Follow this, make function check player ping:

public AntiLaag()
{
   for(new i = 0; i <= MAX_PLAYERS; i++) {
   new sendmsn[256],plr = FindPlayerIDFromString(gPlayers[i]);

if (SpInfo[plr][CheckPing] == 1 && GetPlayerPing(plr) >= 1000) {
   format(sendmsn,256, "Server - Kicked: %s, ID: %d, Reason:[ High Ping - %d ].",gPlayers[plr],plr,GetPlayerPing(plr));
           SendClientMessageToAll(0x377DFFFF,sendmsn);
   Kick(plr);
   }
}
}


Now, get to "public OnPlayerSpawn(playerid,classid,teamid)", and put ticket to send value 1, and thus in the function "public AntiLaag()", check if have value 1:

public OnPlayerSpawn(playerid,classid,teamid)
{
       SpInfo[playerid][CheckPing] = 1;

return 1;
}


And put also ticket but with value 0 when a player leave server, this is in "OnPlayerDisconnect(playerid, reason)":

public OnPlayerDisconnect(playerid, reason)
{
SpInfo[playerid][CheckPing] = 0;

return 1;
}


NOTE: if not have define "gPlayers", you need define, also if not have "FindPlayerIDFromString".

I hope something will help them in any problems please tell me.

Credits: YO ( Madara ).

Greetings  ;)

tato






<!-- Facebook Badge START --><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Eduardo Estrada">Eduardo Estrada</a><br/><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" title="Eduardo Estrada"><img src="http://badge.facebook.com/badge/697470158.6069.1979465113.png" width="120" height="272" style="b

John321


tato






<!-- Facebook Badge START --><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Eduardo Estrada">Eduardo Estrada</a><br/><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" title="Eduardo Estrada"><img src="http://badge.facebook.com/badge/697470158.6069.1979465113.png" width="120" height="272" style="b

yazeen

I can make this not good than your other releases !  :D

tato






<!-- Facebook Badge START --><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Eduardo Estrada">Eduardo Estrada</a><br/><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" title="Eduardo Estrada"><img src="http://badge.facebook.com/badge/697470158.6069.1979465113.png" width="120" height="272" style="b

sseebbyy

#6
500 minisec ?

Man...

When a player connects to the server has a high ping but that only lasts a second, and if it's set 500 as a player will enter and exit...

And I'll post an anti-ping !

PS: Sorry for my bad english  ;D !

Madara

#7
English:
My function first check player if have ticket "CheckPing", be cause if not have that ticket, no check the player. And that ticket is sent when a player spawn, your value in player is 0 when connect, when spawn, your value player is 1, and is there when it starts to check the ping.

public OnPlayerSpawn(playerid,classid,teamid)
{
       SpInfo[playerid][CheckPing] = 1;// here sent to player your CheckPing value 1 for check if have high ping. while have value in 0 (when connected), can't are kick.

return 1;
}


QuoteAnd I'll post an anti-ping !

PS: Sorry for my bad english  Grin !

I upload thi function ago as 10 hours before your


EspaƱol:

Mi funcion primero cheka si tiene el ticket del jugador "CheckPing", por que si no tiene ese ticket, no cheka al jugador. y ese ticket es enviado cuanto se genera ( spawn ), puesto que su valor de ese tag esta en 0 cuando se conecta, cuando genera, su valor se convierte en 1, y con eso puede empezar la funcion a chekar si tiene alto ping.

public OnPlayerSpawn(playerid,classid,teamid)
{
        SpInfo[playerid][CheckPing] = 1;// aqui envia su CheckPing al valor 1 para checar si tiene alto ping. cuando el valor lo tiene en 0 (cuando se conecta), no puede kickearlo.

return 1;
}


QuoteAnd I'll post an anti-ping !

PS: Sorry for my bad english  Grin !

Esta funcion la subi hace 12 horas antes que tu.

sseebbyy

#8
Good and Sorry... :D

I am beginner

BIG[H]

Good Work Madara i like your ahh Individual Player Timer
plr = FindPlayerIDFromString(Player[playerid][Name]
);
But It in Already in Black Panther Before You 2 i added in my BlacK Panther XD
My Guru FORUM MUST VISITmegavcmp.freeforums.org

BIG[H] = BIG HaLL

Charleyutton

Hahaha, are you calling a timer to loop round all the players every half a second? If you add much more to this script then it will lag the server down heavily.
Charleyutton, VU clan leader, VCDC co-creator, SvM Server Owner, Squirrel Scripter. http://vu.vrocker-hosting.co.uk http://svm.vrocker-hosting.co.uk XE Scripter

Scripter

Quote from: Charleyutton on March 28, 2011, 10:43:12 AM
Hahaha, are you calling a timer to loop round all the players every half a second? If you add much more to this script then it will lag the server down heavily.
oo lag

Madara

Quote from: BIG[H] on March 28, 2011, 09:27:40 AM
Good Work Madara i like your ahh Individual Player Timer
plr = FindPlayerIDFromString(Player[playerid][Name]
);
But It in Already in Black Panther Before You 2 i added in my BlacK Panther XD

How?

Quote from: Charleyutton on March 28, 2011, 10:43:12 AM
Hahaha, are you calling a timer to loop round all the players every half a second? If you add much more to this script then it will lag the server down heavily.

True, but can change the seconds for other.

Charleyutton

No matter what, this is gonna be a laggy addition to any script. I suggest if you want to kick high pingers, add a simple ping check on player spawn.
Charleyutton, VU clan leader, VCDC co-creator, SvM Server Owner, Squirrel Scripter. http://vu.vrocker-hosting.co.uk http://svm.vrocker-hosting.co.uk XE Scripter

tato






<!-- Facebook Badge START --><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Eduardo Estrada">Eduardo Estrada</a><br/><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" title="Eduardo Estrada"><img src="http://badge.facebook.com/badge/697470158.6069.1979465113.png" width="120" height="272" style="b