AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   When someone kill someone switch their teams. (https://forums.alliedmods.net/showthread.php?t=82424)

xbatista 12-23-2008 02:54

When someone kill someone switch their teams.
 
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 :(

anakin_cstrike 12-23-2008 07:04

Re: When someone kill someone switch their teams.
 
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;
}


xbatista 12-23-2008 07:12

Re: When someone kill someone switch their teams.
 
THX!!!!!!!!!!!!!!!!!!!!!!
Will try/test.

xbatista 12-23-2008 07:35

Re: When someone kill someone switch their teams.
 
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 :))) :mrgreen: .
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...

Dores 12-23-2008 08:29

Re: When someone kill someone switch their teams.
 
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; }

xbatista 12-23-2008 08:30

Re: When someone kill someone switch their teams.
 
going to try :}}

anakin_cstrike 12-23-2008 08:32

Re: When someone kill someone switch their teams.
 
I think this is useless
PHP Code:

static iMaxPlayers;
    if( !
iMaxPlayers )
    {
        
iMaxPlayers get_maxplayers(); 

but, however..
}

Dores 12-23-2008 08:33

Re: When someone kill someone switch their teams.
 
I know it's kinda useless, but better be safe than sorry...

EDIT: @xbatista: Try now, I fixed it a bit.

xbatista 12-23-2008 08:39

Re: When someone kill someone switch their teams.
 
Now? ok.

xbatista 12-23-2008 08:47

Re: When someone kill someone switch their teams.
 
prints in console:native error get_user_attacker in ev_Death.
And NO switches :((


All times are GMT -4. The time now is 09:11.

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