the richest guys in the server?
#8

Quote:
Originally Posted by Sergei
Посмотреть сообщение
@Finn
It checks if the variable richestplayer is set to INVALID_PLAYER_ID or not.

My code can be done via foreach aswell, didn't know the OP is using it;

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

    foreach(Player, playerid)
    {
        if(richestplayer != INVALID_PLAYER_ID)
        {
            if(GetPlayerMoney(richestplayer) < GetPlayerMoney(playerid))
            {
                richestplayer = playerid;
            }
        }
        else
        {
            richestplayer = playerid;
        }
    }

    return richestplayer;
}

//Or as you guys seem to like shorter code:
stock GetRichestPlayer()
{
    new r = INVALID_PLAYER_ID;
    foreach(Player, i)
    {
        if(r == INVALID_PLAYER_ID || GetPlayerMoney(r) < GetPlayerMoney(i))
        {
            r = i;
        }
    }
    return r;
}
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)