aliasmask wrote:
Code:
[H, if(isGM()), code: {
[H: plGM = json.intersection(plGM,getAllPlayerNames("json"))]
[H: setLibProperty("PlayersGM", json.union( plGM, getPlayerName() ), gLib )]
};{}]
Only updates when GM is loading, it removes anyone who's not currently in the players list, then adds the current GM name. I like your solution to updating another lib token. Seems to help on the race condition. I had another way of doing it. I would get current map and if it wasn't the lib map, I would change the map to lib map (at top of macro), then at bottom I would set property, then change map back. The couple of lines in between seemed to fix the race condition and token duplication. Only side effect would be a split second of black screen, but on load, didn't make any difference.
Ah, yes. There is one thing I forgot with that update. Demoting GMs to players. It works fine when the server is first started, but if a person logs in as a 2nd GM, but then relogs as a player with the same name, they'll still get the GM info for output. This can be resolved by the following change:
Code:
[H, if(! json.isEmpty(plGM)): plGM = lower(plGM)]
[H: playerName = lower(getPlayerName)]
[H, if(isGM()), code: {
[H: plGM = json.intersection(plGM,lower(getAllPlayerNames("json")))]
[H: setLibProperty("PlayersGM", json.union( plGM, playerName), gLib )]
};{
[H, if(json.contains(plGM,playerName)): setLibProperty("PlayersGM", json.remove(plGM,playerName), gLib)]
}]
edit: also, needed to account for case because Chris != chris when making json comparisons but maptool would convert and treat as the same.