03-20-2012, 11:29 PM
You know, a "please" would take you a long way
For the plugin author: The GetAllPlayers() method is not implemented in newer MCS versions and has been replaced with calls to ForEachPlayer() (due to multithreading issues). The Core plugin already uses this approach so you can see how it's used there.
Basically the issue is that GetAllPlayers() returned a player instance and another thread could invalidate that instance before the lua plugin could even touch it. So instead you provide a callback that is called for each player and the mechanism guarantees that the player instance is valid throughout the callback's execution. Note though that you should NOT store the player instance for later processing (same issue as with GetAllPlayers() ) and you should make the callback as fast as possible, avoiding heavy calculations or such, because a critical section is held during the callback which effectively stops all other MCS threads from touching the players list.
For the plugin author: The GetAllPlayers() method is not implemented in newer MCS versions and has been replaced with calls to ForEachPlayer() (due to multithreading issues). The Core plugin already uses this approach so you can see how it's used there.
Basically the issue is that GetAllPlayers() returned a player instance and another thread could invalidate that instance before the lua plugin could even touch it. So instead you provide a callback that is called for each player and the mechanism guarantees that the player instance is valid throughout the callback's execution. Note though that you should NOT store the player instance for later processing (same issue as with GetAllPlayers() ) and you should make the callback as fast as possible, avoiding heavy calculations or such, because a critical section is held during the callback which effectively stops all other MCS threads from touching the players list.