AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Switch teams after 3 rounds (https://forums.alliedmods.net/showthread.php?t=112815)

mattisbogus 12-21-2009 10:16

Switch teams after 3 rounds
 
This code is from Jon, I tried to edit it for my needs but I just don't know enough (trying to learn) to get it to do what I want it to do. I tried sending the server cmds in a few parts in the code, it works, but the timing is wrong, and I don't know if this is best option.

- After 3 rounds I need it to change team and I want a cvar to be set "ajc_team <1|2>" and also "pb_bot_join_team <T|CT>" (i.e. CT(humans) changes to T, ajc_team = 1 pb_bot_join_team = CT) I want this to happen each time the code changes team every 3 rounds, so the next cmds would be (i.e. T(humans) changes to CT, ajc_teams = 2 pb_bot_join_team = T) I hope this makes since.

You don't have to right full code if you don't want, I can try to learn myself, only maybe some hints/tips so I can finally figure this out, thank you.

PHP Code:

#include <amxmodx>
#include <cstrike>

#define PLUGIN "Switch Teams"
#define VERSION "1.0"
#define AUTHOR "Jon"

#define ROUNDS 3

new g_iRounds;
new 
g_iMaxPlayers;

public 
plugin_init( )
{
    
register_pluginPLUGINVERSIONAUTHOR );
    
    
g_iMaxPlayers get_maxplayers( );
    
    
register_event"HLTV""EventNewRound""a""1=0""2=0" );
    
register_logevent"EventRoundEnd"2"1=Round_End" );
}

public 
EventNewRound( )
{
    if( 
GetPlayers( ) )
    {
        
g_iRounds++;
    }
}

public 
EventRoundEnd( )
{
    if( 
g_iRounds == ROUNDS )
    {
        for( new 
1<= g_iMaxPlayersi++ )
        {
            if( !
is_user_connected) )
            {
                continue;
            }
            
            switch( 
cs_get_user_team) )
            {
                case 
CS_TEAM_T:
                {
                    
cs_set_user_teamiCS_TEAM_CT );
                }
                
                case 
CS_TEAM_CT:
                {
                    
cs_set_user_teamiCS_TEAM_T );
                }
            }
        }
        
        
g_iRounds 0;
    }
}

bool:GetPlayers( )
{    
    new 
iTerroristsiCTs;
    
    for( new 
1<= g_iMaxPlayersi++ )
    {
        if( !
is_user_connected) )
        {
            continue;
        }
        
        switch( 
cs_get_user_team) )
        {
            case 
CS_TEAM_T:
            {
                
iTerrorists++;
            }
            
            case 
CS_TEAM_CT:
            {
                
iCTs++;
            }
        }
        
        if( 
iTerrorists && iCTs )
        {
            return 
true;
        }
    }
    
    return 
false;




All times are GMT -4. The time now is 04:13.

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