Hello. When I use this plugin (or use the server console 'status' command) it tells me I have a ping of 26. When I press the TAB key to view the scoreboard with my ping it states my ping is 5.
Repeated usage gives me similar numbers.
Why the difference?
#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_PingAll, ADMFLAG_SLAY, "Print all Human Ping values to chat");
}
public Action Command_Ping(int client, int args)
{
if (IsClientInGame(client) && !IsFakeClient(client))
{
char sBuffer[64];
FormatEx(sBuffer, sizeof(sBuffer), "\x04Your Current Ping:\x05 %.3f ms", GetClientAvgLatency(client, NetFlow_Both));
ReplaceString(sBuffer, sizeof(sBuffer), "0.00", "", false);
ReplaceString(sBuffer, sizeof(sBuffer), "0.0", "", false);
ReplaceString(sBuffer, sizeof(sBuffer), "0.", "", false);
PrintToChat(client, sBuffer);
}
return Plugin_Handled;
}
public Action Command_PingAll(int client, int args)
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && !IsFakeClient(i))
{
char sBuffer[64];
FormatEx(sBuffer, sizeof(sBuffer), "\x04Current Ping:\x05 %.3f ms", GetClientAvgLatency(i, NetFlow_Both));
ReplaceString(sBuffer, sizeof(sBuffer), "0.00", "", false);
ReplaceString(sBuffer, sizeof(sBuffer), "0.0", "", false);
ReplaceString(sBuffer, sizeof(sBuffer), "0.", "", false);
PrintToChat(client, "%N: %s", i, sBuffer);
}
}
return Plugin_Handled;
}
|