Select 2 Players
#1

Hello, how can i make that this chooses instead of one Player 2 Players?

Код:
stock OnePlayer()
{
    new count = 0;
    new Random = Iter_Random(Player);
    foreach(Player, i)
    {
        if(team[i] == TEAM_RED) count++;
        if(count == Iter_Count(Player))
        {
			SendClientMessage(playerid,COLOR_RED"You got chosen.");
        }
    }
    return 1;
}
Reply
#2

i dont think this even chooses one random player

im not familiar with ******'s libraries tho
Reply
#3

this select one player but i want that it chooses 2 players..
Reply
#4

Quote:
Originally Posted by Blackazur
Посмотреть сообщение
this select one player but i want that it chooses 2 players..
No it doesn't. It just gives them a message. Well, not even that because it sends the message to the player with the id in the variable "playerid", which is unknown, not even defined.
Reply
#5

pawn Код:
new Random = Iter_Random(Player);
Doesn't this gives you warnings? You aren't using it then why declare it?

pawn Код:
if(count == Iter_Count(Player))
This isn't required if all the players are TEAM_RED. You must use a specific integer value to check that limit. For example:
pawn Код:
if(count > Iter_Count(Player))
This will run only when there are more than 2 red team players.

I assume you want to pickup random players for choosing them, so this code will pick 2 random players from TEAM_RED:
pawn Код:
new players = Itter_Count(Player);
    if(players > 1)//if there is more than 1 player
    {
        #define count 2//number of players we want to select

        for(new x = 0; x < count; x++)//looping as many people we want to select
        {
            new bool:choosen = false;
            foreach(new i : Player)//not an efficient method though! (but can work OK!)
            {
                new randomplayer = Iter_Random(Player);
                if(team[randomplayer] == TEAM_RED)
                {
                    //your code
                    SendClientMessage(randomplayer,COLOR_RED"You got chosen.");
                    choosen = true;
                    break;
                }
            }
            if(! choosen)//in case no one was choosen, we will go loop sequently!
            {
                foreach(new i : Player)
                {
                    if(team[i] == TEAM_RED)
                    {
                        //your code
                        SendClientMessage(i,COLOR_RED"You got chosen.");
                        break;
                    }
                }
            }
        }
    }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)