Raised This Month: $ Target: $400
 0% 

Randomize teams


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fmfs10
Senior Member
Join Date: Mar 2009
Location: Brasil
Old 03-16-2010 , 15:48   Randomize teams
Reply With Quote #1

Hello... Like i said in another post (just edited it because i don't need this anymore), i'm making a for MIX, CPL and CF.
I just want to know, how can i put players from spec to a random team, respecting the limitteams of course. And if possible, show to me how everything is working

Sorry for my bad english

And thanks for you response =D
fmfs10 is offline
Brreaker
Senior Member
Join Date: Oct 2009
Location: Constanta, Romania
Old 03-16-2010 , 16:12   Re: Randomize teams
Reply With Quote #2

register_clcmd("amx_random", "pRandom", ADMIN_KICK, "Random player teams")

public pRandom(id) {
new iRandomNum = random_num(0, 1)
switch(iRandomNum) {
case 0: cs_set_user_team(id, CS_TEAM_T)
case 1: cs_set_user_team(id, CS_TEAM_CT)
}

Just a suggestion
Brreaker is offline
Send a message via MSN to Brreaker Send a message via Yahoo to Brreaker
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 03-16-2010 , 16:18   Re: Randomize teams
Reply With Quote #3

I use this ,
pretty easy but it does the trick xD

PHP Code:
public RandomTeams() // Randomize Teams
{
    new 
players[32], pnumplayerctsts;
    
get_players(playerspnum);
    
    for( new 
i=0i<pnumi++ )
    {
        
player players[i];
        
        if(!
cts && !ts)
        {
            
select_model(player,1,random_num(1,4));
            
ts++;
            
cts=0;
        }
        else if(!
cts && ts)
        {
            
select_model(player,2,random_num(1,4));
            
ts=0;
            
cts++;
        }
        else if(
cts && !ts)
        {
            
select_model(player,1,random_num(1,4));
            
ts++;
            
cts=0;
        }
    }
}


select_model(idteammodel// Set Models
{
    switch(
team) {
        case 
1: {
            switch(
model) {
                case 
1cs_set_user_team(idCS_TEAM_TCS_T_TERROR);
                case 
2cs_set_user_team(idCS_TEAM_TCS_T_LEET);
                case 
3:    cs_set_user_team(idCS_TEAM_TCS_T_ARCTIC);
                case 
4cs_set_user_team(idCS_TEAM_TCS_T_GUERILLA);
            }
        }
        case 
2: {
            switch(
model) {
                case 
1cs_set_user_team(idCS_TEAM_CTCS_CT_URBAN);
                case 
2cs_set_user_team(idCS_TEAM_CTCS_CT_GSG9);
                case 
3cs_set_user_team(idCS_TEAM_CTCS_CT_SAS);
                case 
4cs_set_user_team(idCS_TEAM_CTCS_CT_GIGN);
                case 
5cs_set_user_team(idCS_TEAM_CTCS_CT_VIP); //my lil secret
            
}
        }
        case 
3: {
            
cs_set_user_team(idCS_TEAM_SPECTATORCS_DONTCHANGE);
            if(
is_user_alive(id))
                
user_kill(id);
        }
    }

__________________
I am out of order!
grimvh2 is offline
fmfs10
Senior Member
Join Date: Mar 2009
Location: Brasil
Old 03-17-2010 , 11:03   Re: Randomize teams
Reply With Quote #4

Thanks!
Working great !
fmfs10 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-17-2010 , 11:29   Re: Randomize teams
Reply With Quote #5

Here is a real way to randomize teams.
grim's will be the same each time.

Code:
RandomizeTeams( ) {     new iPlayers[ 32 ], iNum;     get_players( iPlayers, iNum );         for( new i = 0; i < iNum; i++ )     {         if( !( CS_TEAM_T <= cs_get_user_team( iPlayers[ i ] ) <= CS_TEAM_CT ) )         {             iPlayers[ i-- ] = iPlayers[ --iNum ];         }     }         new iPlayer, CsTeams:iTeam = random( 2 ) ? CS_TEAM_T : CS_TEAM_CT;         new iRandom;         while( iNum )     {         iRandom = random( iNum );                 iPlayer = iPlayers[ iRandom ];                 cs_set_user_team( iPlayer, iTeam );                 iPlayers[ iRandom ] = iPlayers[ --iNum ];                 iTeam = CsTeams:( ( _:iTeam ) % 2 + 1 );     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 03-17-2010 , 13:02   Re: Randomize teams
Reply With Quote #6

Quote:
Originally Posted by Exolent[jNr] View Post
Here is a real way to randomize teams.
grim's will be the same each time.

Code:
RandomizeTeams( ) { new iPlayers[ 32 ], iNum;
get_players( iPlayers, iNum );

for( new i = 0; i < iNum; i++ ) { if( !( CS_TEAM_T <= cs_get_user_team( iPlayers[ i ] ) <= CS_TEAM_CT ) ) { iPlayers[ i-- ] = iPlayers[ --iNum ];
} } new iPlayer, CsTeams:iTeam = random( 2 ) ? CS_TEAM_T : CS_TEAM_CT;

new iRandom;

while( iNum ) { iRandom = random( iNum );

iPlayer = iPlayers[ iRandom ];

cs_set_user_team( iPlayer, iTeam );

iPlayers[ iRandom ] = iPlayers[ --iNum ];

iTeam = CsTeams:( ( _:iTeam ) % 2 + 1 );
} }

Thats why it was cheap :p
__________________
I am out of order!
grimvh2 is offline
fmfs10
Senior Member
Join Date: Mar 2009
Location: Brasil
Old 03-17-2010 , 18:24   Re: Randomize teams
Reply With Quote #7

Yeah i thinked this too...
But why new iPlayers[32] and not [33]?

Is 0 counting as a player too?

EDIT@

In this way, i can't get players from spec... Why?[

EDITē@

You can't change your name with this, and when you try to change your name, sv_restart doesn't work anymore (i've puted server_cmd(amx_cvar sv_restart 1) in the plugin...)

Last edited by fmfs10; 03-17-2010 at 19:52. Reason: Just some more things to add =])
fmfs10 is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-18-2010 , 00:09   Re: Randomize teams
Reply With Quote #8

Quote:
Originally Posted by fmfs10 View Post
Yeah i thinked this too...
But why new iPlayers[32] and not [33]?

Is 0 counting as a player too?
No, it is iPlayers[32] because there are 32 cells in that array. Once it is initialized, it becomes 0-31. 0 is not counted when you declare it.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-18-2010 , 00:39   Re: Randomize teams
Reply With Quote #9

Quote:
Originally Posted by fmfs10 View Post
EDIT@

In this way, i can't get players from spec... Why?[

EDITē@

You can't change your name with this, and when you try to change your name, sv_restart doesn't work anymore (i've puted server_cmd(amx_cvar sv_restart 1) in the plugin...)
1. Remove this part:

Code:
    for( new i = 0; i < iNum; i++ )     {         if( !( CS_TEAM_T <= cs_get_user_team( iPlayers[ i ] ) <= CS_TEAM_CT ) )         {             iPlayers[ i-- ] = iPlayers[ --iNum ];         }     }

2. That code snippet has nothing to do with those bugs.
It has to be something else in your code.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 03-18-2010 , 05:58   Re: Randomize teams
Reply With Quote #10

PHP Code:
engclient_cmd(0"jointeam""5"); 
__________________
hleV 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 08:38.


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