Raised This Month: $ Target: $400
 0% 

Restarting rounds without resetting team scores


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 11-26-2011 , 17:50   Restarting rounds without resetting team scores
Reply With Quote #1

- TITLE -

How to do that ?
reinert is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-26-2011 , 18:02   Re: Restarting rounds without resetting team scores
Reply With Quote #2

orpheu, two way
1. jump cross the code of resetting team scores (efficient)
2. save scores, hook round restart, set it back. (less efficient than #1)
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 11-26-2011 , 18:03   Re: Restarting rounds without resetting team scores
Reply With Quote #3

What you mean with first method ?
reinert is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-26-2011 , 18:05   Re: Restarting rounds without resetting team scores
Reply With Quote #4

find the asm codes which do the reset stuff, mempatch a jmp bytes before it.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 11-26-2011 , 18:08   Re: Restarting rounds without resetting team scores
Reply With Quote #5

Found this: g_OfSwapAllPlayers
Which swaps player teams and swaps team scores, but after swaping, people still got weapons they had, money they had
reinert is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-26-2011 , 19:41   Re: Restarting rounds without resetting team scores
Reply With Quote #6

You want only team scores ? Because there are others things resetted.
__________________
Arkshine is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 11-27-2011 , 04:25   Re: Restarting rounds without resetting team scores
Reply With Quote #7

Yeah I need to switch teams, switch team scores, then do restart, set scores back.
reinert is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-27-2011 , 07:22   Re: Restarting rounds without resetting team scores
Reply With Quote #8

You can test that.
Unzip in amxmodx/ directory.

What it does :

1/ Hook when a round restart is triggered
2/ Retrieve current team scores
3/ Block coming TeamScore message (because it's updated right away)
4/ Switch team scores
5/ Update scores on scoreboard.

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

/*
    │ PLUGIN
*/
    
new const PluginName   [] = "Switch Team Score On Restart";
    new const 
PluginVersion[] = "1.0";
    new const 
PluginAuhtor [] = "Arkshine";

/*
    | RESTART HANDLING
*/
    
enum GameRulesMembers
    
{
        
m_iNumTerroristWins,
        
m_iNumCTWins,
        
m_bCompleteReset,
        
m_bFirstConnected,
    };

    new const 
GameRulesMIGameRulesMembers ][] =
    {
        
"m_iNumTerroristWins",
        
"m_iNumCTWins",
        
"m_bCompleteReset",
        
"m_bFirstConnected"
    
};

    new 
g_pGameRules;

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

    
new CurrentTerroristWins;
    new 
CurrentCTWins;
    
    new 
TeamScoreMessageIndex;
    
    new 
bool:ReadyToSwitch;


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

public 
OnInstallGameRules()
{
    
g_pGameRules OrpheuGetReturn();
}

public 
plugin_init()
{
    
register_pluginPluginNamePluginVersionPluginAuhtor );
    
    
handleForward();
}

public 
plugin_cfg()
{
    
TeamScoreMessageIndex get_user_msgid"TeamScore" );
}

handleForward()
{
    new 
OrpheuFunction:handleFunc OrpheuGetFunctionFromObjectg_pGameRules"RestartRound""CGameRules" );

    
OrpheuRegisterHookhandleFunc"OnRestartRound_Pre" OrpheuHookPre );
    
OrpheuRegisterHookhandleFunc"OnRestartRound_Post" OrpheuHookPost );
}

public 
OnRestartRound_Pre( const handleGameRules )
{
    if( 
get_mp_pdatam_bCompleteReset ) )
    {
        
CurrentTerroristWins get_mp_pdatam_iNumTerroristWins );
        
CurrentCTWins        get_mp_pdatam_iNumCTWins );

        
set_msg_blockTeamScoreMessageIndexBLOCK_SET );

        
ReadyToSwitch true;
    }
}

public 
OnRestartRound_Post( const handleGameRules )
{
    if( 
ReadyToSwitch )
    {
        
ReadyToSwitch false;

        
set_mp_pdatam_iNumTerroristWinsCurrentCTWins );
        
set_mp_pdatam_iNumCTWinsCurrentTerroristWins );

        
set_msg_blockTeamScoreMessageIndexBLOCK_NOT );
        
updateTeamScore();
    }
}

updateTeamScore()
{
    static 
OrpheuFunction:handleFunchandleFunc || ( handleFunc OrpheuGetFunction"UpdateTeamScores""CHalfLifeMultiplay" ) );
    
OrpheuCallSuperhandleFuncg_pGameRules );

Attached Files
File Type: zip SwitchTeamScoreOnRestart.zip (8.3 KB, 107 views)
__________________

