Raised This Month: $51 Target: $400
 12% 

I'm struggling with win round event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoldNux
Senior Member
Join Date: Mar 2018
Old 11-06-2022 , 09:54   I'm struggling with win round event
Reply With Quote #1

I'm testing a plugin that will switch players every round. (The bomb is auto planted)
To keep track of scores and swap the scores on the scoreboard I have some code.

First I used:
PHP Code:
    register_event("SendAudio""Event_WinT""a""2&%!MRAD_terwin")
    
register_event("SendAudio""Event_WinCT""a""2&%!MRAD_ctwin"
But then I switched to using:
PHP Code:
    register_logevent("Event_CTWin"6"3=CTs_Win""3=Target_Defused")
    
register_logevent("Event_TerroristWin" 6"3=Terrorists_Win""3=Target_Bombed"
The documentation on register_logevent is weak and I'm not sure how to use it.
I tried adding Target_Defused but it does not respond to defusion.

Anyways, I have issues with both.
It seems that when I hook the sound and I'm alone on the server and die from the bomb going of, one team is given two points.

I figured this was because both sounds are played.
So I tried to use register_logevent but then defusion does not count and if I remember correctly I also had some issues with it giving two points from one win.

All I know is the functions I call from the events are called more times then it should for some reason.

I also tried using both but this does not solve the issue that one might be triggered at the same time if a player is alone on the server.
PHP Code:
    register_logevent("Event_TerroristWin" 6"3=Terrorists_Win""3=Target_Bombed")
    
register_event("SendAudio""Event_WinCT""a""2&%!MRAD_ctwin"
But had the same problem.
Here are two versions of the functions called:
I can't see any issues with the logic in any of them.

PHP Code:
public Event_Win(isTWin)
{
    new 
isRoundEven g_RoundCounter == 0;
    new 
teamOneWon = (isRoundEven && isTWin) || (!isRoundEven && !isTWin)
    if (
teamOneWon)
    {
        
g_TeamOneScore++
        
set_hudmessage(2001000, -1.00.3016.02.50.10.2);
        
show_hudmessage(0"TEAM ONE WIN!");
    }
    else
    {
        
g_TeamTwoScore++
        
set_hudmessage(2001000, -1.00.3016.02.50.10.2);
        
show_hudmessage(0"TEAM TWO WIN!");
    }
    
    
SwapAlivePlayers();
    
set_hudmessage(2001000, -1.00.3016.02.50.10.2);
    
show_hudmessage(0"TEAM ONE ( %d | %d ) TEAM TWO"g_TeamOneScoreg_TeamTwoScore);
    
UpdateScoreboard();
    
CheckScores();

This one is messy:

PHP Code:
public Event_WinT()
{
    new 
isRoundEven g_RoundCounter == 0;
    if (!
isRoundEven)
    {
        
g_TeamOneScore++
        
set_hudmessage(2001000, -1.00.3016.02.50.10.2);
        
show_hudmessage(0"TEAM ONE WIN!");
    }
    else
    {
        
g_TeamTwoScore++
        
set_hudmessage(2001000, -1.00.3016.02.50.10.2);
        
show_hudmessage(0"TEAM TWO WIN!");
    }

    
SwapAlivePlayers();
    
set_hudmessage(2001000, -1.00.3016.02.50.10.2);
    
show_hudmessage(0"TEAM ONE ( %d | %d ) TEAM TWO"g_TeamOneScoreg_TeamTwoScore);
    
UpdateScoreboard();
    
CheckScores();
}

public 
Event_WinCT()
{
    new 
isRoundEven g_RoundCounter == 0;
    if (!
isRoundEven)
    {
        
g_TeamTwoScore++
        
set_hudmessage(2001000, -1.00.3016.02.50.10.2);
        
show_hudmessage(0"TEAM TWO WIN!");
    }
    else
    {
        
g_TeamOneScore++
        
set_hudmessage(2001000, -1.00.3016.02.50.10.2);
        
show_hudmessage(0"TEAM ONE WIN!");
    }

    
SwapAlivePlayers();
    
set_hudmessage(2001000, -1.00.3016.02.50.10.2);
    
show_hudmessage(0"TEAM ONE ( %d | %d ) TEAM TWO"g_TeamOneScoreg_TeamTwoScore);
    
UpdateScoreboard();
    
CheckScores();

GoldNux is offline
GoldNux
Senior Member
Join Date: Mar 2018
Old 11-06-2022 , 10:42   Re: I'm struggling with win round event
Reply With Quote #2

This is a horrible way to solve the issue but at least I know for sure what the issue was.
PHP Code:
public Event_WinCT()
{
    new 
alivePlayers[32];
    new 
playerCount;
    
get_players(alivePlayersplayerCount"ach")
    if (
playerCount != 0)
        
code..
    { 
GoldNux 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 12:56.


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