- Code: Select all
public override void UserJoined(Player player) {
if (PlayerCount < 2){
player.Send("wait");
}else{
if(!init){
InitGame();
init=true;//init is a private variable, set to false when new game is created
}
However, if 2 users join in the same moment, InitGame function gets executed twice. It's like 2 UserJoined function would get executed simultaneously, causing InitGame to be executed twice too. How to fix that? Thanks.