Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions Rocket.Unturned/Commands/CommandHome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using SDG.Unturned;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;

namespace Rocket.Unturned.Commands
{
Expand All @@ -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
Expand Down Expand Up @@ -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"));
//}
//}
}

}
Expand Down
25 changes: 14 additions & 11 deletions Rocket.Unturned/Commands/CommandTp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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));
}
Expand All @@ -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));
}
Expand Down
20 changes: 12 additions & 8 deletions Rocket.Unturned/Commands/CommandTphere.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down
25 changes: 13 additions & 12 deletions Rocket.Unturned/Commands/CommandTpwp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,11 +45,12 @@ public List<string> 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)
{
Expand All @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename RaycastFromSkyToPosition to raycastFromSkyToPosition as before, just in case to keep backward compatibility

{
position.y = 1024f;
RaycastHit raycastHit;
Expand Down
6 changes: 3 additions & 3 deletions Rocket.Unturned/U.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand All @@ -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}"},
Expand All @@ -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}"},
Expand Down