[HELP] Detecting most kills?
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
pawn Код:
new
    gLeader = -1,
    gHighScore = 0,
    gScore[MAX_PLAYERS];


public OnPlayerDeath(playerid, killerid, reason)
{
    ++gScore[killerid];
    if (gScore[killerid] > gHighScore)
    {
        gHighScore = gScore[killerid];
        gLeader = killerid;
    }
    return 1;
}
That will do away with the loop by keeping track of the leader. Note that this code will require additional code in OnPlayerConnect and OnPlayerDisconnect for when people leave and join so the leader is known to be on the server.

And "++var;" is the pre-increment operator, "var++;" is the post-increment operator and they are different, though the difference doesn't matter in this code example.
Alright, thanks a bunch for explaining it.
Reply


Messages In This Thread
[HELP] Detecting most kills? - by RoCK'N'Rolla - 18.08.2010, 09:33
Re: [HELP] Detecting most kills? - by RoCK'N'Rolla - 18.08.2010, 09:46
Re: [HELP] Detecting most kills? - by Sky4D - 18.08.2010, 15:27
Re: [HELP] Detecting most kills? - by Dark_Kostas - 18.08.2010, 15:36
Re: [HELP] Detecting most kills? - by Sky4D - 18.08.2010, 15:38
Re: [HELP] Detecting most kills? - by Sky4D - 18.08.2010, 18:22
Re: [HELP] Detecting most kills? - by RoCK'N'Rolla - 19.08.2010, 10:44

Forum Jump:


Users browsing this thread: 6 Guest(s)