View Full Version : get_players team
Backstabnoob
06-13-2010, 10:33
How can I get only terrorists or counter-terrorists in get_players()? with corresponding count.
For cstrike.
#8 SickneSS
06-13-2010, 10:39
new iPlayers[32]
new iNum
get_players(iPlayers, iNum, "ch" /*Ingnores Bots and HLTV */, "TERRORIST" or "CT")
Backstabnoob
06-13-2010, 11:03
get_players(players,num,"ceh","TERRORIST");
This returns CTs, too.
Edit:
This should select one player as a random T:
public random_t()
{
new players[g_maxplayers];
static num;
get_players(players,num,"ceh","TERRORIST");
if(num)
{
new x = random_num(1, num);
if(is_user_connected(x) && is_user_alive(x))
g_random_t = x;
}
}
RandomPlayer()
{
new players[32], pnum;
get_players(players, pnum);
// get_players(players, pnum, "e", "CT");
//get_players(players, pnum, "e", "TERRORIST"
if( !pnum ) return -1;
return players[random(pnum)];
}
RandomPlayer()
{
new players[32], pnum;
get_players(players, pnum);
// get_players(players, pnum, "e", "CT");
//get_players(players, pnum, "e", "TERRORIST"
if( !pnum ) return -1;
return players[random(pnum)];
}
Can someone explain this step?
Does it have any return value or smth?
if( !pnum )
Dude why do you even bother restoring a 10 years old thread? :O
Either way, if there are no players (!pnum) the function returns -1.
HamletEagle
01-26-2020, 06:18
Dude why do you even bother restoring a 10 years old thread? :O
Either way, if there are no players (!pnum) the function returns -1.
Because he has a legitimate question about the topic.
pnum is the number of players. If pnum is 0(!pnum is the same as pnum == 0) then there are no players so a random player cannot be retrieved.
Yeah, I give him credit for searching first.
Upri98, to use that RandomPlayer function you would do something like:
new iRandom = RandomPlayer();
if ( iRandom == -1 )
{
//No random players available
}
else
{
//iRandom is your random player
}
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.