Raised This Month: $350 Target: $400
 87%   Almost there!

Solved [Any] Ping Viewer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alasfourom
Senior Member
Join Date: Feb 2022
Old 05-08-2022 , 10:05   [Any] Ping Viewer
Reply With Quote #1

Description:
  • Display Players Ping Using Command

Why This:
  • Since some mods with extra players, using "TAP" may not show their ping
  • Using "TAP" doesn't always show you the actual real ping
  • Some players don’t know how to open console and type ping

Thanks:
  • `666 > rewriting the script
  • Bacardi > providing color codes
  • PC Gamer > adding commands to display all players ping

Commands:
  • sm_ping <#userid|name> Display Any Player Ping Using Their Names > !ping @me, !ping @all, !ping NAME
    Mario: 25 ms


  • sm_myping > Print Your Current Ping
    Your Current Ping: 25 ms


  • sm_allping > Print All Players Ping
    Players Ping Status:
    Mario: 25 ms
    Sonic: 25 ms


Installation:
  • Put the "L4D2_Nuke.smx" file in your "\addons\sourcemod\plugins" folder.


Updates:
Code:
  • Version 1.5 (30-Aug-2022) - Added a new command to target any player.
  • Version 1.4 (05-June-2022) - added more commands.
  • Version 1.3 (10-May-2022) - Thanks To PC Gamer, for adding a new command.
  • Version 1.2 (08-May-2022) - Thanks To Bacardi, for color codes.
  • Version 1.1 (08-May-2022) - Thanks To `666, for rewriting it and converting it to milliseconds.
  • Version 1.0 (08-May-2022) - Initial release.
Attached Files
File Type: sp Get Plugin or Get Source (Ping Viewer.sp - 295 views - 3.8 KB)

