Code:
#include <fakemeta>
// check_type determines which way to find best player
// check_type = 0 -- most frags
// check_type = 1 -- best difference in frags to deaths (frags - deaths)
// check_type = 2 -- best ratio of frags per deaths (frags / deaths)
get_team_leader(team, check_type)
{
new bestClient = 0;
new Float:bestFrags = -9999.9;
static Float:frags, deaths;
// g_max_clients = get_maxplayers();
for( new client = 1; client <= g_max_clients; client++ )
{
if( !is_user_connected(client) || get_pdata_int(client, 114) != team) continue;
pev(client, pev_frags, frags);
switch( check_type )
{
//case 0: frags = frags;
case 1: frags -= get_pdata_int(client, 444);
case 2:
{
deaths = get_pdata_int(client, 444);
frags /= (deaths ? deaths : 1);
}
}
if( frags > bestFrags )
{
bestFrags = frags;
bestClient = client;
}
}
return bestClient;
}
__________________