Raised This Month: $ Target: $400
 0% 

When someone kill someone switch their teams.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 12-23-2008 , 02:54   When someone kill someone switch their teams.
Reply With Quote #1

What the code that will example:
If terrorist kills a CT ,on round end terrorist will go to CT team and CT will go to terrorist team.?
Thx.

P.S.If terrorist kills a CT then switch on round end.!!!

Quote:
P.S. Bad english (( sorry
Short description: Terrorist(player) killed a CT(player) switch their teams on round end,if CT(player) killed a Terrorist(player) nothing does...
I'm tired

Last edited by xbatista; 12-23-2008 at 07:59.
xbatista is offline
Send a message via Skype™ to xbatista
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
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 12-23-2008 , 07:12   Re: When someone kill someone switch their teams.
Reply With Quote #3

THX!!!!!!!!!!!!!!!!!!!!!!
Will try/test.
xbatista is offline
Send a message via Skype™ to xbatista
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 12-23-2008 , 07:35   Re: When someone kill someone switch their teams.
Reply With Quote #4

It works, but how to do:if terrorist(player) killed a ct(player),then terrorist(player) go to ct team and CT(player) go to terrorist team? :}} NOT THIS!!! : if ct(player) killed a terrorist(player).
Please help :/
And sorry I forget to post : (player)
not all team )) .
And if CT(player) killed a terrorist(player) nothing to do/no switches...


P.S. Bad english (( sorry
Short description: Terrorist(player) killed a CT(player) switch their teams on round end,if CT(player) killed a Terrorist(player) nothing does...

Last edited by xbatista; 12-23-2008 at 07:58.
xbatista is offline
Send a message via Skype™ to xbatista
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-23-2008 , 08:29   Re: When someone kill someone switch their teams.
Reply With Quote #5

CVar:
  • amx_spt < 1 | 0 > - If 1(default), players' teams will switch if a terrorist killed a ct.
Code:
#include <amxmodx> #include <cstrike> #define VERSION "1.0" new p_On; new bool:g_bSwitch[ 33 ]; public plugin_init() {     register_plugin( "Switch Players Teams", VERSION, "Dores" );         p_On = register_cvar( "amx_spt", "1" );     register_event( "DeathMsg", "ev_Death", "a" );     register_logevent( "logev_roundEnd", 2, "1=Round_End" ); } public ev_Death( iVic ) {     if( !get_pcvar_num( p_On ) )     {         return PLUGIN_CONTINUE;     }         static iAtt ; iAtt = get_user_attacker( iVic );         if( cs_get_user_team( iVic ) == CS_TEAM_CT && cs_get_user_team( iAtt ) == CS_TEAM_T )     {         g_bSwitch[ iVic ] = true;         g_bSwitch[ iAtt ] = true;     }         return PLUGIN_CONTINUE; } public client_disconnect( id ) {     g_bSwitch[ id ] = false; } public logev_roundEnd() {     if( !get_pcvar_num( p_On ) )     {         return PLUGIN_CONTINUE;     }         static iMaxPlayers;     if( !iMaxPlayers )     {         iMaxPlayers = get_maxplayers();     }         static i;     static CsTeams:team;     for( i = 1 ; i <= iMaxPlayers ; i++ )     {         if( !is_user_connected( i ) || !g_bSwitch[ i ] )             continue;                 team = cs_get_user_team( i );         if( team == CS_TEAM_SPECTATOR || team == CS_TEAM_UNASSIGNED )         {             g_bSwitch[ i ] = false;             continue;         }                 cs_set_user_team( i, ( team % CS_TEAM_CT ) + CS_TEAM_T );         g_bSwitch[ i ] = false;     }         return PLUGIN_CONTINUE; }
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 12-23-2008 at 08:32.
Dores is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 12-23-2008 , 08:30   Re: When someone kill someone switch their teams.
Reply With Quote #6

going to try :}}
xbatista is offline
Send a message via Skype™ to xbatista
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 12-23-2008 , 08:32   Re: When someone kill someone switch their teams.
Reply With Quote #7

I think this is useless
PHP Code:
static iMaxPlayers;
    if( !
iMaxPlayers )
    {
        
iMaxPlayers get_maxplayers(); 
but, however..
}
__________________

anakin_cstrike is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-23-2008 , 08:33   Re: When someone kill someone switch their teams.
Reply With Quote #8

I know it's kinda useless, but better be safe than sorry...

EDIT: @xbatista: Try now, I fixed it a bit.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 12-23-2008 , 08:39   Re: When someone kill someone switch their teams.
Reply With Quote #9

Now? ok.
xbatista is offline
Send a message via Skype™ to xbatista
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 12-23-2008 , 08:47   Re: When someone kill someone switch their teams.
Reply With Quote #10

prints in console:native error get_user_attacker in ev_Death.
And NO switches (
xbatista is offline
Send a message via Skype™ to xbatista
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 09:11.


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