L0771 wrote:if you use player.name, i think you need to know if player.name was set
hm... I'm going to go out on a limb and assume that people playing in multiplayer will set a name...I didn't want to use the playerindex because I assume those could change as players leave (after game.removeofflineplayers is called) which would end up making the code treat the 'same' players as different players. I'm not certain but maybe it could be indexed based on the actual player object? However, that would likely create new, distinct, player objects after game.removeofflineplayers is called and they join again, which would lead to lost settings that the nickname index wouldn't have a problem with. Not a huge issue admittedly, but something to take note of.
L0771 wrote:I think you don't need restart gui every load
Originally it was set to remove the gui onsave (so it didn't leave orphaned guis when the mod was removed), as such onload the gui needed to be restored with init_gui. That worked fine in SP, not so well in MP it turns out.
L0771 wrote:i don't know why but in a new game with your code 2/10 games i had ctd
Interesting, I didn't experience any ctds in the limited testing I did, neither did FishSandwich as far as I could tell. So no idea what's causing that.
P.S.
apparently FishSandwich had to comment out both onsave AND onload to get it to work (mostly) as intended, I, however, have no idea why/how onload could make the gui disappear (it's very much intended to do the opposite).
Choumiko wrote:Perhaps onplayercreated is called whenever a player joins a mp game?
From my understanding it's called when a player first joins the game (or after they've left, game.removeofflineplayers is called, and they join again).
Choumiko wrote:Not sure how onload exactly works, but in a mp game it can't possibly have a list of players as anyone could join or only join the game once and never return?
Well... it's a bit complicated to think about. I can understand it not having a list of all players since there are only two forces and it just needs to keep track of which force entities belong to (and what has been researched, etc. for those forces), not sure how that'll be handled in 12.x with separate forces, except I'm assuming that when you reload a save and players rejoin it that they start where they were when the game was saved so it has to be able to reconnect the joining players to the players/characters who were there previously and thus would need a list... note: I haven't played MP so... I'm really doing a lot of this 'blind', I could be entirely wrong on some of my assumptions. Also, when the game is first started from a save, I'd kind of expect it to have game.players[1] (or whatever the proper index would be for the player that opened the save, not sure how that's handled if they had a different index during the game then saved it and loaded it later theirselves).
However in the simpler case and the one causing the most issue really, autosaves, it _could_ have a list of all current players, at least I would think so, because, well they're still connected...