AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]gain problem with random player ;) (https://forums.alliedmods.net/showthread.php?t=107139)

One 10-23-2009 08:36

[SOLVED]gain problem with random player ;)
 
PHP Code:

register_logevent("round_end"2"1=Round_End"

PHP Code:

public round_end()
{
    if(
g_spieler_anzahl_checked == && g_first_round == 1)
    {
        new 
survivor
        
new user_is_suvivor[33]
        new 
user_was_CT[33]
        for(new 
id 1;id <= g_MaxPlayers;id++)
        {
            if(
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T)
            {
                
survivor++
            }
            if(
survivor == && is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T)
            {
                
user_is_suvivor[id] = 1
                
if(is_user_alive(id))
                {
                    
cs_set_user_team(user_is_suvivor[id],CS_TEAM_CT)
                }
            }
            if(
survivor >= 2)
            {
                if(
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT)
                {
                    
cs_set_user_team(id,CS_TEAM_T)
                    
user_was_CT[id] = 1
                
}
                if(
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T && user_was_CT[id] == 0)
                {
                    new 
name[33]
                    new 
iPlayers32 ], iNumiPlayer;
                    
get_playersiPlayersiNum );
    
                    
iPlayer iPlayersrandomiNum ) ];
                    if(
is_user_alive(iPlayer))
                    {
                        
get_user_name(iPlayer,name,32)
                        
cs_set_user_team(iPlayer,CS_TEAM_CT)
                        
client_print(0,print_chat,"tranfered  %s to CT",name)
                    }
                }
            }
        }
    }
            


what i want do to =
@ round end i want check all alive T's !
if is there only 1 T. then transfer the T to CT & all players to T. ( 1 CT vs. all Terrors )

if are there more Terrors alive, then set a random terror of alive terror to CT & all CTs to Terror. ( again 1 CT vs all Terrors. )

the game playe =

first round will one user tranfered to CT & he has to player vs. all Terrors. @ round end if he could kill all Terrors, he willbe stay CT & the same game agin. if 1 or more Terrors survive the round, 1 of em willbe CT & he has the chance to kill all Terrors.



i hope anyone can help me. :(

Sylwester 10-23-2009 10:44

Re: again problem with random player ;)
 
try this:
PHP Code:

public round_end()
{
    new 
alive_Ts[33], Ts[33], alive_CTs[33], CTs[33]
    new 
alive_Ts_numTs_numalive_CTs_numCTs_numid
    
for(new 1<= g_MaxPlayersi++){
        if(!
is_user_connected(i))
            continue
        switch(
cs_get_user_team(i)){
            case 
CS_TEAM_CT:{
                
CTs[CTs_num++] = i
                
if(is_user_alive(i))
                    
alive_CTs[alive_CTs_num++] = i
            
}
            case 
CS_TEAM_T:{
                
Ts[Ts_num++] = i
                
if(is_user_alive(i))
                    
alive_Ts[alive_Ts_num++] = i
            
}
        }
    }

    if(
CTs_num Ts_num 2)
        return  
// not enough players
    
    
if(alive_Ts_num 0)
        
cs_set_user_team(alive_Ts[random(alive_Ts_num)], CS_TEAM_CT)
    else if(
alive_CTs_num 0)
        
id alive_CTs[random(alive_CTs_num)]
    else if(
Ts_num 0)
        
cs_set_user_team(Ts[random(Ts_num)], CS_TEAM_CT)
    else if(
CTs_num 0)
        
id CTs[random(CTs_num)]

    for(new 
i=0i<CTs_numi++)
        if(
CTs[i] != id)
            
cs_set_user_team(CTs[i], CS_TEAM_T)



xPaw 10-23-2009 11:40

Re: again problem with random player ;)
 
PHP Code:

HeyBitch( ) {
    if( 
Some-Random-Checks-Goes-Here ) {
        new 
iPlayers32 ], iCount;
        
        for( new 
1<= g_iMaxplayersi++ ) {
            if( !
is_user_connected) )
                continue;
            
            switch( 
cs_get_user_team) ) {
                case 
CS_TEAM_T : if( is_user_alive) ) iPlayersiCount++ ] = i;
                case 
CS_TEAM_CTcs_set_user_teamiCS_TEAM_T );
            }
        }
        
        if( !
iCount ) {
            
// No alive terrorists
            
            
return;
        }
        
        new 
iPlayer = ( iCount == iPlayers] : iPlayersrandomiCount ) ] );
        
        
cs_set_user_teamiPlayerCS_TEAM_CT );
        
        
// Your stuff
    
}



One 10-23-2009 11:42

Re: again problem with random player ;)
 
awesome oO

ty

@ Xpaw : you tried the same in catch mod & sorry but this part sux & dont talk with bitch to me :)

xPaw 10-23-2009 11:46

Re: [SOLVED]gain problem with random player ;)
 
What?

Hawk552 10-23-2009 11:48

Re: [SOLVED]gain problem with random player ;)
 
Quote:

Originally Posted by xPaw (Post 969920)
What?

He's telling you not to call him a bitch.

One 10-23-2009 11:51

Re: again problem with random player ;)
 
Quote:

Originally Posted by xPaw (Post 969913)
Code:

HeyBitch( ) {
    if( Some-Random-Checks-Goes-Here ) {
        new iPlayers[ 32 ], iCount;
       
        for( new i = 1; i <= g_iMaxplayers; i++ ) {
            if( !is_user_connected( i ) )
                continue;
           
            switch( cs_get_user_team( i ) ) {
                case CS_TEAM_T : if( is_user_alive( i ) ) iPlayers[ iCount++ ] = i;
                case CS_TEAM_CT: cs_set_user_team( i, CS_TEAM_T );
            }
        }
       
        if( !iCount ) {
            // No alive terrorists
           
            return;
        }
       
        new iPlayer = ( iCount == 1 ? iPlayers[ 0 ] : iPlayers[ random( iCount ) ] );
       
        cs_set_user_team( iPlayer, CS_TEAM_CT );
       
        // Your stuff
    }
}


i think i can understand you why you write heybitch ;) or better said why you call your function so...

xPaw 10-23-2009 11:51

Re: [SOLVED]gain problem with random player ;)
 
Did i called him a bitch? Bah, its just function name ?

One 10-23-2009 11:53

Re: [SOLVED]gain problem with random player ;)
 
why you never call your funtions so & you do this only in my post? im not a idiot like ...

ahhh 4get it ;)

Sylwester 10-23-2009 12:07

Re: [SOLVED]gain problem with random player ;)
 
Quote:

first round will one user tranfered to CT & he has to player vs. all Terrors. @ round end if he could kill all Terrors, he willbe stay CT & the same game agin.
xPaw you missed this one in your code.

Also you don't need to use "if" here:
PHP Code:

new iPlayer = ( iCount == iPlayers] : iPlayersrandomiCount ) ] ); 

==>
PHP Code:

new iPlayer iPlayersrandomiCount ) ]; 



All times are GMT -4. The time now is 17:34.

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