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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ You can still use old plugins without any changes/recompilation/updates.
- [x] New Features:
- [x] Commands:
- [x] /position /pos (current position of the player).
- [x] /tpwp (improved version of /tp wp).
- [x] Gather a Team with a direct access to the repo edit without admins help. (We still gather a team)
- [ ] RocketModFix Video Installation Guide (could be uploaded on YouTube).

Expand Down
85 changes: 85 additions & 0 deletions Rocket.Unturned/Commands/CommandTpwp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using SDG.Unturned;
using UnityEngine;
using Rocket.Unturned.Player;
using System.Collections.Generic;
using Rocket.API;
using Rocket.Unturned.Chat;

namespace Rocket.Unturned.Commands
{
public class CommandTpwp : IRocketCommand
{
public AllowedCaller AllowedCaller
{
get
{
return AllowedCaller.Player;
}
}

public string Name
{
get { return "tpwp"; }
}

public string Help
{
get { return "Teleports you to waypoint location";}
}

public string Syntax
{
get { return ""; }
}

public List<string> Aliases
{
get { return new List<string>(); }
}

public List<string> Permissions
{
get { return new List<string>() { "rocket.tpwp", "rocket.teleportwp" }; }
}

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.Player.quests.isMarkerPlaced)
{
UnturnedChat.Say(player, U.Translate("command_tpwp_marker_not_set"));
throw new WrongUsageOfCommandException(caller, this);
}

Vector3 position = player.Player.quests.markerPosition;
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));
}

// Copy of Unturned function because its protected
protected static bool raycastFromSkyToPosition(ref Vector3 position)
{
position.y = 1024f;
RaycastHit raycastHit;
if (Physics.Raycast(position, Vector3.down, out raycastHit, 2048f, RayMasks.WAYPOINT))
{
position = raycastHit.point + Vector3.up;
return true;
}
return false;
}
}
}
2 changes: 2 additions & 0 deletions Rocket.Unturned/U.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public class U : MonoBehaviour, IRocketImplementation, IModuleNexus
{ "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}"},
{ "command_tpwp_marker_not_set","Your waypoint is not set"},
{ "command_tpwp_failed_raycast","Failed to find ground"},
{ "command_clear_error","There was an error clearing {0} inventory."},
{ "command_clear_private","Your inventory was cleared!"},
{ "command_clear_other","Your inventory was cleared by {0}!"},
Expand Down