Raised This Month: $ Target: $400
 0% 

Team_swtich


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
emperial159
Member
Join Date: Feb 2011
Old 05-08-2011 , 13:46   Team_swtich
Reply With Quote #1

Hi. When a lot of people playing crashing the team_switch some people don't swtich them why? plz help

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Auto Team Switcher"
#define VERSION "1.0"
#define AUTHOR "nikhilgupta345"

#pragma semicolon 1

new roundnumber 0;
new 
Atsround;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd"say /roundnumber""sayRound" );
    
register_concmd"amx_roundrestart""restartnumber"ADMIN_KICK );
    
    
register_logevent"roundend"2"1=Round_End" );
    
register_event"TextMsg","restart","a","2&#Game_C""2&#Game_W" ); // Event for "Game Commencing" TextMsg and "Game Will Restart in X Seconds" TextMsg
    
    
Atsround register_cvar"amx_atsrounds""15" );
    
}

public 
sayRoundid )
{
    
client_printidprint_chat"The current round is %i."roundnumber );
    return 
PLUGIN_HANDLED;
}

public 
roundend()
{
    
roundnumber++;
    
    if( 
roundnumber >= get_pcvar_numAtsround ) )
    {
        new 
players[32], num;
        
get_playersplayersnum );
        
        for( new 
inumi++ )
            
add_delayplayers[i] ); // Prevent Server Crash with a lot of people.
            
    
}
}


public 
restartnumberidlevelcid )
{
    if( !
cmd_accessidlevelcid) )
        return 
PLUGIN_HANDLED;
    
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}

public 
restartid )
{
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}

public 
changeTeamid )
{
    switch( 
cs_get_user_teamid ) )
    {
        case 
CS_TEAM_CTcs_set_user_teamidCS_TEAM_T );
        
        case 
CS_TEAM_Tcs_set_user_teamidCS_TEAM_CT );
    }

    
roundnumber 0;
}

add_delayid )
{
    switch( 
id )
    {
        case 
1..7set_task0.1"changeTeam"id );
        case 
8..15set_task0.2"changeTeam"id );
        case 
16..23set_task0.3"changeTeam"id );
        case 
24..32set_task0.4"changeTeam"id );
    }


Last edited by emperial159; 05-09-2011 at 09:41.
emperial159 is offline
Old 05-09-2011, 10:39
emperial159
This message has been deleted by ConnorMcLeod. Reason: Don't bump untill 2 weeks have past.
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 05-09-2011 , 11:39   Re: Team_swtich
Reply With Quote #2

[pawn]
the server will not crash by changing all players teams...

Code:
public roundend() {     roundnumber++;         if( roundnumber >= get_pcvar_num( Atsround ) )     {         new players[32], num;         get_players( players, num, "h");                 for( new i; i < num; i++ )         {             new id=players[i];             switch (get_user_team(id))             {                 case 1: cs_set_user_team(id, CS_TEAM_CT);                 case 2: cs_set_user_team(id, CS_TEAM_T);             }         }     } }

This should work...
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-09-2011 , 13:06   Re: Team_swtich
Reply With Quote #3

emperial159
I don't know how cs module works, but check error logs - maybe you also should check if player is connecting before calling add_delay( players[i] );
__________________

SonicSonedit is offline
emperial159
Member
Join Date: Feb 2011
Old 05-09-2011 , 14:42   Re: Team_swtich
Reply With Quote #4

Oke i doned but round changing always one time but i do 2 rounds...

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Auto Team Switcher"
#define VERSION "1.0"
#define AUTHOR "nikhilgupta345"

#pragma semicolon 1

new roundnumber 0;
new 
Atsround;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd"say /roundnumber""sayRound" );
    
register_concmd"amx_roundrestart""restartnumber"ADMIN_KICK );
    
    
register_logevent"roundend"2"1=Round_End" );
    
register_event"TextMsg","restart","a","2&#Game_C""2&#Game_W" ); // Event for "Game Commencing" TextMsg and "Game Will Restart in X Seconds" TextMsg
    
    
Atsround register_cvar"amx_atsrounds""15" );
    
}

public 
sayRoundid )
{
    
client_printidprint_chat"The current round is %i."roundnumber );
    return 
PLUGIN_HANDLED;
}

public 
roundend() 
{     
       
roundnumber++;         
       if( 
roundnumber >= get_pcvar_numAtsround ) )     
       {           
       new 
players[32], num;        
       
get_playersplayersnum"h");                 
       for( new 
inumi++ )         
       {               
       new 
id=players[i];             
       switch (
get_user_team(id))             
       {                 
            case 
1cs_set_user_team(idCS_TEAM_CT);                 
            case 
2cs_set_user_team(idCS_TEAM_T);             
           }         
        }     
    } 
}


public 
restartnumberidlevelcid )
{
    if( !
cmd_accessidlevelcid) )
        return 
PLUGIN_HANDLED;
    
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}

public 
restartid )
{
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}

public 
changeTeamid )
{
    switch( 
cs_get_user_teamid ) )
    {
        case 
CS_TEAM_CTcs_set_user_teamidCS_TEAM_T );
        
        case 
CS_TEAM_Tcs_set_user_teamidCS_TEAM_CT );
    }

    
roundnumber 0;

emperial159 is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 05-09-2011 , 14:49   Re: Team_swtich
Reply With Quote #5

i can't even understand what do you mean but try this...

