Raised This Month: $ Target: $400
 0% 

get_players team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-13-2010 , 10:33   get_players team
Reply With Quote #1

How can I get only terrorists or counter-terrorists in get_players()? with corresponding count.

For cstrike.
Backstabnoob is offline
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 06-13-2010 , 10:39   Re: get_players team
Reply With Quote #2

new iPlayers[32]
new iNum

get_players(iPlayers, iNum, "ch" /*Ingnores Bots and HLTV */, "TERRORIST" or "CT")
#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-13-2010 , 11:03   Re: get_players team
Reply With Quote #3

get_players(players,num,"ceh","TERRORIST");

This returns CTs, too.

Edit:

This should select one player as a random T:
PHP Code:
public random_t()
{
    new 
players[g_maxplayers];
    static 
num;
    
    
get_players(players,num,"ceh","TERRORIST");
    
    if(
num)
    {
        new 
random_num(1num);
        
        if(
is_user_connected(x) && is_user_alive(x))
            
g_random_t x;
    }


Last edited by Backstabnoob; 06-13-2010 at 11:24.
Backstabnoob is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 06-13-2010 , 14:54   Re: get_players team
Reply With Quote #4

PHP Code:
RandomPlayer()
{
    new 
players[32], pnum;
    
get_players(playerspnum);
    
// get_players(players, pnum, "e", "CT");
    //get_players(players, pnum, "e", "TERRORIST"
   
    
if( !pnum ) return -1;
    
    return 
players[random(pnum)];

__________________
I am out of order!
grimvh2 is offline
Upri98
New Member
Join Date: Sep 2019
Location: Balkan
Old 01-26-2020 , 05:24   Re: get_players team
Reply With Quote #5

Quote:
Originally Posted by grimvh2 View Post
PHP Code:
RandomPlayer()
{
    new 
players[32], pnum;
    
get_players(playerspnum);
    
// 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?

Code:
if( !pnum )
__________________
Coding is !easy.

Last edited by Upri98; 01-26-2020 at 05:32. Reason: im idiot.
Upri98 is offline
thEsp
BANNED
Join Date: Aug 2017
Old 01-26-2020 , 06:05   Re: get_players team
Reply With Quote #6

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.
thEsp is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-26-2020 , 06:18   Re: get_players team
Reply With Quote #7

Quote:
Originally Posted by thEsp View Post
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.
__________________

Last edited by HamletEagle; 01-26-2020 at 13:18.
HamletEagle is online now
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-26-2020 , 11:54   Re: get_players team
Reply With Quote #8

Yeah, I give him credit for searching first.

Upri98, to use that RandomPlayer function you would do something like:
PHP Code:
new iRandom RandomPlayer();

if ( 
iRandom == -)
{
    
//No random players available
}
else
{
    
//iRandom is your random player

__________________
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:56.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode