AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get total ping (https://forums.alliedmods.net/showthread.php?t=87130)

biscuit628 03-07-2009 08:48

get total ping
 
how can i get the all player total ping?
the server has 5players playing,
Player a ping is 10..
Player b ping is 20..
Player c ping is 16..
Player d ping is 5..
Player e ping is 30..

a+b+c+d+e = TotalPing

DruGzOG 03-07-2009 08:55

Re: get total ping
 
Its when you press tab (Player Status Hud) The Latency ____

biscuit628 03-07-2009 08:56

Re: get total ping
 
Quote:

Originally Posted by DruGzOG (Post 775708)
Its when you press tab (Player Status Hud) The Latency ____

i mean how to script that in sma

ConnorMcLeod 03-07-2009 09:03

Re: get total ping
 
PHP Code:

new iPlayers[32], iNumiTotalPingiPingiLoss

// get the players num and save their id into iPlayers array
get_players(iPlayersiNum)
for(new 
ii<iNumi++)
{
    
// for each array cell that contain the id of a connected player, retrieve the player ping
    
get_user_ping(iPlayers[i], iPingiLoss)

    
// add this ping ti the variable iTotalPing
    
iTotalPing += iPing



biscuit628 03-07-2009 09:46

Re: get total ping
 
Quote:

Originally Posted by ConnorMcLeod (Post 775713)
PHP Code:

new iPlayers[32], iNumiTotalPingiPingiLoss

// get the players num and save their id into iPlayers array
get_players(iPlayersiNum)
for(new 
ii<iNumi++)
{
    
// for each array cell that contain the id of a connected player, retrieve the player ping
    
get_user_ping(iPlayers[i], iPingiLoss)

    
// add this ping ti the variable iTotalPing
    
iTotalPing += iPing




thank:)
i am trying to script a plugin
but still have many error.
PHP Code:

#include <amxmodx>

public plugin_init()
{
  
register_plugin("ServerPing","1.0","Biscuit")
}

public 
TotalPing(){
    new 
iPlayers[32],iServerPingiNumiTotalPingiPingiLoss

    
// get the players num and save their id into iPlayers array
    
get_players(iPlayersiNum)
    for(new 
ii<iNumi++)
    {
        
// for each array cell that contain the id of a connected player, retrieve the player ping
        
get_user_ping(iPlayers[i], iPingiLoss)

        
// add this ping ti the variable iTotalPing
        
iTotalPing += iPing
        iServerPing 
== iTotalPing get_playersnum()
    }  
}

public 
Pingshow(){
    if(
iServerPing) <= 20{
        
client_print(0,print_chat,"ServerPing is very good")
            }
     else if(
iServerPing) >= 21 && (iServerPing) <= 50{
        
client_print(0,print_chat,"ServerPing is generally")
            }
     else(
iServerPing) >= 51{
        
client_print(0,print_chat,"ServerPing is Bad")
            }



ConnorMcLeod 03-07-2009 10:14

Re: get total ping
 
iServerPing == iTotalPing / get_playersnum()

->

Put this OUTSIDE of the for loop :
iServerPing = iTotalPing / iNum

biscuit628 03-07-2009 12:46

Re: get total ping
 
Quote:

Originally Posted by ConnorMcLeod (Post 775738)
iServerPing == iTotalPing / get_playersnum()

->

Put this OUTSIDE of the for loop :
iServerPing = iTotalPing / iNum

i am making like this at now..
but i still get a problem
set_cvar_string is not work?
PHP Code:

#include <amxmodx>

public plugin_init()
{
  
register_plugin("ServerPing","1.0","Biscuit")
  
register_cvar("ServerPing","-999")
  
register_cvar("Pingconnect","--")
}

public 
TotalPing(){
    new 
iPlayers[32], ServerPingiNumiTotalPingiPingiLoss

    
// get the players num and save their id into iPlayers array
    
get_players(iPlayersiNum)
    for(new 
i=0iNumi++)
    {
        
// for each array cell that contain the id of a connected player, retrieve the player ping
        
get_user_ping(iPlayers[i], iPingiLoss)

        
// add this ping ti the variable iTotalPing
        
iTotalPing += iPing
    
}
    
ServerPing iTotalPing iNum
    set_cvar_num
("ServerPing",ServerPing)
}

public 
Pingshow(){
    new 
ServerPing
        ServerPing 
get_cvar_num ("ServerPing")
    if(
ServerPing <= 20){
        
set_cvar_string("Pingconnect","Cool")
    }else if (
ServerPing >= 21 && ServerPing <= 50){
        
set_cvar_string("Pingconnect","Not Bad")
    }else{
        
set_cvar_string("Pingconnect","Worst)
    }
    set_task(10,"
Pingshow")



iNspiratioN 03-07-2009 13:13

Re: get total ping
 
I think i fixed it.

Compiles fine now. No errors.

PHP Code:

#include <amxmodx>

public plugin_init()
{
    
register_plugin("ServerPing","1.0","Biscuit")
    
register_cvar("ServerPing","-999")
    
register_cvar("Pingconnect","--")
}

public 
TotalPing(){
    new 
iPlayers[32], ServerPingiNumiTotalPingiPingiLoss
    
    
// get the players num and save their id into iPlayers array
    
get_players(iPlayersiNum)
    for(new 
i=0iNumi++)
    {
        
// for each array cell that contain the id of a connected player, retrieve the player ping
        
get_user_ping(iPlayers[i], iPingiLoss)
        
        
// add this ping ti the variable iTotalPing
        
iTotalPing += iPing
    
}
    
ServerPing iTotalPing iNum
    set_cvar_num
("ServerPing",ServerPing)
}

public 
Pingshow(){
    new 
ServerPing
    ServerPing 
get_cvar_num ("ServerPing")
    if(
ServerPing <= 20){
        
set_cvar_string("Pingconnect","Cool")
    }else if (
ServerPing >= 21 && ServerPing <= 50){
        
set_cvar_string("Pingconnect","Not Bad")
    }else{
        
set_cvar_string("Pingconnect","Worst")
    }
    
set_task(10.0,"Pingshow")



biscuit628 03-07-2009 14:01

Re: get total ping
 
Quote:

Originally Posted by iNspiratioN (Post 775864)
I think i fixed it.

Compiles fine now. No errors.

The cvar "Pingconnect" cannot change by set_cvar_string..
it only show the cvar"--"

iNspiratioN 03-07-2009 14:09

Re: get total ping
 
You want it to show it?


Like this?
PHP Code:

#include <amxmodx>

public plugin_init()
{
    
register_plugin("ServerPing","1.0","Biscuit")
    
register_cvar("ServerPing","-999")
}

public 
TotalPing(){
    new 
iPlayers[32], ServerPingiNumiTotalPingiPingiLoss
    
    
// get the players num and save their id into iPlayers array
    
get_players(iPlayersiNum)
    for(new 
i=0iNumi++)
    {
        
// for each array cell that contain the id of a connected player, retrieve the player ping
        
get_user_ping(iPlayers[i], iPingiLoss)
        
        
// add this ping ti the variable iTotalPing
        
iTotalPing += iPing
    
}
    
ServerPing iTotalPing iNum
    set_cvar_num
("ServerPing",ServerPing)
}

public 
Pingshow(){
    new 
id read_data(1)
    new 
ServerPing
    ServerPing 
get_cvar_num ("ServerPing")
    if(
ServerPing <= 20){
        
client_print(idprint_chat"ServerPing is good")
    }else if (
ServerPing >= 21 && ServerPing <= 50){
        
client_print(idprint_chat"ServerPing is generally")
    }else{
        
client_print(idprint_chat"ServerPing is bad")
    }


P.S acctualy i don't get it what you want...


All times are GMT -4. The time now is 08:54.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.