Client set ping
Posted: 2015 Jan 10 21:41
Hello ( Sorry i speak only english and frensh and its really bad x) ) ,
i've this script
[php] #include <amxmodx> #include <fakemeta> public plugin_init() { register_forward(FM_UpdateClientData, "fw_updateClientData") } public fw_updateClientData(id) { if ( ! ( pev(id, pev_button) & IN_SCORE ) ) return; new ping = 10 new ping1 new offset1 for(new player = 1; player < get_maxplayers(); player++) { if(!is_user_connected(id)) continue; for(new offset1 = 0; offset1 < 4; offset1++) { if ((ping - offset1) % 4 == 0) { ping1 = (ping - offset1) / 4 break; } } message_begin(MSG_ONE_UNRELIABLE, SVC_PINGS, _, id) write_byte((offset1 * 64) + (1 + 2 * (player - 1))) write_short(ping1) write_byte(0) message_end() } } [/php]
i need you to explain to me
this :
for(new offset1 = 0; offset1 < 4; offset1++)
{
if ((ping - offset1) % 4 == 0)
{
ping1 = (ping - offset1) / 4
break;
}
}
and this :
write_byte((offset1 * 64) + (1 + 2 * (player - 1)))
i've this script
[php] #include <amxmodx> #include <fakemeta> public plugin_init() { register_forward(FM_UpdateClientData, "fw_updateClientData") } public fw_updateClientData(id) { if ( ! ( pev(id, pev_button) & IN_SCORE ) ) return; new ping = 10 new ping1 new offset1 for(new player = 1; player < get_maxplayers(); player++) { if(!is_user_connected(id)) continue; for(new offset1 = 0; offset1 < 4; offset1++) { if ((ping - offset1) % 4 == 0) { ping1 = (ping - offset1) / 4 break; } } message_begin(MSG_ONE_UNRELIABLE, SVC_PINGS, _, id) write_byte((offset1 * 64) + (1 + 2 * (player - 1))) write_short(ping1) write_byte(0) message_end() } } [/php]
i need you to explain to me
this :
for(new offset1 = 0; offset1 < 4; offset1++)
{
if ((ping - offset1) % 4 == 0)
{
ping1 = (ping - offset1) / 4
break;
}
}
and this :
write_byte((offset1 * 64) + (1 + 2 * (player - 1)))