AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Switching player's team. Will this work? Urgent Help! (https://forums.alliedmods.net/showthread.php?t=221282)

devWaleed 07-20-2013 06:29

Switching player's team. Will this work? Urgent Help!
 
I know this is very awful code for team balancing but what do you think? Will this work?


PHP Code:

    new t_countct_countnumplayers[32], tempid;

    new 
ct_count    =    get_playersplayersnum"ae""CT" );  //Get ct count
    
new t_count    =    get_playersplayersnum"ae""T" ); //Get t count
    
if(t_count ct_count){
        
// T - CT
        
new tcount    =    t_count ct_count
        if(
tcount 1){
                        
//If there are more than 1 player which makes team unequal.
            // There are more Ts.then allowed!
            
while(tcount>1){
                new 
t_count    =    get_playersplayersnum"ae""T" );
                for(new 
0i<tcounti++){
                    
tempid    =    players[i];
                    
cs_set_user_team(tempidCS_TEAM_CT); //Change Player's team...
                    
i++;
                }
                
tcount++;
            }
        }
    } 

-TY!

devWaleed 07-20-2013 06:44

Re: Switching player's team. Will this work? Urgent Help!
 
I think it should be

PHP Code:

tcount--; //in while loop 

I have read it again, everything looks fine to me but It didn't work in my server. nothing happened. Tell me if there is anything wrong...

ConnorMcLeod 07-20-2013 07:58

Re: Switching player's team. Will this work? Urgent Help!
 
If it can help : http://forums.alliedmods.net/showthread.php?p=705142

About your code, get_players usage is wrong, get_players returns 1 and not players number that is hold in 'num' var.
Also, terrorists team name is "TERRORIST"

PHP Code:

    new ct_count    =    get_playersplayersnum"ae""CT" );  //Get ct count
    
new t_count    =    get_playersplayersnum"ae""T" ); //Get t count 

->
PHP Code:

    get_playersplayersct_count"ae""CT" );  //Get ct count
    
get_playersplayerst_count"ae""TERRORIST" ); //Get t count 


devWaleed 07-20-2013 11:39

Re: Switching player's team. Will this work? Urgent Help!
 
Thank for reply. I changed my approached. But I am getting "Tag mismatch error" on this line:

PHP Code:

   ePlayer  =  floatround((num num2)/2floatround_ceil); 



All times are GMT -4. The time now is 06:27.

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