/// <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 = _data.Get <Player>(user.GlobalID); dbPlayer.IsDeleted = true; _data.SubmitDataChange(dbPlayer, DatabaseActionType.Update); _.BootPC(user, "Your character has been deleted."); _admin.DeletePlayerCharacter(user, true); } }
public 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); } }