AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED][HELP] Setting team scores (https://forums.alliedmods.net/showthread.php?t=233339)

connoisseur 01-13-2014 09:07

[SOLVED][HELP] Setting team scores
 
Hi, I used the following method to set team scores on the scoreboard.
It works fine, but as the new round starts, the team scores set back according to the original values which they previously had. They do not continue according to the new values provided.
Code:
public plugin_init() {       .......       gTeamScore = get_user_msgid("TeamScore") } public changescores() {       message_begin(MSG_ALL,gTeamScore)       write_string("TERRORIST")       write_short(g_tscore)       message_end()       message_begin(MSG_ALL,gTeamScore)       write_string("CT")       write_short(g_ctscore)       message_end() }
How can I keep the new scores saved?

DavidJr 01-13-2014 09:32

Re: [HELP] Setting team scores
 
Store the score in array, and when the round starts, set it again

connoisseur 01-13-2014 09:41

Re: [HELP] Setting team scores
 
Quote:

Originally Posted by DavidJr (Post 2085335)
Store the score in array, and when the round starts, set it again

Do you mean setting the scores every round again and again?
That can be done, but I was wondering if it could somehow just carry on using the new scores. Setting every round doesn't seem like the optimum way.

Isn't there any way I can edit the variables where the actual scores are stored in the game?

DavidJr 01-13-2014 09:52

Re: [HELP] Setting team scores
 
I guess you can't. Maybe it is possible with Orpheu

connoisseur 01-13-2014 10:07

Re: [HELP] Setting team scores
 
Quote:

Originally Posted by DavidJr (Post 2085354)
I guess you can't. Maybe it is possible with Orpheu

I don't know how to code using orpheu, I'm not that experienced in pawn scripting.
It would be great if someone could provide the code. :oops:

wickedd 01-13-2014 18:41

Re: [HELP] Setting team scores
 
You don't need orpheu.

ConnorMcLeod 01-14-2014 00:07

Re: [HELP] Setting team scores
 
Try to add in plugin_init :

PHP Code:

set_msg_block(gTeamScoreBLOCK_SET


Also, you have to understand that "TeamScore" message is just used to set the visual part of score on client hud, if you want to change the real value, you need to set some internal data that can only be accessed with orpheu module.

Code i gave you will block messages that the game is sending, so only messages from the plugin gonna be received by players, it should be fine.

connoisseur 01-14-2014 00:59

Re: [HELP] Setting team scores
 
Thanks. But there's a small problem in applying that way. If I use sv_restart at some point, the team scores will not set back to 0-0, they will still be set according to g_tscore/g_ctscore.

ConnorMcLeod 01-14-2014 13:03

Re: [HELP] Setting team scores
 
PHP Code:

new bool:g_bRestarting;

public 
plugin_init()
{
    
register_event("TextMsg""Event_TextMsg_Restart""a""2&#Game_C""2&#Game_w");
    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0");
}

public 
Event_TextMsg_Restart()
{
    
g_bRestarting true;
}

public 
Event_HLTV_New_Round()
{
    if( 
g_bRestarting )
    {
        
g_bRestarting false;
        
// Set score to 0-0 here
    
}


Also, you may have to send TeamScore message to connecting or just connected players.

hornet 01-15-2014 18:23

Re: [HELP] Setting team scores
 
1 Attachment(s)
If you have Orpheu installed, then this is the easy way of life:
Spoiler


All times are GMT -4. The time now is 10:05.

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