Last edited by Arkshine; 05-14-2015 at 04:37.
Arkshine is offline
colossus
Member
Join Date: Sep 2013
Old 05-13-2015 , 22:42   Re: Restarting rounds without resetting team scores
Reply With Quote #9

Quote:
Originally Posted by Arkshine View Post
You can test that.
Unzip in amxmodx/ directory.

What it does :

1/ Hook when a round restart is triggered
2/ Retrieve current team scores
3/ Block coming TeamScore message (because it's updated right away)
4/ Switch team scores
5/ Update scores on scoreboard.

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

/*
    │ PLUGIN
*/
    
new const PluginName   [] = "Switch Team Score On Restart";
    new const 
PluginVersion[] = "1.0";
    new const 
PluginAuhtor [] = "Arkshine";

/*
    | RESTART HANDLING
*/
    
enum GameRulesMembers
    
{
        
m_iNumTerroristWins,
        
m_iNumCTWins,
        
m_bCompleteReset,
        
m_bFirstConnected,
    };

    new const 
GameRulesMIGameRulesMembers ][] =
    {
        
"m_iNumTerroristWins",
        
"m_iNumCTWins",
        
"m_bCompleteReset",
        
"m_bFirstConnected"
    
};

    new 
g_pGameRules;

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

    
new CurrentTerroristWins;
    new 
CurrentCTWins;
    
    new 
TeamScoreMessageIndex;
    
    new 
bool:GameCommencing;
    new 
bool:ReadyToSwitch;


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

public 
OnInstallGameRules()
{
    
g_pGameRules OrpheuGetReturn();
}

public 
plugin_init()
{
    
register_pluginPluginNamePluginVersionPluginAuhtor );
    
    
handleForward();
}

public 
plugin_cfg()
{
    
TeamScoreMessageIndex get_user_msgid"TeamScore" );
}

handleForward()
{
    
register_event"TextMsg""OnGameCommencing""a""2=#Game_Commencing" );

    new 
OrpheuFunction:handleFunc OrpheuGetFunctionFromObjectg_pGameRules"RestartRound""CGameRules" );

    
OrpheuRegisterHookhandleFunc"OnRestartRound_Pre" OrpheuHookPre );
    
OrpheuRegisterHookhandleFunc"OnRestartRound_Post" OrpheuHookPost );
}

public 
OnGameCommencing()
{
    
GameCommencing true;
}

public 
OnRestartRound_Pre( const handleGameRules )
{
    if( 
GameCommencing )
    {
        
GameCommencing false;
        return;
    }

    if( 
get_mp_pdatam_bCompleteReset ) )
    {
        
CurrentTerroristWins get_mp_pdatam_iNumTerroristWins );
        
CurrentCTWins        get_mp_pdatam_iNumCTWins );

        
set_msg_blockTeamScoreMessageIndexBLOCK_SET );

        
ReadyToSwitch true;
    }
}

public 
OnRestartRound_Post( const handleGameRules )
{
    if( 
ReadyToSwitch )
    {
        
ReadyToSwitch false;

        
set_mp_pdatam_iNumTerroristWinsCurrentCTWins );
        
set_mp_pdatam_iNumCTWinsCurrentTerroristWins );

        
set_msg_blockTeamScoreMessageIndexBLOCK_NOT );
        
updateTeamScore();
    }
}

updateTeamScore()
{
    static 
OrpheuFunction:handleFunchandleFunc || ( handleFunc OrpheuGetFunction"UpdateTeamScores""CHalfLifeMultiplay" ) );
    
OrpheuCallSuperhandleFuncg_pGameRules );

RoundRestart Pre don't work
the score is reset before RoundRestart Pre Hook

the correct way is to get CurrentTerroristWins and CurrentCTWins is in TextMsg


PHP Code:
register_message(get_user_msgid("TextMsg"), "message_textmsg")

public 
message_textmsg()
{
    static 
textmsg[22]
    
    
get_msg_arg_string(2textmsgcharsmax(textmsg))
    
    if (
equal(textmsg"#Game_will_restart_in"))
    {
        
g_iNumTerroristWins get_mp_pdatam_iNumTerroristWins )
        
g_iNumCTWins get_mp_pdatam_iNumCTWins )
    }


Last edited by colossus; 05-13-2015 at 22:43.
colossus is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-14-2015 , 04:29   Re: Restarting rounds without resetting team scores
Reply With Quote #10

No, score is reset inside RestartRound, but I'm not sure why I'm checking against GameCommencing and returning. It's likely wrong, it should not return.
You can remove anything related to GameCommencing, it's not needed. since when round is restarting (so when Game Commencing is triggered), m_bCompleteReset is set to true.
__________________

Last edited by Arkshine; 05-14-2015 at 04:35.
Arkshine is offline
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 07:28.


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