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 % 2 == 0;
new teamOneWon = (isRoundEven && isTWin) || (!isRoundEven && !isTWin)
if (teamOneWon)
{
g_TeamOneScore++
set_hudmessage(200, 100, 0, -1.0, 0.30, 1, 6.0, 2.5, 0.1, 0.2);
show_hudmessage(0, "TEAM ONE WIN!");
}
else
{
g_TeamTwoScore++
set_hudmessage(200, 100, 0, -1.0, 0.30, 1, 6.0, 2.5, 0.1, 0.2);
show_hudmessage(0, "TEAM TWO WIN!");
}
SwapAlivePlayers();
set_hudmessage(200, 100, 0, -1.0, 0.30, 1, 6.0, 2.5, 0.1, 0.2);
show_hudmessage(0, "TEAM ONE ( %d | %d ) TEAM TWO", g_TeamOneScore, g_TeamTwoScore);
UpdateScoreboard();
CheckScores();
}
This one is messy:
PHP Code:
public Event_WinT()
{
new isRoundEven = g_RoundCounter % 2 == 0;
if (!isRoundEven)
{
g_TeamOneScore++
set_hudmessage(200, 100, 0, -1.0, 0.30, 1, 6.0, 2.5, 0.1, 0.2);
show_hudmessage(0, "TEAM ONE WIN!");
}
else
{
g_TeamTwoScore++
set_hudmessage(200, 100, 0, -1.0, 0.30, 1, 6.0, 2.5, 0.1, 0.2);
show_hudmessage(0, "TEAM TWO WIN!");
}
SwapAlivePlayers();
set_hudmessage(200, 100, 0, -1.0, 0.30, 1, 6.0, 2.5, 0.1, 0.2);
show_hudmessage(0, "TEAM ONE ( %d | %d ) TEAM TWO", g_TeamOneScore, g_TeamTwoScore);
UpdateScoreboard();
CheckScores();
}
public Event_WinCT()
{
new isRoundEven = g_RoundCounter % 2 == 0;
if (!isRoundEven)
{
g_TeamTwoScore++
set_hudmessage(200, 100, 0, -1.0, 0.30, 1, 6.0, 2.5, 0.1, 0.2);
show_hudmessage(0, "TEAM TWO WIN!");
}
else
{
g_TeamOneScore++
set_hudmessage(200, 100, 0, -1.0, 0.30, 1, 6.0, 2.5, 0.1, 0.2);
show_hudmessage(0, "TEAM ONE WIN!");
}
SwapAlivePlayers();
set_hudmessage(200, 100, 0, -1.0, 0.30, 1, 6.0, 2.5, 0.1, 0.2);
show_hudmessage(0, "TEAM ONE ( %d | %d ) TEAM TWO", g_TeamOneScore, g_TeamTwoScore);
UpdateScoreboard();
CheckScores();
}