Ejemplo n.º 1
0
        /// <summary>
        /// Deletes a player's character. Player must submit the command twice within 30 seconds.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="target"></param>
        /// <param name="targetLocation"></param>
        /// <param name="args"></param>
        public void DoAction(NWPlayer user, NWObject target, NWLocation targetLocation, params string[] args)
        {
            string lastSubmission    = user.GetLocalString("DELETE_CHARACTER_LAST_SUBMISSION");
            bool   isFirstSubmission = true;

            // Check for the last submission, if any.
            if (!string.IsNullOrWhiteSpace(lastSubmission))
            {
                // Found one, parse it.
                DateTime dateTime = DateTime.Parse(lastSubmission);
                if (DateTime.UtcNow <= dateTime.AddSeconds(30))
                {
                    // Player submitted a second request within 30 seconds of the last one.
                    // This is a confirmation they want to delete.
                    isFirstSubmission = false;
                }
            }

            // Player hasn't submitted or time has elapsed
            if (isFirstSubmission)
            {
                user.SetLocalString("DELETE_CHARACTER_LAST_SUBMISSION", DateTime.UtcNow.ToString(CultureInfo.InvariantCulture));
                user.FloatingText("Please confirm your deletion by entering another \"/delete <CD Key>\" command within 30 seconds.");
            }
            else
            {
                Player dbPlayer = DataService.Player.GetByID(user.GlobalID);
                dbPlayer.IsDeleted = true;
                DataService.SubmitDataChange(dbPlayer, DatabaseActionType.Update);

                NWNXAdmin.DeletePlayerCharacter(user, true, "Your character has been deleted.");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deletes a player's character. Player must submit the command twice within 30 seconds.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="target"></param>
        /// <param name="targetLocation"></param>
        /// <param name="args"></param>
        public void DoAction(NWGameObject user, NWGameObject target, Location targetLocation, params string[] args)
        {
            string lastSubmission    = GetLocalString(user, "DELETE_CHARACTER_LAST_SUBMISSION");
            bool   isFirstSubmission = true;

            // Check for the last submission, if any.
            if (!string.IsNullOrWhiteSpace(lastSubmission))
            {
                // Found one, parse it.
                DateTime dateTime = DateTime.Parse(lastSubmission);
                if (DateTime.UtcNow <= dateTime.AddSeconds(30))
                {
                    // Player submitted a second request within 30 seconds of the last one.
                    // This is a confirmation they want to delete.
                    isFirstSubmission = false;
                }
            }

            // Player hasn't submitted or time has elapsed
            if (isFirstSubmission)
            {
                SetLocalString(user, "DELETE_CHARACTER_LAST_SUBMISSION", DateTime.UtcNow.ToString(CultureInfo.InvariantCulture));
                FloatingTextStringOnCreature(user, "Please confirm your deletion by entering another \"/delete <CD Key>\" command within 30 seconds.");
            }
            else
            {
                var playerID = GetGlobalID(user);
                var entity   = PlayerRepo.Get(playerID);
                entity.IsDeleted = true;
                PlayerRepo.Set(entity);

                BootPC(user, "Your character has been deleted.");
                NWNXAdmin.DeletePlayerCharacter(user, true);
            }
        }
Ejemplo n.º 3
0
        public static void OnModuleEnter()
        {
            NWPlayer player = _.GetEnteringObject();

            if (!player.IsPlayer)
            {
                return;
            }

            string error = ValidateBackground(player);

            if (string.IsNullOrWhiteSpace(error))
            {
                error = ValidateName(player);
            }

            if (!string.IsNullOrWhiteSpace(error))
            {
                _.BootPC(player, error);
                NWNXAdmin.DeletePlayerCharacter(player, true);
            }
        }