Raised This Month: $ Target: $400
 0% 

[SOLVED]gain problem with random player ;)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 10-23-2009 , 08:36   [SOLVED]gain problem with random player ;)
Reply With Quote #1

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.
__________________

Last edited by One; 10-23-2009 at 11:44.
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-23-2009 , 10:44   Re: again problem with random player ;)
Reply With Quote #2

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)

__________________
Impossible is Nothing

Last edited by Sylwester; 10-23-2009 at 10:47.
Sylwester is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 10-23-2009 , 11:42   Re: again problem with random player ;)
Reply With Quote #3

awesome oO

ty

@ Xpaw : you tried the same in catch mod & sorry but this part sux & dont talk with bitch to me
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-23-2009 , 11:40   Re: again problem with random player ;)
Reply With Quote #4

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
    
}

__________________
xPaw is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 10-23-2009 , 11:51   Re: again problem with random player ;)
Reply With Quote #5

Quote:
Originally Posted by xPaw View Post
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...
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-23-2009 , 11:46   Re: [SOLVED]gain problem with random player ;)
Reply With Quote #6

What?
__________________
xPaw is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-23-2009 , 11:48   Re: [SOLVED]gain problem with random player ;)
Reply With Quote #7

Quote:
Originally Posted by xPaw View Post
What?
He's telling you not to call him a bitch.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-23-2009 , 11:51   Re: [SOLVED]gain problem with random player ;)
Reply With Quote #8

Did i called him a bitch? Bah, its just function name ?
__________________
xPaw is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 10-23-2009 , 11:53   Re: [SOLVED]gain problem with random player ;)
Reply With Quote #9

why you never call your funtions so & you do this only in my post? im not a idiot like ...

ahhh 4get it ;)
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-23-2009 , 12:07   Re: [SOLVED]gain problem with random player ;)
Reply With Quote #10

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 ) ]; 
__________________
Impossible is Nothing
Sylwester 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 17:34.


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