AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Printing score every round end. (https://forums.alliedmods.net/showthread.php?t=163961)

Diegorkable 08-05-2011 15:22

Printing score every round end.
 
I have a function, that is called every round end just by the event register, but for some reason, when the round ends the function is called twice, and what it does, it shows, for some reason, in this very odd way:
  • If the CT wins - It shows the score AFTER WINNING twice. (probably function is being called twice and idk why)
  • If T wins - Score is being printed twice with 2 score: the score BEFORE THE TEAM WON, and the score AFTER WINNING (so if the score was 5 - 6, and T won, it would print two lines when the first line says 5 - 6 and then print another line saying 6 - 6 (updated score))


Here is the the function:

PHP Code:

public Event_TeamScore()
{
    if (
g_IsStarted
    {
        
read_data(1szTeamName1)
   
        
iTeam = (szTeamName[0] == 'T') ? 1
        iScore 
read_data(2)
        
iScoreOffset iScore g_iLastTeamScore[iTeam]
    
        if(
iScoreOffset 0)
        {
            
g_iScore[iTeam] += iScoreOffset
        
}
    
        
g_iLastTeamScore[iTeam] = iScore
        
        
if ((g_iScore[0] == 16) || (g_iScore[1] == 16))
        {
            
EndMatch()
            return 
PLUGIN_HANDLED
        
}
        
        
ClientCommand_SayScore()
    }

    return 
PLUGIN_HANDLED
}

public 
ClientCommand_SayScore()
{
    
client_print(0print_chat"Score: (Terrorist) %d - %d (Counter-Terrorist)"g_iScore[0], g_iScore[1])

    return 
PLUGIN_HANDLED
    


This is the logevent register:

PHP Code:

register_logevent("round_end"2"1=Round_End"


Diegorkable 08-07-2011 06:13

Re: Printing score every round end.
 
I thought about it and the only way it could happen is if this function is being called twice. Is it being called at round end + round start? therefore it displays it twice right after the second? and the more wierd thing is, why is it displaying pervious score then current score when T wins, and when CT wins its the current score twice. I tried as an alternative to remove the register_event and instead just call the function every round_end, but then score isn't being printed at all.


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

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