SA-MP Forums Archive
getting highest money on server.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: getting highest money on server.. (/showthread.php?tid=434063)



getting highest money on server.. - kizla - 30.04.2013

How to get top 5 richest guys on server online?


Re: getting highest money on server.. - MattyG - 30.04.2013

Try adding this under your command:

pawn Код:
new first = -1, second = -1, third = -1, fourth = -1, fifth = -1, firstamount, secondamount, thirdamount, fourthamount, fifthamount;
for(i=0;i<MAX_PLAYERS;i++)
{
    if(GetPlayerMoney(i)>firstamount)
    {
        first=i;
    }
    else if(GetPlayerMoney(i)>secondamount)
    {
        second=i;
    }
    else if(GetPlayerMoney(i)>thirdamount)
    {
        third=i;
    }
    else if(GetPlayerMoney(i)>fourthamount)
    {
        fourth=i;
    }
    else if(GetPlayerMoney(i)>fifthamount)
    {
        fifth=i;
    }
    else return 1;
}
new string[30]
SendClientMessage(playerid, COLOUR, "Richest people online now:");
format(string, sizeof(string), "1: %s", GetPlayerName(first);
SendClientMessage(playerid, COLOUR, string);
if(second != -1)
{
    format(string, sizeof(string), "2: %s", GetPlayerName(second);
    SendClientMessage(playerid, COLOUR, string);
}
if(third != -1)
{
    format(string, sizeof(string), "3: %s", GetPlayerName(third);
    SendClientMessage(playerid, COLOUR, string);
}
if(fourth != -1)
{
    format(string, sizeof(string), "4: %s", GetPlayerName(fourth);
    SendClientMessage(playerid, COLOUR, string);
}
if(fifth != -1)
{
    format(string, sizeof(string), "5: %s", GetPlayerName(fifth);
    SendClientMessage(playerid, COLOUR, string);
}
EDIT: Don't use that actually, it won't work if someone is in first, then someone comes above them.