 |
|
AMX Mod X Plugin Approver
|

12-18-2011
, 13:11
Re: Why is this getting called multiple times?
|
#4
|
That's not a bug. It's more a lack of knowledge of the game (AMXX scripting).
The game basically does that (at least just on what it's related to the problem) :
- When a player is killed, CheckWinConditions is called 2 times (This function checks/handles round end)
- When a round is triggered, things are done in this order : SendAudio -> TeamScore -> Log -> m_iRoundWinStatus (m_iRoundWinStatus is the offset which holds what team has won)
What happens when a round end is triggered :
- m_iRoundWinStatus is setted to a value
- To avoid to run multiple round end, a check exists at the top of the function, checking if m_iRoundWinStatus hold a value. If so, we ignore. The offset is reset when a new round starts.
What happens when you kill players when you hook SendAudio ? :
- m_iRoundWinStatus is not set yet, and killing players will call 2 times CheckWinConditions (per player).
- CheckWinConditions is called while hooking SendAudio, but since m_iRoundWinStatus is not set yet, another round end will be triggered.
Conclusion : You should avoid killing players when the round end has just started. Hooking SendAudio/Log is not really reliable to know which team has won because some others plugins could kill players at this time, though adding a system to avoid to execute multiple times would be enough.
__________________
Last edited by Arkshine; 12-18-2011 at 13:12.
|
|
|
|