Raised This Month: $ Target: $400
 0% 

How can I detect team score ?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-22-2013 , 11:30   Re: How can I detect team score ?
Reply With Quote #4

This is how teams scores are updated in the game :

Code:
void CHalfLifeMultiplay::UpdateTeamScores()
{
	MESSAGE_BEGIN(MSG_ALL, gmsgTeamScore);
	WRITE_STRING("CT");
	WRITE_SHORT(m_iCTsScore);
	MESSAGE_END();

	MESSAGE_BEGIN(MSG_ALL, gmsgTeamScore);
	WRITE_STRING("TERRORIST");
	WRITE_SHORT(m_iTerroristsScore);
	MESSAGE_END();
}
So if you want to hook it, you need to always wait for the second message.

PHP Code:
new g_iCTsScoreg_iTerroristsScore;

public 
plugin_init()
{
    
register_event("TeamScore""Event_TeamScore""a");
}

public 
Event_TeamScore()
{
    new 
szTeam[2];
    
read_argv(1szTeamcharsmax(szTeam));
    switch( 
szTeam[0] )
    {
        case 
'C':
        {
            
// CT Score, T's has not been sent yet, wait for next message.
            
g_iCTsScore read_data(2);
        }
        case 
'T':
        {
            
g_iTerroristsScore read_data(2);
            
// both messages has been sent, you can use values now.
        
}
    }


And if you want to send your own values (won't be real score, only what appears in scoreboard), then you can use this :
PHP Code:
new gmsgTeamScore;

public 
plugin_init()
{
    
gmsgTeamScore get_user_msgid("TeamScore");
}

UpdateTeamScores(iCTsScoreiTerroristsScore)
{
    
emessage_begin(MSG_ALLgmsgTeamScore);
    
ewrite_string("CT");
    
ewrite_short(iCTsScore);
    
emessage_end();

    
emessage_begin(MSG_ALLgmsgTeamScore);
    
ewrite_string("TERRORIST");
    
ewrite_short(iTerroristsScore);
    
emessage_end();


Also, if you want to change real score values, you need plugins using a module such as orpheu or rage.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 05-22-2013 at 11:33.
ConnorMcLeod is offline
 



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 16:22.


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