diff --git a/Rocket.Unturned/Commands/CommandHome.cs b/Rocket.Unturned/Commands/CommandHome.cs index 090f7d2..f6fd5a9 100644 --- a/Rocket.Unturned/Commands/CommandHome.cs +++ b/Rocket.Unturned/Commands/CommandHome.cs @@ -4,6 +4,7 @@ using SDG.Unturned; using System.Collections.Generic; using UnityEngine; +using UnityEngine.UIElements; namespace Rocket.Unturned.Commands { @@ -24,7 +25,7 @@ public string Name public string Help { - get { return "Teleports you to your last bed";} + get { return "Teleports you to your last bed"; } } public string Syntax @@ -54,21 +55,26 @@ public void Execute(IRocketPlayer caller, string[] command) } else { - if (player.Stance == EPlayerStance.DRIVING || player.Stance == EPlayerStance.SITTING) - { - UnturnedChat.Say(caller, U.Translate("command_generic_teleport_while_driving_error")); - throw new WrongUsageOfCommandException(caller, this); - } - else - { - pos.y += 0.5f; // Respawn uses this offset. - float yaw = MeasurementTool.byteToAngle(rot); - bool teleportSuccessful = player.Player.teleportToLocation(pos, yaw); - if(!teleportSuccessful) - { - UnturnedChat.Say(caller, U.Translate("command_bed_obstructed")); - } - } + //if (player.Stance == EPlayerStance.DRIVING || player.Stance == EPlayerStance.SITTING) + //{ + // UnturnedChat.Say(caller, U.Translate("command_generic_teleport_while_driving_error")); + // throw new WrongUsageOfCommandException(caller, this); + //} + //else + //{ + pos.y += 0.5f; // Respawn uses this offset. + + float yaw = MeasurementTool.byteToAngle(rot); + + //bool teleportSuccessful = player.Player.teleportToLocation(pos, yaw); + + player.Player.teleportToLocationUnsafe(pos, yaw); + + //if (!teleportSuccessful) + //{ + // UnturnedChat.Say(caller, U.Translate("command_bed_obstructed")); + //} + //} } } diff --git a/Rocket.Unturned/Commands/CommandTp.cs b/Rocket.Unturned/Commands/CommandTp.cs index cdc59ae..6ca97bd 100644 --- a/Rocket.Unturned/Commands/CommandTp.cs +++ b/Rocket.Unturned/Commands/CommandTp.cs @@ -27,7 +27,7 @@ public string Name public string Help { - get { return "Teleports you to another player or location";} + get { return "Teleports you to another player or location"; } } public string Syntax @@ -54,11 +54,11 @@ public void Execute(IRocketPlayer caller, string[] command) throw new WrongUsageOfCommandException(caller, this); } - if (player.Stance == EPlayerStance.DRIVING || player.Stance == EPlayerStance.SITTING) - { - UnturnedChat.Say(player, U.Translate("command_generic_teleport_while_driving_error")); - throw new WrongUsageOfCommandException(caller, this); - } + //if (player.Stance == EPlayerStance.DRIVING || player.Stance == EPlayerStance.SITTING) + //{ + // UnturnedChat.Say(player, U.Translate("command_generic_teleport_while_driving_error")); + // throw new WrongUsageOfCommandException(caller, this); + //} float? x = null; float? y = null; @@ -72,16 +72,18 @@ public void Execute(IRocketPlayer caller, string[] command) } if (x != null && y != null && z != null) { - player.Teleport(new Vector3((float)x, (float)y, (float)z), MeasurementTool.angleToByte(player.Rotation)); + //player.Teleport(new Vector3((float)x, (float)y, (float)z), MeasurementTool.angleToByte(player.Rotation)); + player.Player.teleportToLocationUnsafe(new Vector3((float)x, (float)y, (float)z), MeasurementTool.angleToByte(player.Rotation)); Core.Logging.Logger.Log(U.Translate("command_tp_teleport_console", player.CharacterName, (float)x + "," + (float)y + "," + (float)z)); UnturnedChat.Say(player, U.Translate("command_tp_teleport_private", (float)x + "," + (float)y + "," + (float)z)); } else { UnturnedPlayer otherplayer = UnturnedPlayer.FromName(command[0]); - if (otherplayer != null && otherplayer != player) + if (otherplayer != null /*&& otherplayer != player*/) { - player.Teleport(otherplayer); + //player.Teleport(otherplayer); + player.Player.teleportToLocationUnsafe(otherplayer.Position, player.Rotation); Core.Logging.Logger.Log(U.Translate("command_tp_teleport_console", player.CharacterName, otherplayer.CharacterName)); UnturnedChat.Say(player, U.Translate("command_tp_teleport_private", otherplayer.CharacterName)); } @@ -90,8 +92,9 @@ public void Execute(IRocketPlayer caller, string[] command) LocationDevkitNode item = LocationDevkitNodeSystem.Get().GetAllNodes().Where(n => n.locationName.IndexOf(command[0]) != -1).FirstOrDefault(); if (item != null) { - Vector3 c = item.transform.position + new Vector3(0f, 0.5f, 0f); - player.Teleport(c, MeasurementTool.angleToByte(player.Rotation)); + Vector3 LocationPosition = item.transform.position + new Vector3(0f, 0.5f, 0f); + //player.Teleport(LocationPosition, MeasurementTool.angleToByte(player.Rotation)); + player.Player.teleportToLocationUnsafe(LocationPosition, player.Rotation); Core.Logging.Logger.Log(U.Translate("command_tp_teleport_console", player.CharacterName, item.locationName)); UnturnedChat.Say(player, U.Translate("command_tp_teleport_private", item.locationName)); } diff --git a/Rocket.Unturned/Commands/CommandTphere.cs b/Rocket.Unturned/Commands/CommandTphere.cs index 60ae78d..0a6061a 100644 --- a/Rocket.Unturned/Commands/CommandTphere.cs +++ b/Rocket.Unturned/Commands/CommandTphere.cs @@ -23,7 +23,7 @@ public string Name public string Help { - get { return "Teleports another player to you";} + get { return "Teleports another player to you"; } } public string Syntax @@ -51,14 +51,18 @@ public void Execute(IRocketPlayer caller, string[] command) throw new WrongUsageOfCommandException(caller, this); } UnturnedPlayer otherPlayer = UnturnedPlayer.FromName(command[0]); - if (otherPlayer!=null && otherPlayer != caller) + if (otherPlayer != null /* && otherPlayer != caller*/) { - if(otherPlayer.IsInVehicle) - { - UnturnedChat.Say(caller, U.Translate("command_tphere_vehicle")); - return; - } - otherPlayer.Teleport(player); + //if(otherPlayer.IsInVehicle) + //{ + // UnturnedChat.Say(caller, U.Translate("command_tphere_vehicle")); + // return; + //} + + //otherPlayer.Teleport(player); + + otherPlayer.Player.teleportToLocationUnsafe(player.Position, player.Rotation); + Logger.Log(U.Translate("command_tphere_teleport_console", otherPlayer.CharacterName, player.CharacterName)); UnturnedChat.Say(caller, U.Translate("command_tphere_teleport_from_private", otherPlayer.CharacterName)); UnturnedChat.Say(otherPlayer, U.Translate("command_tphere_teleport_to_private", player.CharacterName)); diff --git a/Rocket.Unturned/Commands/CommandTpwp.cs b/Rocket.Unturned/Commands/CommandTpwp.cs index a788ff5..9e44663 100644 --- a/Rocket.Unturned/Commands/CommandTpwp.cs +++ b/Rocket.Unturned/Commands/CommandTpwp.cs @@ -24,7 +24,7 @@ public string Name public string Help { - get { return "Teleports you to waypoint location";} + get { return "Teleports you to waypoint location"; } } public string Syntax @@ -45,11 +45,12 @@ public List Permissions public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; - if (player.Stance == EPlayerStance.DRIVING || player.Stance == EPlayerStance.SITTING) - { - UnturnedChat.Say(player, U.Translate("command_generic_teleport_while_driving_error")); - throw new WrongUsageOfCommandException(caller, this); - } + + //if (player.Stance == EPlayerStance.DRIVING || player.Stance == EPlayerStance.SITTING) + //{ + // UnturnedChat.Say(player, U.Translate("command_generic_teleport_while_driving_error")); + // throw new WrongUsageOfCommandException(caller, this); + //} if (!player.Player.quests.isMarkerPlaced) { @@ -58,19 +59,19 @@ public void Execute(IRocketPlayer caller, string[] command) } Vector3 position = player.Player.quests.markerPosition; - if (!raycastFromSkyToPosition(ref position)) + if (!RaycastFromSkyToPosition(ref position)) { UnturnedChat.Say(player, U.Translate("command_tpwp_failed_raycast")); throw new WrongUsageOfCommandException(caller, this); } - - player.Teleport(new Vector3(position.x, position.y, position.z), player.Rotation); - Core.Logging.Logger.Log(U.Translate("command_tp_teleport_console", player.CharacterName, position.x + "," + position.y + "," + position.z)); - UnturnedChat.Say(player, U.Translate("command_tp_teleport_private", position.x + "," + position.y + "," + position.z)); + //player.Teleport(new Vector3(position.x, position.y, position.z), player.Rotation); + player.Player.teleportToLocationUnsafe(new Vector3(position.x, position.y, position.z), player.Rotation); + Core.Logging.Logger.Log(U.Translate("command_tp_teleport_console", player.CharacterName, position.x + ", " + position.y + ", " + position.z)); + UnturnedChat.Say(player, U.Translate("command_tp_teleport_private", position.x + ", " + position.y + ", " + position.z)); } // Copy of Unturned function because its protected - protected static bool raycastFromSkyToPosition(ref Vector3 position) + protected static bool RaycastFromSkyToPosition(ref Vector3 position) { position.y = 1024f; RaycastHit raycastHit; diff --git a/Rocket.Unturned/U.cs b/Rocket.Unturned/U.cs index 1492ce6..fd78386 100644 --- a/Rocket.Unturned/U.cs +++ b/Rocket.Unturned/U.cs @@ -35,7 +35,7 @@ public class U : MonoBehaviour, IRocketImplementation, IModuleNexus { "command_generic_failed_find_player","Failed to find player"}, { "command_generic_invalid_parameter","Invalid parameter"}, { "command_generic_target_player_not_found","Target player not found"}, - { "command_generic_teleport_while_driving_error","You cannot teleport while driving or riding in a vehicle."}, + //{ "command_generic_teleport_while_driving_error","You cannot teleport while driving or riding in a vehicle."}, { "command_god_enable_console","{0} enabled Godmode"}, { "command_god_enable_private","You can feel the strength now..."}, { "command_god_disable_console","{0} disabled Godmode"}, @@ -49,7 +49,7 @@ public class U : MonoBehaviour, IRocketImplementation, IModuleNexus { "command_duty_disable_console","{0} is no longer in duty"}, { "command_duty_disable_private","You are no longer in duty..."}, { "command_bed_no_bed_found_private","You do not have a bed to teleport to."}, - { "command_bed_obstructed","Your bed is obstructed."}, + //{ "command_bed_obstructed","Your bed is obstructed."}, { "command_i_too_much","You have tried to spawn too many items! The limit is {0}." }, { "command_i_blacklisted","This item is restricted!" }, { "command_i_giving_console","Giving {0} item {1}:{2}"}, @@ -70,7 +70,7 @@ public class U : MonoBehaviour, IRocketImplementation, IModuleNexus { "command_tp_teleport_console","{0} teleported to {1}"}, { "command_tp_teleport_private","Teleported to {0}"}, { "command_tp_failed_find_destination","Failed to find destination"}, - { "command_tphere_vehicle", "The player you are trying to teleport is in a vehicle"}, + //{ "command_tphere_vehicle", "The player you are trying to teleport is in a vehicle"}, { "command_tphere_teleport_console","{0} was teleported to {1}"}, { "command_tphere_teleport_from_private","Teleported {0} to you"}, { "command_tphere_teleport_to_private","You were teleported to {0}"},