Code:
public roundend() {         roundnumber++;             if( roundnumber >= get_pcvar_num( Atsround ) )         {                   new players[32], num;                 get_players( players, num, "h");                         for( new i; i < num; i++ )                 {                           new id=players[i];                         switch (get_user_team(id))                         {                                 case 1: cs_set_user_team(id, CS_TEAM_CT);                                     case 2: cs_set_user_team(id, CS_TEAM_T);                             }                 }         roundnumber=0;     } }
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
emperial159
Member
Join Date: Feb 2011
Old 06-13-2011 , 10:12   Re: Team_swtich
Reply With Quote #6

Ty it's working but the server breaking when are 10x10 players...

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
 
#define PLUGIN "Auto Team Switcher"
#define VERSION "1.0"
#define AUTHOR "nikhilgupta345"
 
#pragma semicolon 1
 
new roundnumber 0;
new 
Atsround;
 
public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
   
    
register_clcmd"say /roundnumber""sayRound" );
    
register_concmd"amx_roundrestart""restartnumber"ADMIN_KICK );
   
    
register_logevent"roundend"2"1=Round_End" );
    
register_event"TextMsg","restart","a","2&#Game_C""2&#Game_W" ); // Event for "Game Commencing" TextMsg and "Game Will Restart in X Seconds" TextMsg
   
    
Atsround register_cvar"amx_atsrounds""15" );
   
}
 
public 
sayRoundid )
{
    
client_printidprint_chat"The current round is %i."roundnumber );
    return 
PLUGIN_HANDLED;
}
 
public 
roundend()
{    
    
roundnumber++;        
    if( 
roundnumber >= get_pcvar_numAtsround ) )    
    {          
        new 
players[32], num;        
        
get_playersplayersnum"h");                
        for( new 
inumi++ )        
        {              
            new 
id=players[i];            
            switch (
get_user_team(id))            
            {                
                case 
1cs_set_user_team(idCS_TEAM_CT);                
                    case 
2cs_set_user_team(idCS_TEAM_T);            
                }        
        }    
        
roundnumber 0;
    }
}
 
public 
restartnumberidlevelcid )
{
    if( !
cmd_accessidlevelcid) )
        return 
PLUGIN_HANDLED;
   
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}
 
public 
restartid )
{
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}
 
public 
changeTeamid )
{
    
set_hudmessage(150210500.460.4500.02.02.01.0, -1);
        
show_hudmessage(0"Switching Teams");
 
    switch( 
cs_get_user_teamid ) )
    {
        case 
CS_TEAM_CTcs_set_user_teamidCS_TEAM_T );
       
        case 
CS_TEAM_Tcs_set_user_teamidCS_TEAM_CT );
    }
 
    
roundnumber 0;

emperial159 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-13-2011 , 12:43   Re: Team_swtich
Reply With Quote #7

Your original code is fine.
You just need to remove task if the player disconnects, because a player can disconnect before the task is executed, thus giving you the invalid player error.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Auto Team Switcher"
#define VERSION "1.0"
#define AUTHOR "nikhilgupta345"

#pragma semicolon 1

new roundnumber 0;
new 
Atsround;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd"say /roundnumber""sayRound" );
    
register_concmd"amx_roundrestart""restartnumber"ADMIN_KICK );
    
    
register_logevent"roundend"2"1=Round_End" );
    
register_event"TextMsg","restart","a","2&#Game_C""2&#Game_W" ); // Event for "Game Commencing" TextMsg and "Game Will Restart in X Seconds" TextMsg
    
    
Atsround register_cvar"amx_atsrounds""15" );
    
}

public 
client_disconnectid )
{
    
remove_taskid );
}

public 
sayRoundid )
{
    
client_printidprint_chat"The current round is %i."roundnumber );
    return 
PLUGIN_HANDLED;
}

public 
roundend()
{
    
roundnumber++;
    
    if( 
roundnumber >= get_pcvar_numAtsround ) )
    {
        new 
players[32], num;
        
get_playersplayersnum );
        
        for( new 
inumi++ )
            
set_taskfloat), "changeTeam"players[i] );
            
    }
}


public 
restartnumberidlevelcid )
{
    if( !
cmd_accessidlevelcid) )
        return 
PLUGIN_HANDLED;
    
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}

public 
restartid )
{
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}

public 
changeTeamid )
{
    switch( 
cs_get_user_teamid ) )
    {
        case 
CS_TEAM_CTcs_set_user_teamidCS_TEAM_T );
        
        case 
CS_TEAM_Tcs_set_user_teamidCS_TEAM_CT );
    }

    
roundnumber 0;

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 06-13-2011 at 13:17.
Exolent[jNr] is offline
emperial159
Member
Join Date: Feb 2011
Old 06-13-2011 , 12:53   Re: Team_swtich
Reply With Quote #8

Look error...
emperial159 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-13-2011 , 13:18   Re: Team_swtich
Reply With Quote #9

Try it now.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
emperial159
Member
Join Date: Feb 2011
Old 06-15-2011 , 07:54   Re: Team_swtich
Reply With Quote #10

Working 10x10 ,but when the map change there are first round and is 1 switch team when go onother round there is 2 switch... And sometimes people don't swtich them...

Last edited by emperial159; 06-15-2011 at 10:57.
emperial159 is offline
Reply


Thread Tools
Display Modes

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 04:25.


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