diff --git a/CommandLocate.cs b/CommandLocate.cs index bb59947..459a178 100644 --- a/CommandLocate.cs +++ b/CommandLocate.cs @@ -41,24 +41,21 @@ public List Permissions public void Execute(IRocketPlayer caller, string[] command) { - if ((caller is ConsolePlayer && command.Length < 1) || command.Length > 1) + // Get playername, if one was set in the command. Don't allow the command to be ran on self from the console. + UnturnedPlayer target = command.GetUnturnedPlayerParameter(0); + if ((caller is ConsolePlayer && command.Length < 1) || command.Length > 1 || (target == null && command.Length == 1 && caller.HasPermission("locate.other"))) { UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("can't_locate_player")); return; } if (command.Length == 1) { + // Only allow the player to locate another player if they have the right permission. if (!caller.HasPermission("locate.other")) { UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("locate_other_not_allowed")); return; } - UnturnedPlayer target = command.GetUnturnedPlayerParameter(0); - if (target == null) - { - UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("can't_locate_player")); - return; - } else { UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("location_on_map_other", target.CharacterName.Truncate(14), Math.Round(target.Position.x, 2), Math.Round(target.Position.y, 2), Math.Round(target.Position.z, 2))); @@ -66,7 +63,7 @@ public void Execute(IRocketPlayer caller, string[] command) } else { - UnturnedPlayer unturnedCaller = UnturnedPlayer.FromName(caller.Id); + UnturnedPlayer unturnedCaller = (UnturnedPlayer)caller; UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("location_on_map", Math.Round(unturnedCaller.Position.x, 2), Math.Round(unturnedCaller.Position.y, 2), Math.Round(unturnedCaller.Position.z, 2))); } } diff --git a/CommandTprel.cs b/CommandTprel.cs index ee101ea..b35c892 100644 --- a/CommandTprel.cs +++ b/CommandTprel.cs @@ -43,12 +43,13 @@ public List Permissions public void Execute(IRocketPlayer caller, string[] command) { - UnturnedPlayer unturnedCaller = UnturnedPlayer.FromName(caller.Id); if (command.Length == 0) { UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("tprel_help", new object[] { })); return; } + + // Only allow the command to be ran with all three parameters. if (command.Length != 3) { UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); @@ -59,14 +60,18 @@ public void Execute(IRocketPlayer caller, string[] command) float? x = command.GetFloatParameter(0); float? y = command.GetFloatParameter(1); float? z = command.GetFloatParameter(2); + UnturnedPlayer unturnedCaller = (UnturnedPlayer)caller; if (x.HasValue && y.HasValue && z.HasValue) { + // Don't allow the player to teleport if they are in a car. if (unturnedCaller.Stance == EPlayerStance.DRIVING || unturnedCaller.Stance == EPlayerStance.SITTING) { UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("tp_fail", new object[] { })); return; } + + // Compute new location from the relative location parameters entered into the command. Vector3 newLocation = new Vector3(unturnedCaller.Position.x + x.Value, unturnedCaller.Position.y + y.Value, unturnedCaller.Position.z + z.Value); unturnedCaller.Teleport(newLocation, unturnedCaller.Rotation); UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("tp_success", new object[] { Math.Round(newLocation.x, 2), Math.Round(newLocation.y, 2), Math.Round(newLocation.z, 2) })); diff --git a/CommandTpto.cs b/CommandTpto.cs index 7557015..49c8685 100644 --- a/CommandTpto.cs +++ b/CommandTpto.cs @@ -42,7 +42,6 @@ public List Permissions public void Execute(IRocketPlayer caller, string[] command) { - UnturnedPlayer unturnedCaller = UnturnedPlayer.FromName(caller.Id); if (command.Length == 0) { UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("tpto_help", new object[] { })); @@ -53,11 +52,16 @@ public void Execute(IRocketPlayer caller, string[] command) UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("invalid_arg", new object[] { })); return; } + + // Don't allow teleport if the player is in a car. + UnturnedPlayer unturnedCaller = (UnturnedPlayer)caller; if (unturnedCaller.Stance == EPlayerStance.DRIVING || unturnedCaller.Stance == EPlayerStance.SITTING) { UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("tp_fail", new object[] { })); return; } + + // Parse through the list of parameters, and compute new location. Vector3 newLocation = unturnedCaller.Position; foreach (string part in command) { diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index a3bbde1..3ea9734 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.0.0")] -[assembly: AssemblyFileVersion("1.3.0.0")] +[assembly: AssemblyVersion("1.3.0.1")] +[assembly: AssemblyFileVersion("1.3.0.1")]