private void OnJoinResult(MyPacket packet) { JoinResultMsg msg = base.ReplicationLayer.OnJoinResult(packet); this.OnUserJoined(ref msg); packet.Return(); }
public void SendJoinResult(ulong sendTo, JoinResult joinResult, ulong adminID = 0) { JoinResultMsg msg = new JoinResultMsg(); msg.JoinResult = joinResult; msg.Admin = adminID; SendControlMessage(sendTo, ref msg); }
public void SendJoinResult(ulong sendTo, JoinResult joinResult, ulong adminID = 0) { JoinResultMsg msg = new JoinResultMsg(); msg.JoinResult = joinResult; msg.Admin = adminID; ReplicationLayer.SendJoinResult(ref msg, sendTo); }
private void SendJoinResult(ulong sendTo, JoinResult joinResult, ulong adminID = 0UL) { JoinResultMsg msg = new JoinResultMsg { JoinResult = joinResult, ServerExperimental = MySession.Static.IsSettingsExperimental(), Admin = adminID }; base.ReplicationLayer.SendJoinResult(ref msg, sendTo); }
private static void DenyPlayer( ulong remoteUserId ) { Essentials.Log.Info( "deny player " + remoteUserId.ToString( ) ); MyAPIGateway.Players.GetPlayers( connectedPlayers ); int publicPlayers = connectedPlayers.Count - reservedPlayers.Count; int publicSlots = Server.Instance.Config.MaxPlayers - PluginSettings.Instance.ReservedSlotsCount; if ( publicPlayers < publicSlots ) return; if ( waitingPlayers.Contains( remoteUserId ) ) return; Essentials.Log.Info( "Removing user " + remoteUserId.ToString( ) ); JoinResultMsg msg = new JoinResultMsg( ); msg.JoinResult = JoinResult.ServerFull; msg.Admin = 0; ServerNetworkManager.Instance.SendStruct( remoteUserId, msg, msg.GetType( ) ); }
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 OnJoinResult(MyPacket packet) { JoinResultMsg msg = ReplicationLayer.OnJoinResult(packet); OnUserJoined(ref msg); }
void OnUserJoined(ref JoinResultMsg msg, ulong sender) { 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(MySpaceTexts.MessageBoxCaptionError), messageText: new StringBuilder(string.Format( MyTexts.GetString(MySpaceTexts.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(MySpaceTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MySpaceTexts.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(MySpaceTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MySpaceTexts.MultiplayerErrorBannedByAdmins))); } } else { MyStringId resultText = MySpaceTexts.MultiplayerErrorConnectionFailed; switch (msg.JoinResult) { case JoinResult.AlreadyJoined: resultText = MySpaceTexts.MultiplayerErrorAlreadyJoined; break; case JoinResult.ServerFull: resultText = MySpaceTexts.MultiplayerErrorServerFull; break; case JoinResult.SteamServersOffline: resultText = MySpaceTexts.MultiplayerErrorSteamServersOffline; break; case JoinResult.TicketInvalid: resultText = MySpaceTexts.MultiplayerErrorTicketInvalid; break; case JoinResult.GroupIdInvalid: resultText = MySpaceTexts.MultiplayerErrorGroupIdInvalid; break; case JoinResult.TicketCanceled: resultText = MySpaceTexts.MultiplayerErrorTicketCanceled; break; case JoinResult.TicketAlreadyUsed: resultText = MySpaceTexts.MultiplayerErrorTicketAlreadyUsed; break; case JoinResult.LoggedInElseWhere: resultText = MySpaceTexts.MultiplayerErrorLoggedInElseWhere; break; case JoinResult.NoLicenseOrExpired: resultText = MySpaceTexts.MultiplayerErrorNoLicenseOrExpired; break; case JoinResult.UserNotConnected: resultText = MySpaceTexts.MultiplayerErrorUserNotConnected; break; case JoinResult.VACBanned: resultText = MySpaceTexts.MultiplayerErrorVACBanned; break; case JoinResult.VACCheckTimedOut: resultText = MySpaceTexts.MultiplayerErrorVACCheckTimedOut; break; default: System.Diagnostics.Debug.Fail("Unknown JoinResult"); break; } Dispose(); MyGuiScreenMainMenu.UnloadAndExitToMenu(); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError), messageText: MyTexts.Get(resultText))); return; } }
void OnJoinResult(ref JoinResultMsg msg, ulong sender) { System.Diagnostics.Debug.Fail("Server cannot join anywhere!"); }
private static void DenyPlayer( ulong remoteUserId ) { //get the list of current players just so we can count them (this is a stupid solution) MyAPIGateway.Players.GetPlayers( connectedPlayers ); int publicPlayers = connectedPlayers.Count - Math.Min( reservedPlayers.Count, PluginSettings.Instance.ReservedSlotsCount ); int publicSlots = Server.Instance.Config.MaxPlayers - PluginSettings.Instance.ReservedSlotsCount; if ( publicPlayers < publicSlots ) return; //don't do anything while we're waiting for group authorization if ( waitingPlayers.Contains( remoteUserId ) ) return; //kick the player with the "Server is full" message //too bad we can't send a custom message, but they're hardcoded into the client Essentials.Log.Info( "Player denied: " + remoteUserId.ToString( ) ); JoinResultMsg msg = new JoinResultMsg( ); msg.JoinResult = JoinResult.ServerFull; msg.Admin = 0; ServerNetworkManager.Instance.SendStruct( remoteUserId, msg, msg.GetType( ) ); }
private void OnUserJoined(ref JoinResultMsg msg) { if (msg.JoinResult == JoinResult.OK) { base.IsServerExperimental = msg.ServerExperimental; if (this.OnJoin != null) { this.OnJoin(); this.OnJoin = null; } } else { StringBuilder builder; MyStringId? nullable; Vector2? nullable2; if (msg.JoinResult == JoinResult.NotInGroup) { MySessionLoader.UnloadAndExitToMenu(); this.Dispose(); ulong groupId = this.Server.GetGameTagByPrefixUlong("groupId"); string clanName = MyGameService.GetClanName(groupId); builder = MyTexts.Get(MyCommonTexts.MessageBoxCaptionError); nullable = null; nullable = null; nullable = null; nullable = null; nullable2 = null; MyGuiScreenMessageBox screen = MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.YES_NO, new StringBuilder(string.Format(MyTexts.GetString(MyCommonTexts.MultiplayerErrorNotInGroup), clanName)), builder, nullable, nullable, nullable, nullable, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, nullable2); screen.ResultCallback = delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { MyGameService.OpenOverlayUser(groupId); } }; MyGuiSandbox.AddScreen(screen); } else if (msg.JoinResult == JoinResult.BannedByAdmins) { MySessionLoader.UnloadAndExitToMenu(); this.Dispose(); ulong admin = msg.Admin; if (admin == 0) { builder = MyTexts.Get(MyCommonTexts.MessageBoxCaptionError); nullable = null; nullable = null; nullable = null; nullable = null; nullable2 = null; MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, MyTexts.Get(MyCommonTexts.MultiplayerErrorBannedByAdmins), builder, nullable, nullable, nullable, nullable, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, nullable2)); } else { builder = MyTexts.Get(MyCommonTexts.MessageBoxCaptionError); nullable = null; nullable = null; nullable = null; nullable = null; nullable2 = null; MyGuiScreenMessageBox screen = MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.YES_NO, MyTexts.Get(MyCommonTexts.MultiplayerErrorBannedByAdminsWithDialog), builder, nullable, nullable, nullable, nullable, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, nullable2); screen.ResultCallback = delegate(MyGuiScreenMessageBox.ResultEnum result) { if (result == MyGuiScreenMessageBox.ResultEnum.YES) { MyGameService.OpenOverlayUser(admin); } }; MyGuiSandbox.AddScreen(screen); } } else { StringBuilder messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorConnectionFailed); switch (msg.JoinResult) { case JoinResult.AlreadyJoined: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorAlreadyJoined); break; case JoinResult.TicketInvalid: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorTicketInvalid); break; case JoinResult.SteamServersOffline: messageText = new StringBuilder().AppendFormat(MyTexts.GetString(MyCommonTexts.MultiplayerErrorSteamServersOffline), MySession.Platform); break; case JoinResult.GroupIdInvalid: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorGroupIdInvalid); break; case JoinResult.ServerFull: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorServerFull); break; case JoinResult.KickedRecently: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorKickedByAdmins); break; case JoinResult.TicketCanceled: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorTicketCanceled); break; case JoinResult.TicketAlreadyUsed: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorTicketAlreadyUsed); break; case JoinResult.LoggedInElseWhere: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorLoggedInElseWhere); break; case JoinResult.NoLicenseOrExpired: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorNoLicenseOrExpired); break; case JoinResult.UserNotConnected: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorUserNotConnected); break; case JoinResult.VACBanned: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorVACBanned); break; case JoinResult.VACCheckTimedOut: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorVACCheckTimedOut); break; case JoinResult.PasswordRequired: MyGuiSandbox.AddScreen(new MyGuiScreenServerPassword(password => this.SendPasswordHash(password))); return; case JoinResult.WrongPassword: messageText = MyTexts.Get(MyCommonTexts.MultiplayerErrorWrongPassword); break; case JoinResult.ExperimentalMode: messageText = !MySandboxGame.Config.ExperimentalMode ? MyTexts.Get(MyCommonTexts.MultiplayerErrorExperimental) : MyTexts.Get(MyCommonTexts.MultiplayerErrorNotExperimental); break; default: break; } this.Dispose(); MySessionLoader.UnloadAndExitToMenu(); nullable = null; nullable = null; nullable = null; nullable = null; nullable2 = null; MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageText, MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), nullable, nullable, nullable, nullable, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, nullable2)); } } }