public void onPlayerJoined(Player player) { Console.WriteLine("[lobby] Player joined: " + player.Id); if(room.numPlayers >= RoomInstance.MAX_PLAYERS) { Console.WriteLine("[lobby] Player cap reached, kicking... (current=" + room.numPlayers + ", max=" + RoomInstance.MAX_PLAYERS + ")"); player.kick("max_players"); return; } player.nickname = player.JoinData["nickname"]; if(player.nickname.ToUpper() == "SYSTEM") { Console.WriteLine("[lobby] Player uses restricted nickname, kicking... "); player.kick("nickname_not_allowed"); return; } room.numPlayers++; Console.WriteLine("Player joined: " + player.nickname); room.Broadcast(MessageTypes.SV_PLAYER_JOINED, player.Id, player.nickname); foreach(Player p in room.Players) { if(p.Id != player.Id) { // send to everyone but joining player his own data Console.WriteLine("[lobby] Sending " + p + " data about " + player); p.Send(MessageTypes.SV_PLAYER_REGISTER, p.Id, p.nickname, false, p.isHost); } // send him everyone's data (including his own) Console.WriteLine("[lobby] Sending " + player + " data about " + p); player.Send(MessageTypes.SV_PLAYER_REGISTER, p.Id, p.nickname, (player.Id == p.Id), p.isHost); } }
public void onPlayerJoined(Player player) { player.kick("in_progress"); }