Last edited by alasfourom; 07-30-2022 at 05:06. Reason: Updated
alasfourom is offline
`666
AlliedModders Donor
Join Date: Jan 2006
Old 05-08-2022 , 11:58   Re: Ping Viewer - Issue
Reply With Quote #2

PHP Code:
#pragma semicolon 1
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

public Plugin myinfo = {
    
name "Ping_Viewer",
    
author "",
    
description "Print Your Ping Into Chat",
    
version "1.0",
    
url "https://forums.alliedmods.net/"
};

public 
void OnPluginStart() {
    
RegConsoleCmd("sm_ping"Command_Ping"Print Ping To Chat");
}

public 
Action Command_Ping(int clientint args) {
    if (
IsClientInGame(client) && !IsFakeClient(client)) {
        
char sBuffer[64];
        
FormatEx(sBuffersizeof(sBuffer), "\x01Your Current Ping:\x070088cc %.3f\x01 ms"GetClientAvgLatency(clientNetFlow_Both));
        
ReplaceString(sBuffersizeof(sBuffer), "0.00"""false);
        
ReplaceString(sBuffersizeof(sBuffer), "0.0"""false);
        
ReplaceString(sBuffersizeof(sBuffer), "0."""false);
        
PrintToChat(clientsBuffer);
    }
    return 
Plugin_Handled;

Don't know if colour works for your game, but it works for insurgency.
0088cc is RGB colour code part

Last edited by `666; 05-08-2022 at 12:10.
`666 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 05-08-2022 , 20:36   Re: Ping Viewer - Issue
Reply With Quote #3

It return seconds. You just convert to milliseconds.
And decimal value can be remove %.0f
https://wiki.alliedmods.net/Format_C...ced_Formatting
PHP Code:
   fClientPing GetClientAvgLatency(iNetFlow_Both);
   
fClientPing fClientPing 1000.0;
 
  
PrintToChat(client"\x03Your Current Ping: %.0f ms"fClientPing); 
About color, you not need use other script file.
Try different characters: \x01 \x02 \x03 \x04 ... \x0A \x0B ... \x0F
__________________
Do not Private Message @me

Last edited by Bacardi; 05-08-2022 at 20:38.
Bacardi is offline
alasfourom
Senior Member
Join Date: Feb 2022
Old 05-08-2022 , 21:21   Re: Ping Viewer - Issue
Reply With Quote #4

Quote:
It return seconds. You just convert to milliseconds.
And decimal value can be remove %.0f
https://wiki.alliedmods.net/Format_C...ced_Formatting
PHP Code:
   fClientPing GetClientAvgLatency(iNetFlow_Both);
   
fClientPing fClientPing 1000.0;
 
  
PrintToChat(client"\x03Your Current Ping: %.0f ms"fClientPing); 
About coloryou not need use other script file
Try different characters: \x01 \x02 \x03 \x04 ... \x0A \x0B ... \x0F
I see now, your colors code also worked for me

Quote:
PHP Code:
#pragma semicolon 1
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

public Plugin myinfo = {
    
name "Ping_Viewer",
    
author "",
    
description "Print Your Ping Into Chat",
    
version "1.0",
    
url "https://forums.alliedmods.net/"
};

public 
void OnPluginStart() {
    
RegConsoleCmd("sm_ping"Command_Ping"Print Ping To Chat");
}

public 
Action Command_Ping(int clientint args) {
    if (
IsClientInGame(client) && !IsFakeClient(client)) {
        
char sBuffer[64];
        
FormatEx(sBuffersizeof(sBuffer), "\x01Your Current Ping:\x070088cc %.3f\x01 ms"GetClientAvgLatency(clientNetFlow_Both));
        
ReplaceString(sBuffersizeof(sBuffer), "0.00"""false);
        
ReplaceString(sBuffersizeof(sBuffer), "0.0"""false);
        
ReplaceString(sBuffersizeof(sBuffer), "0."""false);
        
PrintToChat(clientsBuffer);
    }
    return 
Plugin_Handled;

Don't know if colour works for your game, but it works for insurgency.
0088cc is RGB colour code part
It also worked great, since I'm using it for L4D2 > the code color didn't work but the codes posted by Bacardi, did work

Appreciate it guys, thanks a lot

Here is The Result:

Attached Files
File Type: sp Get Plugin or Get Source (Ping_Viewer.sp - 128 views - 913 Bytes)

Last edited by alasfourom; 05-08-2022 at 21:50.
alasfourom is offline
TQH
Junior Member
Join Date: May 2021
Location: Vietnam
Old 05-10-2022 , 05:03   Re: Ping Viewer - Issue
Reply With Quote #5

That's so great! Can you make a version that shows the ping of all players?
Ex: John: 10 ms; Hana: 19 ms; Peter: 3 ms;...

Thank you so much PC Gamer! @};-

Last edited by TQH; 05-10-2022 at 06:14.
TQH is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 05-10-2022 , 05:53   Re: Ping Viewer - Issue
Reply With Quote #6

Quote:
Originally Posted by TQH View Post
That's so great! Can you make a version that shows the ping of all players?
Ex: John: 10 ms; Hana: 19 ms; Peter: 3 ms;...
This should do it...
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

public Plugin myinfo = {
    
name "Ping_Viewer",
    
author "alasfourom, modified by PC Gamer",
    
description "Print Your Ping Into Chat",
    
version "1.1",
    
url "https://forums.alliedmods.net/"
};

public 
void OnPluginStart() {
    
RegConsoleCmd("sm_ping"Command_Ping"Print Ping To Chat");
    
RegAdminCmd("sm_pingall"Command_PingAllADMFLAG_SLAY"Print all Human Ping values to chat");     
}

public 
Action Command_Ping(int clientint args)
{
    if (
IsClientInGame(client) && !IsFakeClient(client))
    {
        
char sBuffer[64];
        
FormatEx(sBuffersizeof(sBuffer), "\x04Your Current Ping:\x05 %.3f ms"GetClientAvgLatency(clientNetFlow_Both));
        
ReplaceString(sBuffersizeof(sBuffer), "0.00"""false);
        
ReplaceString(sBuffersizeof(sBuffer), "0.0"""false);
        
ReplaceString(sBuffersizeof(sBuffer), "0."""false);
        
PrintToChat(clientsBuffer);
    }
    return 
Plugin_Handled;


public 
Action Command_PingAll(int clientint args)
{
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && !IsFakeClient(i)) 
        {
            
char sBuffer[64];
            
FormatEx(sBuffersizeof(sBuffer), "\x04Current Ping:\x05 %.3f ms"GetClientAvgLatency(iNetFlow_Both));
            
ReplaceString(sBuffersizeof(sBuffer), "0.00"""false);
            
ReplaceString(sBuffersizeof(sBuffer), "0.0"""false);
            
ReplaceString(sBuffersizeof(sBuffer), "0."""false);
            
PrintToChat(client"%N: %s"isBuffer);
        }
    }
    return 
Plugin_Handled;

PC Gamer is offline
alasfourom
Senior Member
Join Date: Feb 2022
Old 05-10-2022 , 11:15   Re: Ping Viewer - Issue
Reply With Quote #7

Thanks pc gamer,

Main post updated

Last edited by alasfourom; 05-11-2022 at 01:44.
alasfourom is offline
spic
Junior Member
Join Date: Feb 2022
Old 05-10-2022 , 12:29   Re: Ping Viewer - Issue
Reply With Quote #8

This is really cool, thanks for sharing
spic is offline
yabi
Member
Join Date: Jun 2021
Location: Taiwan
Old 07-15-2022 , 20:37   Re: Ping Viewer
Reply With Quote #9

Quote:
Originally Posted by alasfourom View Post
Updated


Feature:
Display players ping, since some players don’t know how to open console and type ping, also some mods with extra players, your ping will not be visible if you pressed “TAP”


How does it look like:
If you typed "!ping", it will show you like this






If you typed "!pings", "!pingall", "!pinglist" it will show you like this






Many thanks to:
- ‘666
- Bacardi
- PC Gamer


-

i request here
When I type !pingall
All other friends and I can see the ping
In this way, teammates don't need to input anymore~ Everyone can clearly know their ping
yabi is offline
alasfourom
Senior Member
Join Date: Feb 2022
Old 07-16-2022 , 04:04   Re: Ping Viewer
Reply With Quote #10

Quote:
Originally Posted by yabi View Post
i request here
When I type !pingall
All other friends and I can see the ping
In this way, teammates don't need to input anymore~ Everyone can clearly know their ping
Attached Files
File Type: sp Get Plugin or Get Source (Ping_Viewer.sp - 34 views - 1.7 KB)

Last edited by alasfourom; 07-16-2022 at 09:40.
alasfourom is offline
Reply


Thread Tools
Display Modes

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 07:22.


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