Raised This Month: $ Target: $400
 0% 

get total ping


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
biscuit628
Senior Member
Join Date: Jun 2007
Location: 香港HongKong
Old 03-07-2009 , 08:48   get total ping
Reply With Quote #1

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
biscuit628 is offline
DruGzOG
Veteran Member
Join Date: Nov 2007
Location: Unknown
Old 03-07-2009 , 08:55   Re: get total ping
Reply With Quote #2

Its when you press tab (Player Status Hud) The Latency ____
__________________
DruGzOG is offline
Send a message via AIM to DruGzOG
biscuit628
Senior Member
Join Date: Jun 2007
Location: 香港HongKong
Old 03-07-2009 , 08:56   Re: get total ping
Reply With Quote #3

Quote:
Originally Posted by DruGzOG View Post
Its when you press tab (Player Status Hud) The Latency ____
i mean how to script that in sma
biscuit628 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-07-2009 , 09:03   Re: get total ping
Reply With Quote #4

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

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
biscuit628
Senior Member
Join Date: Jun 2007
Location: 香港HongKong
Old 03-07-2009 , 09:46   Re: get total ping
Reply With Quote #5

Quote:
Originally Posted by ConnorMcLeod View Post
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")
            }


Last edited by biscuit628; 03-07-2009 at 10:12.
biscuit628 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-07-2009 , 10:14   Re: get total ping
Reply With Quote #6

iServerPing == iTotalPing / get_playersnum()

->

Put this OUTSIDE of the for loop :
iServerPing = iTotalPing / iNum
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
biscuit628
Senior Member
Join Date: Jun 2007
Location: 香港HongKong
Old 03-07-2009 , 12:46   Re: get total ping
Reply With Quote #7

Quote:
Originally Posted by ConnorMcLeod View Post
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")

biscuit628 is offline
iNspiratioN
Member
Join Date: Feb 2009
Location: Lithuania
Old 03-07-2009 , 13:13   Re: get total ping
Reply With Quote #8

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")

iNspiratioN is offline
biscuit628
Senior Member
Join Date: Jun 2007
Location: 香港HongKong
Old 03-07-2009 , 14:01   Re: get total ping
Reply With Quote #9

Quote:
Originally Posted by iNspiratioN View Post
I think i fixed it.

Compiles fine now. No errors.
The cvar "Pingconnect" cannot change by set_cvar_string..
it only show the cvar"--"
biscuit628 is offline
iNspiratioN
Member
Join Date: Feb 2009
Location: Lithuania
Old 03-07-2009 , 14:09   Re: get total ping
Reply With Quote #10

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...
iNspiratioN is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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