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( ));
        }
示例#2
0
        public JoinResultMsg OnJoinResult(MyPacket packet)
        {
            m_receiveStream.ResetRead(packet);
            JoinResultMsg msg = VRage.Serialization.MySerializer.CreateAndRead <JoinResultMsg>(m_receiveStream);

            return(msg);
        }
        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( ));
        }
        private static void OnUserJoined(ref JoinResultMsg msg)
        {
            if (msg.JoinResult == JoinResult.OK)
            {
                //SeamlessClient.TryShow("User Joined! Result: " + msg.JoinResult.ToString());

                //Invoke the switch event
                OnJoinEvent?.Invoke(null, msg);
            }
        }
示例#5
0
 private static void OnUserJoined(ref JoinResultMsg msg)
 {
     if (SeamlessClient.IsSwitching && msg.JoinResult == JoinResult.OK)
     {
         SeamlessClient.TryShow("User Joined! Result: " + msg.JoinResult.ToString());
         ForceClientConnection();
     }
     else if (SeamlessClient.IsSwitching && msg.JoinResult != JoinResult.OK)
     {
         SeamlessClient.TryShow("Failed to join server! Reason: " + msg.JoinResult.ToString());
         MySession.Static.Unload();
     }
 }
        public void SendJoinResult(ulong sendTo, JoinResult joinResult, ulong adminID = 0)
        {
            JoinResultMsg msg = new JoinResultMsg();
            msg.JoinResult = joinResult;
            msg.Admin = adminID;

            SendControlMessage(sendTo, ref msg);
        }
        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)
            {
                MySessionLoader.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)
            {
                MySessionLoader.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();
                MySessionLoader.UnloadAndExitToMenu();
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                    messageText: MyTexts.Get(resultText)));
                return;
            }
        }
        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);
        }