Exemple #1
0
        private void CmdAuthConsole(ConsoleSystem.Arg arg)
        {
            BasePlayer player;

            if (!ParsePlayer(arg, out player))
            {
                return;
            }

            if (IsSteamPlayer(player))
            {
                return;
            }

            if (!_dataAuthorizes.ContainsKey(player.userID))
            {
                PlayerInit(player);
            }

            if (!arg.HasArgs() || arg.FullString.Length == 0)
            {
                arg.ReplyWithObject(GetMessageLanguage("Registration.EmptyPassword"));
                return;
            }

            var password      = arg.FullString;
            var dataAuthorize = _dataAuthorizes[player.userID];

            if (dataAuthorize.IsAuthed)
            {
                return;
            }

            if (dataAuthorize.Player == null)
            {
                dataAuthorize.Player = player;
            }

            if (string.IsNullOrEmpty(dataAuthorize.Password))
            {
                arg.ReplyWithObject(GetMessageLanguage("Registration.Successful").Replace("{0}", password));
                dataAuthorize.Password = password;
            }
            else if (password == dataAuthorize.Password)
            {
                arg.ReplyWithObject(GetMessageLanguage("Authorized.Successful"));
                player.SetPlayerFlag(BasePlayer.PlayerFlags.ChatMute, false);
            }

            if (password != dataAuthorize.Password)
            {
                arg.ReplyWithObject(GetMessageLanguage("Authorized.BadPassword"));
                return;
            }

            dataAuthorize.IsAuthed = true;
            dataAuthorize.AuthPlayer();
        }