sputnikutah wrote:
So far every 5 seconds i stuff a command to the client that issues an impulse. The mod catches that impulse and records the time now and the last time that impulse was "caught" the difference * 1000 = that client's ping.
If you're using the internal.qc project included with qccx, you can get a clients ping this way,
Code:
float (entity e)
client_ping =
{
local float i, ping;
for (i = 0 ; i < %16 ; i = i + %1)
ping = ping + (e.cl[CL_PING_TIMES + i] * 1000);
ping = floor (ping / 16);
if (ping < 0)
ping = 0;
else if (ping > 9999)
ping = 9999;
return ping;
};
sputnikutah wrote:
the mod loops thru a find player loop and calls pqc_ping_times(player.ping) but then everyone has the same ping reported
should ping be (ping +(client_num*4096)) ?
Yes, however, don't loop through the players and call pqc_ping_times(), loop through the players inside pqc_ping_times().
For example,
Code:
void ()
pqc_ping_times =
{
local entity e;
local float i, ping;
WriteByte(MSG_ALL, SVC_STUFFTEXT);
WriteByte(MSG_ALL, 1);
WriteByte(MSG_ALL, PQC_PING_TIMES);
e = world;
for (i = 0; i < 16; i = i + 1)
{
e = nextent (e);
if (e.classname == "bodyque")
i = 16;
else if (e.cl[CL_ACTIVE] == %1 && e.delay)
{
ping = e.delay;
if (ping > 4095)
ping = 666;
WriteShortPQ (MSG_ALL, ping + (i * 4096));
}
}
WriteShortPQ (MSG_ALL, 0);
WriteString (MSG_ALL, string_null);
};
I use the .delay field to store the client ping. I populate this in PlayerPreThink() every second. Make sure that each client's ping value isn't less than zero or greater than 4095 or else it will screw up the client number.