View Single Post
reinert
Veteran Member
Join Date: Feb 2007
Old 04-25-2011 , 10:26   Re: Switch team scores
Reply With Quote #5

Oh ok, I've made it myself something like:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <orpheu>
#include <orpheu_memory>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define SCORE_T 0
#define SCORE_CT 1

#define set_mp_pdata(%1,%2)  ( OrpheuMemorySetAtAddress( g_pGameRules, %1, 1, %2 ) )
#define get_mp_pdata(%1)     ( OrpheuMemoryGetAtAddress( g_pGameRules, %1 ) )

new g_pGameRules;
new 
g_TeamScore[2];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("TeamScore""eventTeamScore""a");
    
    
register_clcmd"say /swap""ClientCommand_SetTeamScore");
}

public 
plugin_precache()
{
    
OrpheuRegisterHookOrpheuGetFunction"InstallGameRules" ), "OnInstallGameRules"OrpheuHookPost );
}

public 
OnInstallGameRules()
{
    
g_pGameRules OrpheuGetReturn();
}

public 
eventTeamScore()
{
    new 
sTeam[2];
    
read_data(1sTeam1);
    if( 
sTeam[0] == 'T' )
    {
        
g_TeamScore[SCORE_T] = read_data(2);
    }
    else
    {
        
g_TeamScore[SCORE_CT] = read_data(2);
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
ClientCommand_SetTeamScore ()
{                
    
set_mp_pdata"m_iNumCTWins"g_TeamScore[SCORE_T] );
           
    
set_mp_pdata"m_iNumTerroristWins"g_TeamScore[SCORE_CT] );
        
    
UpdateTeamScores( .notifyAllPlugins true );
}

UpdateTeamScores ( const bool:notifyAllPlugins false )
    {
        static 
OrpheuFunction:handleFuncUpdateTeamScores;

        if ( !
handleFuncUpdateTeamScores )
        {
            
handleFuncUpdateTeamScores OrpheuGetFunction"UpdateTeamScores""CHalfLifeMultiplay" )
        }

        ( 
notifyAllPlugins ) ?

            
OrpheuCallSuperhandleFuncUpdateTeamScoresg_pGameRules ) :
            
OrpheuCallhandleFuncUpdateTeamScoresg_pGameRules );
    } 
Tested and it works, but I think ur code is better anyways ? is it ?
reinert is offline