AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Setting team bug (https://forums.alliedmods.net/showthread.php?t=102603)

xbatista 09-04-2009 11:02

Setting team bug
 
I'm just confused in those codes, I don't understand why sometimes terrorist got respawned in ct respawn zone .. ?
( This plugin switches teams when terrorist killed ct, and in ct team max 4 ct players. )
Btw if someone can,then please recode this code.
PHP Code:

// Global
#define MAX_CTS 4

new bool:g_bSwitch33 ];

// In plugin_init
register_messageget_user_msgid"TeamInfo" ), "msg_TeamInfo" );
register_logevent("logevent_round_end"2"1=Round_End");
register_event("DeathMsg""event_deathmsg""a")

//Round end event
public logevent_round_end()
{
    static 
iCsTeams:team;
    for( 
<= g_iMaxPlayers i++ )
    {
        if( !
is_user_connected) || !g_bSwitch]
        || !( 
CS_TEAM_UNASSIGNED < ( team cs_get_user_team) ) < CS_TEAM_SPECTATOR ) )
            continue;
            
        
cs_set_user_teami, ( team CS_TEAM_CT ) + CS_TEAM_T );
        
g_bSwitch] = false;
    }
}

// Team info message
public msg_TeamInfo(msgiddestreceiverid)
{
    if( 
dest != MSG_ALL && dest != MSG_BROADCAST ) return;
        
    new 
teamname[3];
    
get_msg_arg_string(2teamnamesizeof(teamname) - 1);
        
    new 
FmTeams:team;
    for( new 
FmTeams:FM_TEAM_UNASSIGNEDFmTeamsi++ )
    {
        if( 
g_TeamInfo[i][0] == teamname[0] )
        {
            
team i;
            break;
        }
    }
        
    new 
client get_msg_arg_int(1);
    if( 
team == FM_TEAM_CT && fm_get_user_team(client) == team )
    {
        new 
ctnum;
        for( new 
1<= g_iMaxPlayersi++ )
        {
            if( 
!= client
            
&& is_user_connected(i)
            && 
fm_get_user_team(i) == FM_TEAM_CT
            
&& ++ctnum == MAX_CTS )
            {
                
set_pdata_int(client114_:FM_TEAM_T);
                
set_msg_arg_string(2g_TeamInfo[FM_TEAM_T]);
                break;
            }
        }
    }
    
    if( 
g_bSwitchid ] )
    {
        
g_bSwitch[id] = false;
    }
}

// DeathMsg
public event_deathmsg()
{
    new 
i_victim read_data(2)
    new 
i_attacker read_data(1)
    if ( !(
<= i_victim <= g_iMaxPlayers) )
        return;
    
    if( 
cs_get_user_teami_attacker ) == CS_TEAM_T && cs_get_user_teami_victim ) == CS_TEAM_CT )
    {
        if( !
g_bSwitchi_attacker ] )
        {
            
g_bSwitchi_attacker ] = true;
                
            if( !
g_bSwitchi_victim ] )
            {
                
g_bSwitchi_victim ] = true;
            }
        }
    }




All times are GMT -4. The time now is 15:08.

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