Thread: [Solved] [Any] Ping Viewer
View Single Post
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
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 - 221 views - 913 Bytes)

Last edited by alasfourom; 05-08-2022 at 21:50.
alasfourom is offline