the richest guys in the server?
#9

Quote:
Originally Posted by Sergei
Посмотреть сообщение
@Finn,

?

Код:
new richest = INVALID_PLAYER_ID, data[2];
foreach(Player,i)
{
     data[0] = GetPlayerMoney(i);
     if(data[0] && data[0] > data[1]) richest = i;
}
This would do the job.
Yours doesn't even work. You aren't assigning data[1]. Your use of the array for data[] is also slower than individual variables.

The OP can't even code this function and you expect him to add in foreach?

Quote:
Originally Posted by Finn
Посмотреть сообщение
Why so many variables?

pawn Код:
stock GetRichestPlayer()
{
    new richestplayer = INVALID_PLAYER_ID;

    for(new playerid; playerid < MAX_PLAYERS; playerid++)
    {
        if(IsPlayerConnected(playerid))
        {
            if(richestplayer != INVALID_PLAYER_ID)
            {
                if(GetPlayerMoney(richestplayer) < GetPlayerMoney(playerid))
                {
                    richestplayer = playerid;
                }
            }
            else
            {
                richestplayer = playerid;
            }
        }
    }

    return richestplayer;
}
3 embedded ifs and 2 calls to GetPlayerMoney? Mine is still far more efficient.
Reply


Messages In This Thread
the richest guys in the server? - by Rocky Balboa - 21.08.2010, 06:41
Re: the richest guys in the server? - by Rocky Balboa - 21.08.2010, 18:39
Re: the richest guys in the server? - by Rocky Balboa - 21.08.2010, 18:46
Re: the richest guys in the server? - by Voldemort - 22.08.2010, 19:03
Re: the richest guys in the server? - by nemesis- - 22.08.2010, 19:44
Re: the richest guys in the server? - by Finn - 22.08.2010, 20:52
Re: the richest guys in the server? - by Sergei - 22.08.2010, 21:05
Re: the richest guys in the server? - by Finn - 22.08.2010, 21:09
Re: the richest guys in the server? - by nemesis- - 22.08.2010, 22:44
Re: the richest guys in the server? - by Sergei - 23.08.2010, 06:18

Forum Jump:


Users browsing this thread: 1 Guest(s)