Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9b6395
commit e5a5f74
Showing
4 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using Rocket.API; | ||
using Rocket.Unturned.Player; | ||
using Rocket.Unturned.Chat; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using SDG.Unturned; | ||
using VehicleTeleporter; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
using Logger = Rocket.Core.Logging.Logger; | ||
|
||
namespace KillDisplay | ||
{ | ||
class CommandVehicleTP : IRocketCommand | ||
{ | ||
public AllowedCaller AllowedCaller => AllowedCaller.Player; | ||
|
||
public string Name => "vehicletp"; | ||
|
||
public string Help => "Teleports you to one of your saved vehicles."; | ||
|
||
public string Syntax => "/VehicleTP [Vehicle No.]"; | ||
|
||
public List<string> Aliases => new List<string>() { "vtp" }; | ||
|
||
public List<string> Permissions => new List<string>() { "vehicleteleporter.vehicletp" }; | ||
|
||
|
||
public void Execute(IRocketPlayer rCaller, string[] Command) | ||
{ | ||
UnturnedPlayer uPlayer = (UnturnedPlayer)rCaller; | ||
|
||
if (Command.Length > 1 || Command.Length == 0) { UnturnedChat.Say(uPlayer, Syntax, Color.red); return; } | ||
|
||
UtilPlayer utilPlayer = uPlayer.GetComponent<UtilPlayer>(); | ||
|
||
if (VehicleTeleporter.VehicleTeleporter.Instance.HasVehicles(uPlayer.CSteamID) > 0) | ||
{ | ||
if (Regex.IsMatch(Command[0], @"^\d+$")) | ||
{ | ||
List<InteractableVehicle> playerVehicles = utilPlayer.vehicleList; | ||
|
||
if (int.Parse(Command[0]) <= playerVehicles.Count) | ||
{ | ||
InteractableVehicle desiredVehicle = playerVehicles[int.Parse(Command[0]) - 1]; | ||
|
||
uPlayer.Teleport(new Vector3(desiredVehicle.transform.position.x, desiredVehicle.transform.position.y + 3, desiredVehicle.transform.position.z), uPlayer.Rotation); | ||
UnturnedChat.Say(uPlayer, $"You have teleported to your {desiredVehicle.asset.vehicleName}!", Color.yellow); | ||
playerVehicles.Remove(desiredVehicle); | ||
} | ||
else | ||
{ | ||
UnturnedChat.Say(uPlayer, $"Please select a number between 1 and {playerVehicles.Count}.", Color.red); | ||
return; | ||
} | ||
} | ||
else | ||
{ | ||
UnturnedChat.Say(uPlayer, Syntax, Color.red); | ||
return; | ||
} | ||
} else | ||
{ | ||
UnturnedChat.Say(uPlayer, "You do not have any locked vehicles!", Color.red); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using Rocket.API; | ||
using Rocket.Unturned.Player; | ||
using Rocket.Unturned.Chat; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using SDG.Unturned; | ||
using VehicleTeleporter; | ||
|
||
namespace KillDisplay | ||
{ | ||
public class CommandVehicles : IRocketCommand | ||
{ | ||
public AllowedCaller AllowedCaller => AllowedCaller.Player; | ||
|
||
public string Name => "vehicles"; | ||
|
||
public string Help => "Lists your locked vehicles."; | ||
|
||
public string Syntax => "/vehicles"; | ||
|
||
public List<string> Aliases => new List<string>(); | ||
|
||
public List<string> Permissions => new List<string>() { "vehicleteleporter.vehicles" }; | ||
|
||
|
||
public void Execute(IRocketPlayer rCaller, string[] Command) | ||
{ | ||
UnturnedPlayer uPlayer = (UnturnedPlayer)rCaller; | ||
|
||
if (Command.Length > 0) { UnturnedChat.Say(uPlayer, Syntax, Color.red); return; } | ||
|
||
UtilPlayer utilPlayer = uPlayer.GetComponent<UtilPlayer>(); | ||
|
||
if (VehicleTeleporter.VehicleTeleporter.Instance.HasVehicles(uPlayer.CSteamID) > 0) | ||
{ | ||
int vehicleCount = 0; | ||
foreach (InteractableVehicle Vehicle in utilPlayer.vehicleList) | ||
{ | ||
vehicleCount++; | ||
UnturnedChat.Say(uPlayer, $"[{vehicleCount}/{utilPlayer.vehicleList.Count}] {Vehicle.asset.vehicleName}", Color.yellow); | ||
} | ||
return; | ||
} | ||
else | ||
{ | ||
UnturnedChat.Say(uPlayer, "You do not have any locked vehicles!", Color.red); | ||
return; | ||
} | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Rocket.Unturned.Player; | ||
using SDG.Unturned; | ||
using System.Collections.Generic; | ||
|
||
namespace VehicleTeleporter | ||
{ | ||
public class UtilPlayer : UnturnedPlayerComponent | ||
{ | ||
|
||
public List<InteractableVehicle> vehicleList = new List<InteractableVehicle>(); | ||
|
||
public UtilPlayer() | ||
{ | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Rocket.Core.Plugins; | ||
using Rocket.Unturned.Player; | ||
using SDG.Unturned; | ||
using Steamworks; | ||
using System; | ||
using Logger = Rocket.Core.Logging.Logger; | ||
|
||
namespace VehicleTeleporter | ||
{ | ||
public class VehicleTeleporter : RocketPlugin | ||
{ | ||
public static VehicleTeleporter Instance; | ||
|
||
protected override void Load() | ||
{ | ||
base.Load(); | ||
Instance = this; | ||
Logger.Log("Loading VehicleTeleporter, made by Mr.Kwabs.", ConsoleColor.Yellow); | ||
Logger.Log("Successfully loaded VehicleTeleporter, made by Mr.Kwabs.", ConsoleColor.Yellow); | ||
} | ||
|
||
protected override void Unload() | ||
{ | ||
Logger.Log("Unloading VehicleTeleporter, made by Mr.Kwabs.", ConsoleColor.Red); | ||
Instance = null; | ||
base.Unload(); | ||
} | ||
|
||
public int HasVehicles(CSteamID uID) | ||
{ | ||
UnturnedPlayer.FromCSteamID(uID).GetComponent<UtilPlayer>().vehicleList.Clear(); | ||
|
||
int vehicleCount = 0; | ||
if (VehicleManager.vehicles.Count > 0) | ||
{ | ||
foreach (InteractableVehicle Vehicle in VehicleManager.vehicles) | ||
{ | ||
if (Vehicle.isLocked) | ||
{ | ||
if (Vehicle.lockedOwner == uID) | ||
{ | ||
UnturnedPlayer.FromCSteamID(uID).GetComponent<UtilPlayer>().vehicleList.Add(Vehicle); | ||
vehicleCount++; | ||
} | ||
} | ||
} | ||
} | ||
return vehicleCount; | ||
} | ||
} | ||
} |