Raised This Month: $ Target: $400
 0% 

When someone kill someone switch their teams.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 12-23-2008 , 07:04   Re: When someone kill someone switch their teams.
Reply With Quote #2

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

new g_players;
new g_CTDdied;

public plugin_init() 
{
    register_event("SendAudio","twin","a","2=%!MRAD_terwin");
    register_event("SendAudio","roundend","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
    register_event("DeathMsg","hook_death","a");
    
    g_players = get_maxplayers();
}

// if you want when T wins
public twin()
{
    for( new i = 1; i <= g_players; i++ )
    {
        if( !is_user_connected( i ) )
            continue;
            
        switch( cs_get_user_team( i ) )
        {
            case CS_TEAM_T: cs_set_user_team( i, CS_TEAM_CT );
            case CS_TEAM_CT: cs_set_user_team( i, CS_TEAM_T );
            
            default: continue;
        }
    }
}

// if you want when only a T player kills a CT player
public hook_death()
{
    new k = read_data( 1 );
    new v = read_data( 2 );
    
    if( !k || !v )
        return 0;
        
    if( cs_get_user_team( k ) == CS_TEAM_T && cs_get_user_team( v ) != CS_TEAM_T )
        g_CTDdied = true;
        
    return 0;
}

public roundend()
{
    if( ! g_CTDdied )
        return 0;
        
    for( new i = 1; i <= g_players; i++ )
    {
        if( !is_user_connected( i ) )
            continue;
            
        switch( cs_get_user_team( i ) )
        {
            case CS_TEAM_T: cs_set_user_team( i, CS_TEAM_CT );
            case CS_TEAM_CT: cs_set_user_team( i, CS_TEAM_T );
            
            default: continue;
        }
    }
    
    return 0;
}
__________________

anakin_cstrike is offline
 



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 09:11.


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