Quote:
Originally Posted by MeRcyLeZZ
That's pretty neat, how did you manage to find those? I'm going to see if I can send all pings on a single message now, that should reduce bandwidth usage a lot.
|
I know how to parse all svc_ messages, and ofc added some to wiki.
But i can`t understand how works fix_fake_pings.
Code:
register_event("DeathMsg", "fix_fake_pings", "a")
register_event("TeamInfo", "fix_fake_pings", "a")
public fix_fake_pings()
{
......
fw_UpdateClientData(player)
......
}
public fw_UpdateClientData(id)
{
....
if (!(pev(id, pev_button) & IN_SCORE) && !(pev(id, pev_oldbuttons) & IN_SCORE))
return;
...
}
So, when fix_fake_pings triggered, it launch fw_UpdateClientData for all players, but fw_UpdateClientData send messages only for players which "currently" holding IN_SCORE button. So at that time players can see their real ping.
Also right after connect, server send to player svc_pings, so better to add delayed exec with forcing ping. I give advice coz fixed those things in my own plugin that working with ping.
And I see amazing packet calculation
Test code for you, with sending all in one message:
Code:
stock send_pings_test(id)
{
static player;
static p_ping[33]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32};
static p_loss[33]={0,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132};
new bb;//byte buffer
new bits;
//we should have at least ourself to send ping, or we`ll send empty message and as I suppose get error :) but never tested that moment
message_begin(MSG_ONE_UNRELIABLE, SVC_PINGS, _, id);
for (player = 1; player <= 32; player++)
{
//lets send info about all possible players, even they are not on server
// if (! g_connected[player] )
// continue;
//CAP p_ping p_loss values, if they are too big to send
if ( p_ping[player] >= (1<<12) )
{
p_ping[player] = ((1<<12) - 1 );
}
if ( p_loss[player] >= (1<<7) )
{
p_loss[player] = ((1<<7) - 1 );
}
bb += (1 + ( (player - 1) << 1) + ( p_ping[player] << 6) ) << bits; // (player - 1) coz in that message: message_slot=player_id-1;
bits += 18;
for( ;bits >= 8;bits -= 8, bb >>= 8 )
{
write_byte( bb ); // or write: bb&((1<<8)-1)
}
bb += (p_loss[player] << bits );
bits += 7;
for( ;bits >= 8;bits -=8, bb >>= 8 )
{
write_byte( bb );
}
}
write_byte( bb ); //write last part or finalize message
message_end();
}
Unfortunally we can send that message only with write_byte
![Sad](images/smilies/frown.gif)
and in 2 parts
![Sad](images/smilies/frown.gif)
otherwise it`s exceed byte buffer size and corrupt it. Or we need to add support of buffer with more than 4 bytes in it.