Here's a 1.8.2 version using orpheu. Signatures and code taken from
here. Good luck
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <orpheu>
#include <orpheu_memory>
new const Version[] = "0.3";
#define set_mp_pdata(%1,%2) ( OrpheuMemorySetAtAddress( g_pGameRules, %1, 1, %2 ) )
new g_iRoundsWon[ CsTeams ] , g_pCvarRoundsToSwitch , g_bPluginOn , g_pGameRules;
public plugin_precache()
{
OrpheuRegisterHook( OrpheuGetFunction( "InstallGameRules" ) , "OnInstallGameRules" , OrpheuHookPost );
}
public plugin_init()
{
register_plugin( "Team Switcher" , Version , "bugsy" );
g_pCvarRoundsToSwitch = register_cvar( "ts_switchatwonrounds" , "10" );
register_clcmd( "say /switch" , "ToggleSwitch" );
register_clcmd( "say_team /switch" , "ToggleSwitch" );
register_clcmd( "say /status" , "ShowStatus" );
register_clcmd( "say_team /status" , "ShowStatus" );
register_event( "SendAudio" , "TWin" , "a" , "2&%!MRAD_terwin" );
register_event( "SendAudio" , "CTWin" , "a" , "2&%!MRAD_ctwin" );
g_bPluginOn = true;
}
public OnInstallGameRules()
{
g_pGameRules = OrpheuGetReturn();
}
public ToggleSwitch( id )
{
if ( !( get_user_flags( id ) & ADMIN_KICK ) )
return PLUGIN_HANDLED;
g_bPluginOn = !g_bPluginOn;
client_print( id , print_chat , "[AMXX]: The switch teams is now %sactivated!" , g_bPluginOn ? "" : "de-" );
return PLUGIN_HANDLED;
}
public ShowStatus( id )
{
if ( !( get_user_flags( id ) & ADMIN_KICK ) )
return PLUGIN_HANDLED;
if ( g_bPluginOn )
{
client_print(id, print_chat,"* [CT Wins]: %d | [T Wins]: %d" , g_iRoundsWon[ CS_TEAM_CT ] , g_iRoundsWon[ CS_TEAM_T ] );
}
else
{
client_print(id, print_chat,"* Server Not Mixed");
}
return PLUGIN_HANDLED;
}
public TWin()
{
if ( g_bPluginOn )
{
g_iRoundsWon[ CS_TEAM_T ]++;
CheckWins( CS_TEAM_T );
}
}
public CTWin()
{
if ( g_bPluginOn )
{
g_iRoundsWon[ CS_TEAM_CT ]++;
CheckWins( CS_TEAM_CT );
}
}
CheckWins( CsTeams: csTeam )
{
new iPlayers[ 32 ] , iNum , iPlayer , CsTeams:csCurrentTeam , iTemp;
if ( g_iRoundsWon[ csTeam ] && !( ( g_iRoundsWon[ csTeam ] % get_pcvar_num( g_pCvarRoundsToSwitch ) ) ) )
{
get_players( iPlayers , iNum );
for ( new i = 0 ; i < iNum ; i++ )
{
iPlayer = iPlayers[ i ];
csCurrentTeam = cs_get_user_team( iPlayer );
if ( CS_TEAM_T <= csCurrentTeam <= CS_TEAM_CT )
{
cs_set_user_team( iPlayer , ( csCurrentTeam == CS_TEAM_T ) ? CS_TEAM_CT : CS_TEAM_T );
}
}
iTemp = g_iRoundsWon[ CS_TEAM_T ];
g_iRoundsWon[ CS_TEAM_T ] = g_iRoundsWon[ CS_TEAM_CT ];
g_iRoundsWon[ CS_TEAM_CT ] = iTemp;
set_task( 0.1 , "SetScoreDelay" );
}
}
public SetScoreDelay()
{
set_mp_pdata( "m_iNumTerroristWins" , g_iRoundsWon[ CS_TEAM_T ] );
set_mp_pdata( "m_iNumCTWins" , g_iRoundsWon[ CS_TEAM_CT ] );
UpdateTeamScores( .notifyAllPlugins = true );
}
UpdateTeamScores( const bool:notifyAllPlugins = false )
{
static OrpheuFunction:handleFuncUpdateTeamScores;
if ( !handleFuncUpdateTeamScores )
{
handleFuncUpdateTeamScores = OrpheuGetFunction( "UpdateTeamScores", "CHalfLifeMultiplay" );
}
( notifyAllPlugins ) ?
OrpheuCallSuper( handleFuncUpdateTeamScores, g_pGameRules ) :
OrpheuCall( handleFuncUpdateTeamScores, g_pGameRules );
}