protected override void Load() { Instance = this; warpsData = new WarpDataManager(); // Populate Wait Groups, if they're empty. Instance.Configuration.Instance.LoadDefaults(); foreach (WarpWaitGroups group in Instance.Configuration.Instance.WaitGroups) { if (!WaitGroups.ContainsKey(group.GroupName)) { if (group.WaitTime >= 0) { WaitGroups.Add(group.GroupName, group.WaitTime); } else { Logger.LogWarning("Error: Negative wait time value in group: " + group.GroupName); } } else { Logger.LogWarning("Error: Duplicate group name in wait groups."); } } Instance.Configuration.Save(); }
public void Execute(IRocketPlayer caller, string[] command) { if (command.Length == 0 || command.Length > 1) { UnturnedChat.Say(caller, Warps.Instance.Translate("delwarp_help")); return; } Warp warpData = Warps.warpsData.GetWarp(command[0]); if (warpData == null) { UnturnedChat.Say(caller, Warps.Instance.Translate("delwarp_not_found")); return; } else { if (Warps.CheckUconomy()) { if (Warps.Instance.Configuration.Instance.DelWarpChargeEnable && Warps.Instance.Configuration.Instance.DelWarpCost > 0.00m) { if (!Warps.TryCharge(caller, Warps.Instance.Configuration.Instance.DelWarpCost)) { return; } } } Warps.warpsData.RemoveWarp(Warps.MapName + "." + command[0]); UnturnedChat.Say(caller, Warps.Instance.Translate("delwarp_removed")); return; } }
public void Execute(IRocketPlayer caller, string[] command) { if (command.Length == 0 || command.Length > 1) { UnturnedChat.Say(caller, Warps.Instance.Translate("setwarp_help")); return; } string warpName = command[0].Sanitze().Trim(); if (warpName == string.Empty) { UnturnedChat.Say(caller, Warps.Instance.Translate("setwarp_not_set")); return; } Warp warpData = new Warp(); UnturnedPlayer unturnedCaller = (UnturnedPlayer)caller; warpData.Name = warpName; warpData.SetterCharName = unturnedCaller.CharacterName.Sanitze(); warpData.SetterSteamName = unturnedCaller.SteamName.Sanitze(); warpData.SetterCSteamID = unturnedCaller.CSteamID; warpData.World = Warps.MapName; warpData.Rotation = unturnedCaller.Rotation; warpData.Location = unturnedCaller.Position; if (Warps.CheckUconomy()) { if (Warps.Instance.Configuration.Instance.SetWarpChargeEnable && Warps.Instance.Configuration.Instance.SetWarpCost > 0.00m) { if (!Warps.TryCharge(caller, Warps.Instance.Configuration.Instance.SetWarpCost)) { return; } } } if (Warps.warpsData.SetWarp(warpData)) { UnturnedChat.Say(caller, Warps.Instance.Translate("setwarp_set")); return; } else { UnturnedChat.Say(caller, Warps.Instance.Translate("setwarp_not_set")); return; } }
public void FixedUpdate() { if (doWarp) { // Fail if the player moved with movement restriction enabled. if (Warps.Instance.Configuration.Instance.EnableMovementRestriction && lastLocation != Player.Position) { UnturnedChat.Say(Player, Warps.Instance.Translate("warp_fail_player_moved", wData.Name)); doWarp = false; return; } // Fail if the player died. if (Player.Health == 0 || Player.Dead) { UnturnedChat.Say(Player, Warps.Instance.Translate("warp_fail_player_died", wData.Name)); doWarp = false; return; } // Handle the warp after the wait time has gone by. if ((DateTime.Now - startTime).Seconds >= timetoWait) { if (Warps.CheckUconomy()) { if (Warps.Instance.Configuration.Instance.WarpCargeEnable && Warps.Instance.Configuration.Instance.WarpCost > 0.00m) { if (!Warps.TryCharge(Player, Warps.Instance.Configuration.Instance.WarpCost)) { return; } } } Player.Teleport(wData.Location, wData.Rotation); UnturnedChat.Say(Player, Warps.Instance.Translate("player_warp", wData.Name)); doWarp = false; } } }
public void Execute(IRocketPlayer caller, string[] command) { if (command.Length == 0 || command.Length > 2) { UnturnedChat.Say(caller, Warps.Instance.Translate("warp_help")); return; } Warp warp = Warps.warpsData.GetWarp(command[0]); UnturnedPlayer unturnedTarget = command.GetUnturnedPlayerParameter(1); if (warp != null) { if (unturnedTarget != null && (caller.HasPermission("warp.other") || SteamAdminlist.checkAdmin(caller is ConsolePlayer ? CSteamID.Nil : (CSteamID)ulong.Parse(caller.Id)))) { if (unturnedTarget.Stance == EPlayerStance.DRIVING || unturnedTarget.Stance == EPlayerStance.SITTING) { UnturnedChat.Say(caller, Warps.Instance.Translate("warp_cant_warp_in_car")); return; } if (Warps.CheckUconomy()) { if (Warps.Instance.Configuration.Instance.WarpOtherChargeEnable && Warps.Instance.Configuration.Instance.WarpOtherCost > 0.00m) { if (!Warps.TryCharge(caller, Warps.Instance.Configuration.Instance.WarpOtherCost)) { return; } } } unturnedTarget.Teleport(warp.Location, warp.Rotation); UnturnedChat.Say(caller, Warps.Instance.Translate("admin_warp", unturnedTarget.CharacterName, warp.Name)); Logger.Log(Warps.Instance.Translate("admin_warp_log", caller.DisplayName, caller.Id, unturnedTarget.CharacterName, warp.Name)); UnturnedChat.Say(unturnedTarget, Warps.Instance.Translate("player_warp", warp.Name)); return; } else if (unturnedTarget != null) { UnturnedChat.Say(caller, Warps.Instance.Translate("warp_other_not_allowed")); return; } if (unturnedTarget == null && command.Length == 2) { UnturnedChat.Say(caller, Warps.Instance.Translate("warp_cant_find_player")); return; } else if (caller is ConsolePlayer) { UnturnedChat.Say(caller, Warps.Instance.Translate("warp_console_no_player")); return; } else { UnturnedPlayer unturnedCaller = (UnturnedPlayer)caller; if (unturnedCaller.Stance == EPlayerStance.DRIVING || unturnedCaller.Stance == EPlayerStance.SITTING) { UnturnedChat.Say(caller, Warps.Instance.Translate("warp_cant_warp_in_car")); return; } if (Warps.Instance.Configuration.Instance.EnableWaitGroups) { if (Warps.CheckUconomy()) { if (Warps.Instance.Configuration.Instance.WarpCargeEnable && Warps.Instance.Configuration.Instance.WarpCost > 0.00m) { if (!Warps.TryCharge(caller, Warps.Instance.Configuration.Instance.WarpCost, true)) { return; } } } WarpsPlayerComponent wpc = unturnedCaller.GetComponent <WarpsPlayerComponent>(); wpc.DoWarp(warp); return; } else { if (Warps.CheckUconomy()) { if (Warps.Instance.Configuration.Instance.WarpCargeEnable && Warps.Instance.Configuration.Instance.WarpCost > 0.00m) { if (!Warps.TryCharge(caller, Warps.Instance.Configuration.Instance.WarpCost)) { return; } } } unturnedCaller.Teleport(warp.Location, warp.Rotation); UnturnedChat.Say(caller, Warps.Instance.Translate("player_warp", warp.Name)); return; } } } else { UnturnedChat.Say(caller, Warps.Instance.Translate("warp_cant_find_warp", command[0])); return; } }