#include <amxmisc>
#include <amxmodx>
#include <fakemeta>
new offset[33][2], argument[33][3], override[33]={-1, ...};
public plugin_init()
{
register_plugin("Ping Optimize", "1.1", "Se_IaQe");
register_forward(FM_UpdateClientData, "fm_update_client_data");
}
public fm_update_client_data(id)
{
if(!(pev(id, pev_button)&IN_SCORE)&&!(pev(id, pev_oldbuttons)&IN_SCORE))
return;
static player, sending;
sending=0;
for(player=1; player<=get_maxplayers(); player++)
{
if(!is_user_connected(player))
continue;
switch(sending)
{
case 0:
{
message_begin(MSG_ONE_UNRELIABLE, SVC_PINGS, _, id);
write_byte((offset[player][0]*64)+(1+2*(player-1)));
write_short(argument[player][0]);
sending++;
}
case 1:
{
write_byte((offset[player][1]*128)+(2+4*(player-1)));
write_short(argument[player][1]);
sending++;
}
case 2:
{
write_byte((4+8*(player-1)));
write_short(argument[player][2]);
write_byte(0);
message_end();
sending=0;
}
}
}
if(sending)
{
write_byte(0);
message_end();
}
}
public plugin_cfg()
{
set_task(0.5, "plugin_read", 3426422);
}
public plugin_read()
{
set_task(0.5, "plugin_check", 4235621, _, _, "b");
}
public plugin_check()
{
static player, ping;
for(player=1; player<=get_maxplayers(); player++)
{
if(override[player]<0)
ping=clamp(clamp(12, 0, 4095)+random_num(-clamp(4, 0, 4095), clamp(4, 0, 4095)), 0, 4095);
else
ping=override[player];
for(offset[player][0]=0; offset[player][0]<4; offset[player][0]++)
{
if((ping-offset[player][0])%4==0)
{
argument[player][0]=(ping-offset[player][0])/4;
break;
}
}
for(offset[player][1]=0; offset[player][1]<2; offset[player][1]++)
{
if((ping-offset[player][1])%2==0)
{
argument[player][1]=(ping-offset[player][1])/2;
break;
}
}
argument[player][2]=ping;
}
}
public client_disconnected(id)
{
override[id]=-1;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/