Display the most
#1

Hello, First of all I'll give you an example:

Код:
new kills[MAX_PLAYERS];

public OnPlayerDeath(playerid, killerid, reason)
{
    kills[killerid] += 1;
    return 1;
}
Example:
My name is Player1 and my kills are 5.
Player2's kills are 3.
Player3's kills are 2.

And my question is how to make a command to display player id with the most kills ?
Reply
#2

pawn Код:
new maxscore[2];
for(new i; i<MAX_PLAYERS; i++)
{
    if(maxscore[0] < kills[i])
    {
        maxscore[1] = i;
        maxscore[0] = kills[i];
    }
}
new Pname[24], str[100];
GetPlayerName(maxscore[1], Pname, 24);
format(str, sizeof(str), "%s(id:%d) has the highest score with the score of %d", maxscore[1], Pname, maxscore[0]);
SendClientMessageToAll(-1, str);
Something like that would work.
Reply
#3

Use something like if(kills[playerid] > 30)
Reply
#4

Thanks to [HiC]TheKiller, but if the kills are equal SendClientMessageToAll will display the player with fewer id. How to make when we have players with equal kills to give them a battle ?
Reply
#5

Quote:
Originally Posted by BGMike
Посмотреть сообщение
Thanks to [HiC]TheKiller, but if the kills are equal SendClientMessageToAll will display the player with fewer id. How to make when we have players with equal kills to give them a battle ?
To do this, I guess you have to script your own battles system. Do you have any one?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)