View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-12-2020 , 14:12   Re: [ReQ] teams switch after round 10
Reply With Quote #76

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_iRoundsWonCsTeams ] , g_pCvarRoundsToSwitch g_bPluginOn g_pGameRules;

public 
plugin_precache()
{
    
OrpheuRegisterHookOrpheuGetFunction"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 
ToggleSwitchid )
{
    if ( !( 
get_user_flagsid ) & ADMIN_KICK ) )
        return 
PLUGIN_HANDLED;
    
    
g_bPluginOn = !g_bPluginOn;
    
    
client_printid print_chat "[AMXX]: The switch teams is now %sactivated!" g_bPluginOn "" "de-" );
    
    return 
PLUGIN_HANDLED;
}

public 
ShowStatusid )
{
    if ( !( 
get_user_flagsid ) & ADMIN_KICK ) )
        return 
PLUGIN_HANDLED;
        
    if ( 
g_bPluginOn )
    {    
        
client_print(idprint_chat,"* [CT Wins]: %d  |  [T Wins]: %d" g_iRoundsWonCS_TEAM_CT ] , g_iRoundsWonCS_TEAM_T ] );
    }
    else
    {
        
client_print(idprint_chat,"* Server Not Mixed");
    }
    
    return 
PLUGIN_HANDLED;
}


public 
TWin()
{
    if ( 
g_bPluginOn )
    {
        
g_iRoundsWonCS_TEAM_T ]++;
        
CheckWinsCS_TEAM_T );
    }
}

public 
CTWin()
{
    if ( 
g_bPluginOn )
    {
        
g_iRoundsWonCS_TEAM_CT ]++;
        
CheckWinsCS_TEAM_CT );
    }
}

CheckWinsCsTeamscsTeam )
{
    new 
iPlayers32 ] , iNum iPlayer CsTeams:csCurrentTeam iTemp;
    
    if ( 
g_iRoundsWoncsTeam ] && !( ( g_iRoundsWoncsTeam ] % get_pcvar_numg_pCvarRoundsToSwitch ) ) ) )
    {
        
get_playersiPlayers iNum );
        
        for ( new 
iNum i++ )
        {
            
iPlayer iPlayers];
            
csCurrentTeam cs_get_user_teamiPlayer );
            
            if ( 
CS_TEAM_T <= csCurrentTeam <= CS_TEAM_CT )
            {
                
cs_set_user_teamiPlayer , ( csCurrentTeam == CS_TEAM_T ) ? CS_TEAM_CT CS_TEAM_T );
            }
        }
        
        
iTemp g_iRoundsWonCS_TEAM_T ];
        
g_iRoundsWonCS_TEAM_T ] = g_iRoundsWonCS_TEAM_CT ];
        
g_iRoundsWonCS_TEAM_CT ] = iTemp;
        
        
set_task0.1 "SetScoreDelay" );
    }
}

public 
SetScoreDelay()
{
    
set_mp_pdata"m_iNumTerroristWins" g_iRoundsWonCS_TEAM_T ] );
    
set_mp_pdata"m_iNumCTWins" g_iRoundsWonCS_TEAM_CT ] );
        
    
UpdateTeamScores( .notifyAllPlugins true );
}

UpdateTeamScores( const bool:notifyAllPlugins false )
{
    static 
OrpheuFunction:handleFuncUpdateTeamScores;
    
    if ( !
handleFuncUpdateTeamScores )
    {
        
handleFuncUpdateTeamScores OrpheuGetFunction"UpdateTeamScores""CHalfLifeMultiplay" );
    }
    
    ( 
notifyAllPlugins ) ?
    
OrpheuCallSuperhandleFuncUpdateTeamScoresg_pGameRules ) :
    
OrpheuCallhandleFuncUpdateTeamScoresg_pGameRules );

Attached Files
File Type: zip [signatures] teamscore.zip (2.3 KB, 28 views)
__________________
Bugsy is offline