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_iCTsScore, g_iTerroristsScore;
public plugin_init()
{
register_event("TeamScore", "Event_TeamScore", "a");
}
public Event_TeamScore()
{
new szTeam[2];
read_argv(1, szTeam, charsmax(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(iCTsScore, iTerroristsScore)
{
emessage_begin(MSG_ALL, gmsgTeamScore);
ewrite_string("CT");
ewrite_short(iCTsScore);
emessage_end();
emessage_begin(MSG_ALL, gmsgTeamScore);
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.
__________________