void MyMultiplayerClient_HostLeft() { m_clientJoined = false; CloseClient(); MyGuiScreenMainMenu.UnloadAndExitToMenu(); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MySpaceTexts.MultiplayerErrorServerHasLeft))); }
public override void UpdateAfterSimulation() { if (Enabled && MySandboxGame.IsGameReady && MySession.Static != null && MySession.Static.ElapsedPlayTime.TotalSeconds > 5) { GC.Collect(2, GCCollectionMode.Forced); MySandboxGame.Log.WriteLine(String.Format("RELOAD TEST, Game GC: {0} B", GC.GetTotalMemory(false).ToString("##,#"))); MySandboxGame.Log.WriteLine(String.Format("RELOAD TEST, Game WS: {0} B", Process.GetCurrentProcess().PrivateMemorySize64.ToString("##,#"))); MyGuiScreenMainMenu.UnloadAndExitToMenu(); } }
void Matchmaking_LobbyChatUpdate(Lobby lobby, ulong changedUser, ulong makingChangeUser, ChatMemberStateChangeEnum stateChange) { //System.Diagnostics.Debug.Assert(MySession.Static != null); if (lobby.LobbyId == Lobby.LobbyId) { if (stateChange == ChatMemberStateChangeEnum.Entered) { MySandboxGame.Log.WriteLineAndConsole("Player entered: " + MySteam.API.Friends.GetPersonaName(changedUser) + " (" + changedUser + ")"); MyTrace.Send(TraceWindow.Multiplayer, "Player entered"); Peer2Peer.AcceptSession(changedUser); RaiseClientJoined(changedUser); if (MySandboxGame.IsGameReady && changedUser != ServerId) { var playerJoined = new MyHudNotification(MySpaceTexts.NotificationClientConnected, 5000, level: MyNotificationLevel.Important); playerJoined.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser)); MyHud.Notifications.Add(playerJoined); } } else { RaiseClientLeft(changedUser, stateChange); if (changedUser == ServerId) { MyTrace.Send(TraceWindow.Multiplayer, "Host left: " + stateChange.ToString()); RaiseHostLeft(); MyGuiScreenMainMenu.UnloadAndExitToMenu(); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MySpaceTexts.MultiplayerErrorServerHasLeft))); // Set new server //ServerId = Lobby.GetOwner(); //if (ServerId == Sync.MyId) //{ // Lobby.SetLobbyData(HostNameTag, Sync.MyName); //} } else if (MySandboxGame.IsGameReady) { var playerLeft = new MyHudNotification(MySpaceTexts.NotificationClientDisconnected, 5000, level: MyNotificationLevel.Important); playerLeft.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser)); MyHud.Notifications.Add(playerLeft); } } } }
void OnUserJoined(ref JoinResultMsg msg) { if (msg.JoinResult == JoinResult.OK) { if (OnJoin != null) { OnJoin(); OnJoin = null; m_clientJoined = true; } } else if (msg.JoinResult == JoinResult.NotInGroup) { MyGuiScreenMainMenu.UnloadAndExitToMenu(); Dispose(); ulong groupId = Server.GetGameTagByPrefixUlong("groupId"); string groupName = MySteam.API.Friends.GetClanName(groupId); var messageBox = MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: new StringBuilder(string.Format( MyTexts.GetString(MyCommonTexts.MultiplayerErrorNotInGroup), groupName)), buttonType: MyMessageBoxButtonsType.YES_NO); messageBox.ResultCallback = delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { MySteam.API.OpenOverlayUser(groupId); } ; }; MyGuiSandbox.AddScreen(messageBox); } else if (msg.JoinResult == JoinResult.BannedByAdmins) { MyGuiScreenMainMenu.UnloadAndExitToMenu(); Dispose(); ulong admin = msg.Admin; if (admin != 0) { var messageBox = MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.MultiplayerErrorBannedByAdminsWithDialog), buttonType: MyMessageBoxButtonsType.YES_NO); messageBox.ResultCallback = delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { MySteam.API.OpenOverlayUser(admin); } ; }; MyGuiSandbox.AddScreen(messageBox); } else { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.MultiplayerErrorBannedByAdmins))); } } else { MyStringId resultText = MyCommonTexts.MultiplayerErrorConnectionFailed; switch (msg.JoinResult) { case JoinResult.AlreadyJoined: resultText = MyCommonTexts.MultiplayerErrorAlreadyJoined; break; case JoinResult.ServerFull: resultText = MyCommonTexts.MultiplayerErrorServerFull; break; case JoinResult.SteamServersOffline: resultText = MyCommonTexts.MultiplayerErrorSteamServersOffline; break; case JoinResult.TicketInvalid: resultText = MyCommonTexts.MultiplayerErrorTicketInvalid; break; case JoinResult.GroupIdInvalid: resultText = MyCommonTexts.MultiplayerErrorGroupIdInvalid; break; case JoinResult.TicketCanceled: resultText = MyCommonTexts.MultiplayerErrorTicketCanceled; break; case JoinResult.TicketAlreadyUsed: resultText = MyCommonTexts.MultiplayerErrorTicketAlreadyUsed; break; case JoinResult.LoggedInElseWhere: resultText = MyCommonTexts.MultiplayerErrorLoggedInElseWhere; break; case JoinResult.NoLicenseOrExpired: resultText = MyCommonTexts.MultiplayerErrorNoLicenseOrExpired; break; case JoinResult.UserNotConnected: resultText = MyCommonTexts.MultiplayerErrorUserNotConnected; break; case JoinResult.VACBanned: resultText = MyCommonTexts.MultiplayerErrorVACBanned; break; case JoinResult.VACCheckTimedOut: resultText = MyCommonTexts.MultiplayerErrorVACCheckTimedOut; break; default: System.Diagnostics.Debug.Fail("Unknown JoinResult"); break; } Dispose(); MyGuiScreenMainMenu.UnloadAndExitToMenu(); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(resultText))); return; } }
void Matchmaking_LobbyChatUpdate(Lobby lobby, ulong changedUser, ulong makingChangeUser, ChatMemberStateChangeEnum stateChange) { //System.Diagnostics.Debug.Assert(MySession.Static != null); if (lobby.LobbyId == Lobby.LobbyId) { if (stateChange == ChatMemberStateChangeEnum.Entered) { MySandboxGame.Log.WriteLineAndConsole("Player entered: " + MySteam.API.Friends.GetPersonaName(changedUser) + " (" + changedUser + ")"); MyTrace.Send(TraceWindow.Multiplayer, "Player entered"); Peer2Peer.AcceptSession(changedUser); // When some clients connect at the same time then some of them can have already added clients // (see function MySyncLayer.RegisterClientEvents which registers all Members in Lobby). if (Sync.Clients == null || !Sync.Clients.HasClient(changedUser)) { RaiseClientJoined(changedUser); // Battles - send all clients, identities, players, factions as first message to client if (Sync.IsServer && (Battle || Scenario) && changedUser != MySteam.UserId) { SendAllMembersDataToClient(changedUser); } } if (MySandboxGame.IsGameReady && changedUser != ServerId) { // Player is able to connect to the battle which already started - player is then kicked and we do not want to show connected message in HUD. bool showMsg = true; if (MyFakes.ENABLE_BATTLE_SYSTEM && MySession.Static != null && MySession.Static.Battle && !BattleCanBeJoined) { showMsg = false; } if (showMsg) { var playerJoined = new MyHudNotification(MySpaceTexts.NotificationClientConnected, 5000, level: MyNotificationLevel.Important); playerJoined.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser)); MyHud.Notifications.Add(playerJoined); } } } else { // Kicked client can be already removed from Clients if (Sync.Clients == null || Sync.Clients.HasClient(changedUser)) { RaiseClientLeft(changedUser, stateChange); } if (changedUser == ServerId) { MyTrace.Send(TraceWindow.Multiplayer, "Host left: " + stateChange.ToString()); RaiseHostLeft(); MyGuiScreenMainMenu.UnloadAndExitToMenu(); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MySpaceTexts.MultiplayerErrorServerHasLeft))); // Set new server //ServerId = Lobby.GetOwner(); //if (ServerId == Sync.MyId) //{ // Lobby.SetLobbyData(HostNameTag, Sync.MyName); //} } else if (MySandboxGame.IsGameReady) { var playerLeft = new MyHudNotification(MySpaceTexts.NotificationClientDisconnected, 5000, level: MyNotificationLevel.Important); playerLeft.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser)); MyHud.Notifications.Add(playerLeft); } } } }
private void OnLeaveClicked(MyGuiControlButton sender) { CloseScreen(); MyGuiScreenMainMenu.UnloadAndExitToMenu(); }