#include <amxmodx>
new const PluginInfo[][] = { "Round Best Player", "v1.0", "totopizza" };
new g_MaxPlayers;
new g_iCheckConnected;
public plugin_init() {
register_plugin(PluginInfo[0],PluginInfo[1],PluginInfo[2]);
register_event("HLTV", "RoundStart", "a", "1=0", "2=0")
g_MaxPlayers = get_maxplayers();
}
public RoundStart(id)
{
g_iCheckConnected = 0;
new iBestPlayer;
iBestPlayer = get_best_player();
new asesinatos, muertes;
asesinatos = get_user_frags(id);
muertes = get_user_deaths(id);
if(!is_user_connected(iBestPlayer) || !iBestPlayer)
return;
new szPlayerName[32];
get_user_name(iBestPlayer, szPlayerName, 31);
chatcolor(0,"!t%s !nes el lider del mapa con %d kills y %d muertes!", szPlayerName,asesinatos,muertes)
}
get_best_player()
{
new id, iLeader, iKills, iDeaths, iHighestKills, iLowestDeaths;
iHighestKills = -99999;
iLowestDeaths = 99999;
iLeader = -1;
new name[32];
for( new i = 1; i <= g_MaxPlayers; i++)
{
id = i;
if(!is_user_connected(id))
continue;
get_user_name(id, name, 31);
iKills = get_user_frags(id);
iDeaths = get_user_deaths(id);
if( iKills > iHighestKills)
{
iLeader = id;
iLowestDeaths = iDeaths;
iHighestKills = iKills;
}
if(iDeaths < iLowestDeaths)
{
if( iKills >= iHighestKills)
{
//Es el nuevo lider
iLeader = id;
iLowestDeaths = iDeaths;
iHighestKills = iKills;
}
}
}
if(g_iCheckConnected >= 3)
return -1;
if(!is_user_connected(iLeader))
{
g_iCheckConnected++
get_best_player();
}
return iLeader;
}
stock chatcolor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4")
replace_all(msg, 190, "!n", "^1")
replace_all(msg, 190, "!t", "^3")
replace_all(msg, 190, "!t2", "^0")
if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
write_byte(players[i])
write_string(msg)
message_end()
}
}
}
}