SA-MP Forums Archive
anti ping freeze player - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: anti ping freeze player (/showthread.php?tid=643940)



anti ping freeze player - billy1337samp - 30.10.2017

-removed- -----------


Re: anti ping freeze player - Konstantinos - 30.10.2017

When using const, it means that it cannot be modified. Besides that, when not setting a size for your string, its size becomes 46 in your case but a name can be up to 24 characters and ping can be a 3-digit or 4-digit number so it will be cut.


Re: anti ping freeze player - billy1337samp - 30.10.2017

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
When using const, it means that it cannot be modified. Besides that, when not setting a size for your string, its size becomes 46 in your case but a name can be up to 24 characters and ping can be a 3-digit or 4-digit number so it will be cut.
Код HTML:
fmt_str[46]
edit:
is this the right section where people can improve the script?


Re: anti ping freeze player - Arbico - 31.10.2017

Quote:
Originally Posted by billy1337samp
Посмотреть сообщение
Код HTML:
fmt_str[46]
edit:
is this the right section where people can improve the script?
Yeah.

By the way, Here is the code....

PHP код:
#define MAX_PING 15 //This is the max ping, you need to change it.
public OnPlayerUpdate(playerid) {
    if(
GetPlayerPing(playerid) > 15) {
        
//Do some stuff here.
    
}
    return 
1;




Re: anti ping freeze player - billy1337samp - 31.10.2017

Quote:
Originally Posted by Arbico
Посмотреть сообщение
Yeah.

By the way, Here is the code....

PHP код:
#define MAX_PING 15 //This is the max ping, you need to change it.
public OnPlayerUpdate(playerid) {
    if(
GetPlayerPing(playerid) > 15) {
        
//Do some stuff here.
    
}
    return 
1;

SORRY, i know i needed help but i spotted a mistake (incase anyone else wants to use that code)
he did
Код:
> 15
so
Код:
#define MAX_PING
is useless unless you write
Код:
> MAX_PING
This is how the code should look like:
PHP код:
#define MAX_PING 15
public OnPlayerUpdate(playerid) {
    if(
GetPlayerPing(playerid) > MAX_PING) {
        
//Execute code eg. Kick(playerid);
    
}
    return 
1;




Re: anti ping freeze player - Abagail - 31.10.2017

Well obviously that's going to spam, it executes the code whenever their ping is higher than MAX_PING (or below), with no exception. Instead you can try doing something such as:

pawn Код:
if (IllegalPing[i] == true && GetPlayerPing(i) < MAX_PLAYER_PING)
      {
              IllegalPing[i] = false;
              TogglePlayerControllable(i, true);
      }
   
      else if (IllegalPing[i] == false && (GetPlayerPing(i) > MAX_PLAYER_PING) && (GetPlayerPing(i) != 65535))
      {
          // send message or whatever else
          TogglePlayerControllable(i, false);
          IllegalPing[i] = true;
      }
Could also be optimized a little further by allowing a "grace period" in certain circumstances.


Re: anti ping freeze player - Arbico - 01.11.2017

Quote:
Originally Posted by billy1337samp
Посмотреть сообщение
SORRY, i know i needed help but i spotted a mistake (incase anyone else wants to use that code)
he did
Код:
> 15
so
Код:
#define MAX_PING
is useless unless you write
Код:
> MAX_PING
This is how the code should look like:
PHP код:
#define MAX_PING 15
public OnPlayerUpdate(playerid) {
    if(
GetPlayerPing(playerid) > MAX_PING) {
        
//Execute code eg. Kick(playerid);
    
}
    return 
1;

Yeah, thank you. I'm a fast typer, and therefore i make some mistakes.