Closed Cryptite closed 5 months ago
Nice catch! How about not adding the player to the list first, calling the event, check-adding him if not cancelled?
Pseudo code:
if !players.contains(p)
if call(event).cancelled()
return
if players.add(p)
return
...
Yeah I suppose contains could be slightly more performant than a guaranteed add and remove, which would have the set being reordered twice.
This is perhaps not the the best way go to about it, but in our case this was causing an issue.
If you hadn't otherwise provided a tracking rule, but still wanted to cancel the pre track event, you could never subsequently track an NPC because the player was already in the trackedPlayers collection, despite having been cancelled.