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 ;)
O_O :D thanks madara ...luck!
nice one madara ;)
ye nice
I can make this not good than your other releases ! :D
Quote from: yazeen on March 28, 2011, 05:07:39 AM
I can make this not good than your other releases ! :D
why?
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 !
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.
Good and Sorry... :D
I am beginner
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
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.
Quote from: Charleyutton on March 28, 2011, 11: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
Quote from: BIG[H] on March 28, 2011, 10: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, 11: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.
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.
;D ;D
heii ola mmm soy KCHAT jejeje ske ya estaba registrado con estge nick xD bueno el caso es ke me marca error en esta linea
public AntiLaag()
{
for(new i = 0; i <= MAX_PLAYERS; i++) {
new sendmsn[256],plr = FindPlayerIDFromString(pInfo[NameSaved]); <------------------ ESPECIFICAMENTE EN ESTA
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);
}
}
}
====================================================================
Errores
F:\.......\......\......\gamemodes\DMGM3.5.pwn(2703) : error 028: invalid subscript (not an array or too many subscripts): "pInfo"
F:\......\......\......\gamemodes\DMGM3.5.pwn(2703) : warning 215: expression has no effect
F:\......\......\......\gamemodes\DMGM3.5.pwn(2703) : error 001: expected token: ";", but found "]"
F:\......\......\......\gamemodes\DMGM3.5.pwn(2703) : error 029: invalid expression, assumed zero
F:\......\......\......\gamemodes\DMGM3.5.pwn(2703) : fatal error 107: too many error messages on one line
Quote from: [CHG].Vercetty. on April 01, 2011, 03:32:36 PM
heii ola mmm soy KCHAT jejeje ske ya estaba registrado con estge nick xD bueno el caso es ke me marca error en esta linea
public AntiLaag()
{
for(new i = 0; i <= MAX_PLAYERS; i++) {
new sendmsn[256],plr = FindPlayerIDFromString(pInfo[NameSaved]); <------------------ ESPECIFICAMENTE EN ESTA
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);
}
}
}
====================================================================
Errores
F:\.......\......\......\gamemodes\DMGM3.5.pwn(2703) : error 028: invalid subscript (not an array or too many subscripts): "pInfo"
F:\......\......\......\gamemodes\DMGM3.5.pwn(2703) : warning 215: expression has no effect
F:\......\......\......\gamemodes\DMGM3.5.pwn(2703) : error 001: expected token: ";", but found "]"
F:\......\......\......\gamemodes\DMGM3.5.pwn(2703) : error 029: invalid expression, assumed zero
F:\......\......\......\gamemodes\DMGM3.5.pwn(2703) : fatal error 107: too many error messages on one line
Ahi deberias haber puesto un tipo de consulta de un nombre hacia un jugador, en este caso puedes ponerle gPlayers
( si es que lo tienes )
mmmm cool pretty cool !!!
Niceeeeeee! But simple