14.06.2017, 10:26
add
new kills[MAX_PLAYERS];
on top of your script under includes and defines,
then under
I hope you can understand the code which I just wrote.
You\'re welcome.
new kills[MAX_PLAYERS];
on top of your script under includes and defines,
then under
Code:
public OnPlayerDeath(playerid, killerid, reason)
{
kills[killerid]++; //add this
return 1;
}
//Then under
public OnPlayerSpawn(playerid) // you can also use onplayerconnect...
{
new first, second, third, fourth, fifth;
//make a loop
for(new i=0;i<MAX_PLAYERS;i++) // This loop will check for the player that has the most kills
{
if(kills[i] > kills[first])
{
first = i;
}
}
for(new d=0;d<MAX_PLAYERS;d++) // This loop will check for the player that has the second most kills
{
if(first == d) continue;
if(kills[d] > kills[second])
{
second = d;
}
}
for(new s=0;s<MAX_PLAYERS;s++) // This loop will check for the player that has the third most kills
{
if(first == s || second == s) continue;
if(kills[s] > kills[third])
{
third = s;
}
}
for(new a=0;a<MAX_PLAYERS;a++) // This loop will check for the player that has the fourth most kills
{
if(first == a || second == a || third == a) continue;
if(kills[a] > kills[fourth])
{
fourth = a;
}
}
for(new c=0;c<MAX_PLAYERS;c++) // This loop will check for the player that has the fifth most kills
{
if(first == c || second == c || third == c || fourth == c) continue;
if(kills[c] > kills[fifth])
{
fifth = c;
}
}
//Now you have the top 5 players with most kills
/*Variables:
first - id of the player with most kills
second - id of the player with second most kills
third - id of the player with third most kills
fourth - id of the player with fourth most kills
fifth - id of the player with fifth most kills
*/
//Your only job now is to set the string of a textdraw to these 5 players and show it to a player that just connected(playerid)
return 1;
}
You\'re welcome.

