Raised This Month: $ Target: $400
 0% 

Printing score every round end.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 08-05-2011 , 15:22   Printing score every round end.
Reply With Quote #1

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 is offline
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 08-07-2011 , 06:13   Re: Printing score every round end.
Reply With Quote #2

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.
Diegorkable is offline
Reply



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


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