2 Players in Iter_Random
#1

How do I choose 2 players in Iter_Random?
Reply
#2

You can't, but you can make your own custom function to do that by comparing the first random player with the second one.
Reply
#3

Can you give me an example on how to do it? And yeah I know Iter_Random can't do that, My English sucks it should've been "How do I choose 2 players instead of one with the Iter_Random function"
Reply
#4

pawn Код:
TwoRandomPlayers(&player1, &player2)
{
    if (Iter_Count(Player) > 1)
    {
        player1 = Iter_Random(Player);

        do
        {
            player2 = Iter_Random(Player);
        }
        while (player1 == player2);
        return 1;
    }
    return 0;
}
Reply
#5

Will try it out, I appreciated all the helps I been getting from you @Konstantinos
Reply
#6

PHP код:
GetRandomPlayer()
{
    static 
Iterator:StaticList<MAX_PLAYERS>;
    if (
Iter_Size(StaticList) == 0)
    {
        foreach (new 
Player)
            
Iter_Add(i);
    }
    new 
ret Iter_Random(StaticList);
    
Iter_Remove(StaticListret);
    return 
ret;

If you are using the function for a significant amount of players at once (more than 2 or 5) plus this works for N number of players, N being number of connected players.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)