Raised This Month: $ Target: $400
 0% 

Random player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
usaexelent
Senior Member
Join Date: Nov 2009
Location: Lithuania
Old 08-03-2011 , 10:41   Random player
Reply With Quote #1

How can i get a random player who's team is not unassigned and not spectator?
I'm making this function on round end
usaexelent is offline
Send a message via Skype™ to usaexelent
Korxu
Senior Member
Join Date: Sep 2010
Old 08-03-2011 , 11:11   Re: Random player
Reply With Quote #2

Maybe this helps you. Look here and here.

get_players (wiki)

Last edited by Korxu; 08-03-2011 at 11:12. Reason: Wiki added.
Korxu is offline
usaexelent
Senior Member
Join Date: Nov 2009
Location: Lithuania
Old 08-03-2011 , 12:43   Re: Random player
Reply With Quote #3

I know get player command but i need that if player team is spectator or unassigned then it would find other player who is alive.And if that player is dead to then find other player and so on
usaexelent is offline
Send a message via Skype™ to usaexelent
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-03-2011 , 12:59   Re: Random player
Reply With Quote #4

Use get_players()
__________________
Bugsy is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 08-03-2011 , 21:26   Re: Random player
Reply With Quote #5

PHP Code:
getRandPlayer()
{
    new 
players32 ], playernumpList33 ], count;
    
get_playersplayersnum"a" );
    for( new 
num ++ )
    {
        
player players];
        if( 
get_user_teamplayer ) != && get_user_teamplayer ) != )
        continue;
        
        
pListcount ] = player;
        
count ++;
    }
    
    return 
pListrandomcount ) ];

__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 08-03-2011 at 21:29. Reason: Typo
hornet is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-03-2011 , 22:42   Re: Random player
Reply With Quote #6

Use a switch for get_user_team(). Also, no reason to use continue in code so small, it just makes it harder to read.
__________________

Last edited by fysiks; 08-03-2011 at 22:45.
fysiks is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 08-03-2011 , 22:50   Re: Random player
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
Use a switch for get_user_team(). Also, no reason to use continue in code so small, it just makes it harder to read.
Yes Sir ;)

PHP Code:
getRandPlayer()
{
    new 
players32 ], playernumpList33 ], count;
    
get_playersplayersnum"a" );
    for( new 
num ++ )
    {
        
player players];
        if( 
get_user_teamplayer ) == || get_user_teamplayer ) == )
        {
            
pListcount ] = player;
            
count ++;
        }
    }
    
    return 
pListrandomcount ) ];

But to use a switch statement in there, wouldn't that make you have the result code would be written there twice? Or can you actually do
PHP Code:
case 2:
{
    
//

...?
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 08-03-2011 at 22:52.
hornet is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-03-2011 , 23:01   Re: Random player
Reply With Quote #8

1, 2
__________________
fysiks is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 08-03-2011 , 23:03   Re: Random player
Reply With Quote #9

or 0 < team < 3
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-03-2011 , 23:06   Re: Random player
Reply With Quote #10

Quote:
Originally Posted by jim_yang View Post
or 0 < team < 3
If you use get_user_team() there does it only get called once?
__________________
fysiks 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 03:28.


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