AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How can I detect team score ? (https://forums.alliedmods.net/showthread.php?t=216469)

Moody92 05-21-2013 14:13

How can I detect team score ?
 
I've been looking around on how to detect team score, I found bunch of cshack module plugins.

and I thought cshack is a dead module so I decided to ask if there's another way to do it ?

jimaway 05-21-2013 14:26

Re: How can I detect team score ?
 
http://wiki.amxmodx.org/Half-Life_1_...ents#TeamScore

SicknessArG 05-22-2013 07:40

Re: How can I detect team score ?
 
What exactly you wanna do? Cause you can get the score, but you can't change it from scoreboard with some codes...

I've made a stock to change the score without modules, but it isn't a value, it just show what I want to show... You can take a look from my code to see what I'm talking about -link-.

This is the stock -link-.

Hope to be useful.

Sorry for my bad english.

ConnorMcLeod 05-22-2013 11:30

Re: How can I detect team score ?
 
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.

Moody92 05-30-2013 02:22

Re: How can I detect team score ?
 
Quote:

Originally Posted by ConnorMcLeod (Post 1956319)

Thank you alot, really helped me in my misery


All times are GMT -4. The time now is 16:22.

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