03.02.2011, 06:15
Hey guys im wondering how can i detect the player with the most kills. I'm willing to make a sort of high score system with a friend :/
if(!strcmp(cmdtext, "/highestscore", true))
{
if(IsPlayerConnected(playerid))
{
#define TOPLINE 10
new
Player_ID[TOPLINE],
Top_Info[TOPLINE];
foreach(Player, i)
// for(new i, max_players = GetMaxPlayers(); i < max_players; i++)
{
// if(!IsPlayerConnected(i)) continue;
HighestTopList(i, GetPlayerScore(i), Player_ID, Top_Info, TOPLINE);
}
SendClientMessage(playerid, 0xFFFFFFAA, "Highest Score:");
for(new i; i < TOPLINE; i++)
{
if(Top_Info[i] <= 0) continue;
format(string, sizeof string, " %s ID:%d - $%d", plName(Player_ID[i]), Player_ID[i], Top_Info[i]);
SendClientMessage(playerid, 0xFFFFFFAA, string);
}
#undef TOPLINE
return 1;
}
}
stock HighestTopList(const playerid, const Valuez, Player_ID[], Top_Score[], Loop) // Created by Phento
{
new
t = 0,
p = Loop-1;
while(t <= p) {
if(Valuez >= Top_Score[t]) {
if(Top_Score[t+1] <= 0) p = t+1;
while(p > t) { Top_Score[p] = Top_Score[p - 1]; Player_ID[p] = Player_ID[p - 1]; p--; }
Top_Score[t] = Valuez; Player_ID[t] = playerid;
break;
} t++; }
return 1;
}