AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ID of an Random T (https://forums.alliedmods.net/showthread.php?t=130753)

mottzi 06-27-2010 06:39

ID of an Random T
 
Good afternoon AM!

Can you tell me how to get the ID of a random alive Terrorist?


Thanks :wink:

I tried it myself but that cant work:
PHP Code:

    new random1
    
new players[32], pnumtempid;
    new 
max1 0
    get_players
(playerspnum"a");

    for( new 
ii<pnumi++ )
    {
        
tempid players[i]
        
vip[tempid] = 0
        
if(cs_get_user_team(tempid) == CS_TEAM_T)
        {
            
max1++
        }
    }
    
    
random1 random_num(1max1


Mottzi

xPaw 06-27-2010 06:59

Re: ID of an Random T
 
PHP Code:

    new random1
    
new players[32], pnumtempid;
    new 
max1 0terrs32 ];
    
get_players(playerspnum"a");

    for( new 
ii<pnumi++ )
    {
        
tempid players[i]
    
//    vip[tempid] = 0
        
if(cs_get_user_team(tempid) == CS_TEAM_T)
        {
            
terrsmax1++ ] = tempid;
        }
    }
    
    
random1 terrsrandom_num(1max1) ]; 


hleV 06-27-2010 07:18

Re: ID of an Random T
 
PHP Code:

new players[32], num;
get_players(playersnum"a""TERRORIST");
 
new 
players[random(num)]; 


mottzi 06-27-2010 15:33

Re: ID of an Random T
 
Quote:

Originally Posted by hleV (Post 1221304)
PHP Code:

new players[32], num;
get_players(playersnum"a""TERRORIST");
 
new 
players[random(num)]; 


So easy? Is this going to work fine, without bugs?

@xPaw thanks. Im going to use ur code if the easier one dont work =)


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

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