Raised This Month: $ Target: $400
 0% 

Get a random player from CT&T team


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
11922911
Senior Member
Join Date: Dec 2011
Location: Yuen Long Country
Old 02-18-2013 , 01:14   Get a random player from CT&T team
Reply With Quote #1

PHP Code:
new iPlayers[32], iPlayersNum;
get_playersiPlayersiPlayersNum"h" )

new 
iBitsumiCountplayeri;
for( 
0iPlayersNum++ )
{
    
player iPlayers[i]
    if( 
<= _:cs_get_user_team(player) <= )
    {
        
iBitsum |= (1<<player)
        
iCount++
    }
}

if( !
iCount ) return;

new 
iRandom random(iCount);
iCount 0
for( 0iPlayersNum++ )
{
    
player iPlayers[i]
    if( 
iBitsum & (1<<player) )
        
iCount ++;

    if( 
iCount == iRandom )
    {
        
iRandom player
        
break;
    }

PHP Code:
new iRandom;
new 
iPlayers[32], iCount;
get_playersiPlayersiCount"e""TERRORIST" )
if( 
iCount iRandom iPlayers[random(iCount)]
get_playersiPlayersiCount"e""CT" )
if( 
iCount && (!iRandom || random_num(01)) ) iRandom iPlayers[random(iCount)] 
PHP Code:
new g_iMaxPlayers get_maxplayers();
new 
iPlayers[32], iCounti;
for( 
1g_iMaxPlayers++ )
{
    if( 
is_user_connected(i) && (<= _:cs_get_user_team(i) <= 2) )
    {
        
iPlayers[i] = iCount
        iCount 
++
    }
}

if( !
iCount ) return;
new 
iRandom iPlayers[random(iCount)] 
PHP Code:
new iRandomiPlayers[32], iCount 1;
while( 
iCount && !iRandom )
{
    
get_playersiPlayersiCount"h" )
    
iRandom random(iPlayers[iCount])
    if( !(
<= _:cs_get_user_team(iRandom) <= 2) ) iRandom 0

I have no idea what is the best way to do this.

Last edited by 11922911; 02-18-2013 at 10:56.
11922911 is offline
 



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 21:39.


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