If the EH is added multiple times and then player respawns, it will only fire every second EH that was added. If you then respawn again it will fire the same event handlers again, even if you remove them in the event callback.
Description
Description
Details
Details
- Severity
- Major
- Resolution
- Open
- Reproducibility
- Always
- Operating System
- Windows 10 x64
- Category
- Scripting
Steps To Reproduce
- Create new scenario
- Add one player unit
- Set MP respawn to "Respawn on Position of Death"
- Run in Multiplayer
- Execute this code locally 5 times in a row:
player addEventHandler ["Killed", { params ["_unit", "_killer", "_instigator", "_useEffects"]; systemChat format ["== %1 KILLED %2", _unit, _thisEventHandler]; _unit removeEventHandler ["Killed", _thisEventHandler]; }];
- Press respawn
- Note that systemChat indicates that only the 0, 2 and 4 instances of the event handler actually fired.
- Press respawn again and note that the same instances fire again, even though removeEventHandler is being called in the event callback.
Additional Information
Lou Montana also reproduced this issue.
Event Timeline
Comment Actions
I just determined that if I don't call removeEventHandler in the callback it executes every callback instance.