Vice City Multiplayer

VC:MP => mIRC/pawn Scripting => ShowRoom (pawn) => Topic started by: Madara on March 27, 2011, 11:15:54 PM

Title: Kick to High Ping by Madara
Post by: Madara on March 27, 2011, 11:15:54 PM
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  ;)
Title: Re: Kick to High Ping by Madara
Post by: tato on March 28, 2011, 01:15:25 AM
O_O :D thanks madara ...luck!
Title: Re: Kick to High Ping by Madara
Post by: John321 on March 28, 2011, 03:42:57 AM
nice one madara ;)
Title: Re: Kick to High Ping by Madara
Post by: tato on March 28, 2011, 04:40:30 AM
ye nice
Title: Re: Kick to High Ping by Madara
Post by: yazeen on March 28, 2011, 05:07:39 AM
I can make this not good than your other releases !  :D
Title: Re: Kick to High Ping by Madara
Post by: tato on March 28, 2011, 05:09:03 AM
Quote from: yazeen on March 28, 2011, 05:07:39 AM
I can make this not good than your other releases !  :D
why?
Title: Re: Kick to High Ping by Madara
Post by: sseebbyy on March 28, 2011, 08:20:43 AM
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 !
Title: Re: Kick to High Ping by Madara
Post by: Madara on March 28, 2011, 09:10:59 AM
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.
Title: Re: Kick to High Ping by Madara
Post by: sseebbyy on March 28, 2011, 09:15:49 AM
Good and Sorry... :D

I am beginner
Title: Re: Kick to High Ping by Madara
Post by: 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
Title: Re: Kick to High Ping by Madara
Post by: 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.
Title: Re: Kick to High Ping by Madara
Post by: Scripter on March 28, 2011, 12:10:53 PM
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
Title: Re: Kick to High Ping by Madara
Post by: Madara on March 28, 2011, 08:31:27 PM
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.
Title: Re: Kick to High Ping by Madara
Post by: Charleyutton on March 29, 2011, 01:00:15 AM
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.
Title: Re: Kick to High Ping by Madara
Post by: tato on March 29, 2011, 03:16:49 AM
 ;D ;D
Title: Re: Kick to High Ping by Madara
Post by: [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
Title: Re: Kick to High Ping by Madara
Post by: Madara on April 01, 2011, 06:59:24 PM
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 )
Title: Re: Kick to High Ping by Madara
Post by: tato on April 02, 2011, 02:11:42 AM
mmmm cool pretty cool !!!
Title: Re: Kick to High Ping by Madara
Post by: yazeen on April 07, 2011, 09:14:50 AM
Niceeeeeee! But simple