/// <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 Run(object[] args) { if (_isDisabled) { return; } var now = DateTime.UtcNow; if (now >= _restartTime) { _.ExportAllCharacters(); foreach (var player in NWModule.Get().Players) { _.BootPC(player, "Server is automatically rebooting. This is a temporary solution until we can fix performance problems. Thank you for your patience and understanding."); } _nwnxAdmin.ShutdownServer(); } else if (now >= _nextNotification) { var delta = _restartTime - now; string rebootString = _time.GetTimeLongIntervals(delta.Days, delta.Hours, delta.Minutes, delta.Seconds, false); string message = "Server will automatically reboot in " + rebootString; foreach (var player in NWModule.Get().Players) { player.FloatingText(message); } Console.WriteLine(message); // We're in the last hour before rebooting. Schedule the next notification 45 minutes from now. if (delta.TotalHours <= 1 && delta.TotalMinutes >= 45) { _nextNotification = DateTime.UtcNow.AddMinutes(45); } // Notify every minute when it comes close to the reboot time. else if (delta.TotalMinutes <= 15) { _nextNotification = DateTime.UtcNow.AddMinutes(1); } // Otherwise notify on the standard timing. else { _nextNotification = DateTime.UtcNow.AddMinutes(NotificationIntervalMinutes); } } }
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); } }
public void ApplyDefaultAppearance(NWPlayer player) { CustomRaceType race = (CustomRaceType)player.RacialType; int maleHead; int femaleHead; int skinColor; int hairColor; int gender = player.Gender; int appearance = APPEARANCE_TYPE_HUMAN; int maleNeck = 1; int maleTorso = 1; int malePelvis = 1; int maleRightBicep = 1; int maleRightForearm = 1; int maleRightHand = 1; int maleRightThigh = 1; int maleRightShin = 1; int maleRightFoot = 1; int maleLeftBicep = 1; int maleLeftForearm = 1; int maleLeftHand = 1; int maleLeftThigh = 1; int maleLeftShin = 1; int maleLeftFoot = 1; int femaleNeck = 1; int femaleTorso = 1; int femalePelvis = 1; int femaleRightBicep = 1; int femaleRightForearm = 1; int femaleRightHand = 1; int femaleRightThigh = 1; int femaleRightShin = 1; int femaleRightFoot = 1; int femaleLeftBicep = 1; int femaleLeftForearm = 1; int femaleLeftHand = 1; int femaleLeftThigh = 1; int femaleLeftShin = 1; int femaleLeftFoot = 1; switch (race) { case CustomRaceType.Human: skinColor = 2; hairColor = 0; maleHead = 1; femaleHead = 1; break; case CustomRaceType.Bothan: skinColor = 6; hairColor = 1; appearance = APPEARANCE_TYPE_ELF; maleHead = 40; femaleHead = 109; break; case CustomRaceType.Chiss: skinColor = 137; hairColor = 134; maleHead = 33; femaleHead = 191; break; case CustomRaceType.Zabrak: skinColor = 88; hairColor = 0; maleHead = 103; femaleHead = 120; break; case CustomRaceType.Twilek: skinColor = 52; hairColor = 0; maleHead = 115; femaleHead = 145; break; case CustomRaceType.Cyborg: skinColor = 2; hairColor = 0; maleHead = 168; femaleHead = 41; break; case CustomRaceType.Cathar: skinColor = 54; hairColor = 0; appearance = APPEARANCE_TYPE_HALF_ORC; maleHead = 27; femaleHead = 18; break; case CustomRaceType.Trandoshan: skinColor = 39; hairColor = 4; maleHead = 162; femaleHead = 135; maleNeck = 201; maleTorso = 201; malePelvis = 201; maleRightBicep = 201; maleRightForearm = 201; maleRightHand = 201; maleRightThigh = 201; maleRightShin = 201; maleRightFoot = 201; maleLeftBicep = 201; maleLeftForearm = 201; maleLeftHand = 201; maleLeftThigh = 201; maleLeftShin = 201; maleLeftFoot = 201; femaleNeck = 201; femaleTorso = 201; femalePelvis = 201; femaleRightBicep = 201; femaleRightForearm = 201; femaleRightHand = 201; femaleRightThigh = 201; femaleRightShin = 201; femaleRightFoot = 201; femaleLeftBicep = 201; femaleLeftForearm = 201; femaleLeftHand = 201; femaleLeftThigh = 201; femaleLeftShin = 201; femaleLeftFoot = 201; break; default: { _.BootPC(player, "You have selected an invalid race. This could be due to files in your override folder. Ensure these are removed from the folder and then try creating a new character. If you have any problems, visit our website at http://starwarsnwn.com"); return; } } _.SetCreatureAppearanceType(player, appearance); _.SetColor(player, COLOR_CHANNEL_SKIN, skinColor); _.SetColor(player, COLOR_CHANNEL_HAIR, hairColor); if (gender == GENDER_MALE) { _.SetCreatureBodyPart(CREATURE_PART_HEAD, maleHead, player); _.SetCreatureBodyPart(CREATURE_PART_NECK, maleNeck, player); _.SetCreatureBodyPart(CREATURE_PART_TORSO, maleTorso, player); _.SetCreatureBodyPart(CREATURE_PART_PELVIS, malePelvis, player); _.SetCreatureBodyPart(CREATURE_PART_RIGHT_BICEP, maleRightBicep, player); _.SetCreatureBodyPart(CREATURE_PART_RIGHT_FOREARM, maleRightForearm, player); _.SetCreatureBodyPart(CREATURE_PART_RIGHT_HAND, maleRightHand, player); _.SetCreatureBodyPart(CREATURE_PART_RIGHT_THIGH, maleRightThigh, player); _.SetCreatureBodyPart(CREATURE_PART_RIGHT_SHIN, maleRightShin, player); _.SetCreatureBodyPart(CREATURE_PART_RIGHT_FOOT, maleRightFoot, player); _.SetCreatureBodyPart(CREATURE_PART_LEFT_BICEP, maleLeftBicep, player); _.SetCreatureBodyPart(CREATURE_PART_LEFT_FOREARM, maleLeftForearm, player); _.SetCreatureBodyPart(CREATURE_PART_LEFT_HAND, maleLeftHand, player); _.SetCreatureBodyPart(CREATURE_PART_LEFT_THIGH, maleLeftThigh, player); _.SetCreatureBodyPart(CREATURE_PART_LEFT_SHIN, maleLeftShin, player); _.SetCreatureBodyPart(CREATURE_PART_LEFT_FOOT, maleLeftFoot, player); } else if (gender == GENDER_FEMALE) { _.SetCreatureBodyPart(CREATURE_PART_HEAD, femaleHead, player); _.SetCreatureBodyPart(CREATURE_PART_NECK, femaleNeck, player); _.SetCreatureBodyPart(CREATURE_PART_TORSO, femaleTorso, player); _.SetCreatureBodyPart(CREATURE_PART_PELVIS, femalePelvis, player); _.SetCreatureBodyPart(CREATURE_PART_RIGHT_BICEP, femaleRightBicep, player); _.SetCreatureBodyPart(CREATURE_PART_RIGHT_FOREARM, femaleRightForearm, player); _.SetCreatureBodyPart(CREATURE_PART_RIGHT_HAND, femaleRightHand, player); _.SetCreatureBodyPart(CREATURE_PART_RIGHT_THIGH, femaleRightThigh, player); _.SetCreatureBodyPart(CREATURE_PART_RIGHT_SHIN, femaleRightShin, player); _.SetCreatureBodyPart(CREATURE_PART_RIGHT_FOOT, femaleRightFoot, player); _.SetCreatureBodyPart(CREATURE_PART_LEFT_BICEP, femaleLeftBicep, player); _.SetCreatureBodyPart(CREATURE_PART_LEFT_FOREARM, femaleLeftForearm, player); _.SetCreatureBodyPart(CREATURE_PART_LEFT_HAND, femaleLeftHand, player); _.SetCreatureBodyPart(CREATURE_PART_LEFT_THIGH, femaleLeftThigh, player); _.SetCreatureBodyPart(CREATURE_PART_LEFT_SHIN, femaleLeftShin, player); _.SetCreatureBodyPart(CREATURE_PART_LEFT_FOOT, femaleLeftFoot, player); } }