// All we are doing here is checking the config to see if anything like restricted movement or time restriction is enforced. public static object[] CheckConfig(UnturnedPlayer player) { object[] returnv = { false, null, null }; // First check if command is enabled. if (!Instance.Configuration.Instance.Enabled) { // Command disabled. UnturnedChat.Say(player, string.Format(Instance.Configuration.Instance.DisabledMsg, player.CharacterName)); return(returnv); } // It is enabled, but are they in a vehicle? if (player.Stance == EPlayerStance.DRIVING || player.Stance == EPlayerStance.SITTING) { // They are in a vehicle. UnturnedChat.Say(player, string.Format(Instance.Configuration.Instance.NoVehicleMsg, player.CharacterName)); return(returnv); } // They aren't in a vehicle, so check if they have a bed. if (!BarricadeManager.tryGetBed(player.CSteamID, out var bedPos, out var bedRot)) { // Bed not found. UnturnedChat.Say(player, string.Format(Instance.Configuration.Instance.NoBedMsg, player.CharacterName)); return(returnv); } object[] returnv2 = { true, bedPos, bedRot }; return(returnv2); }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; Vector3 pos; byte rot; if (!BarricadeManager.tryGetBed(player.CSteamID, out pos, out rot)) { UnturnedChat.Say(caller, U.Translate("command_bed_no_bed_found_private")); throw new WrongUsageOfCommandException(caller, this); } 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")); } } } }
public void Execute(IRocketPlayer caller, string[] command) { if (command.Length >= 1) { CSteamID PlayerID; UnturnedPlayer TargetPlayer = UnturnedPlayer.FromName(command[0]); if (TargetPlayer == null) { if (Helpers.IsSteamID(command[0])) { PlayerID = new CSteamID(Convert.ToUInt64(command[0])); } else { UnturnedChat.Say(caller, "GotoBed_NoPlayer".Translate()); return; } } else { PlayerID = TargetPlayer.CSteamID; } UnturnedPlayer Player = (UnturnedPlayer)caller; if (BarricadeManager.tryGetBed(PlayerID, out Vector3 Location, out byte Angle)) { Player.Player.teleportToLocationUnsafe(Location, Angle); } else { UnturnedChat.Say(caller, $"GotoBed_NoBed".Translate(Player.CSteamID.m_SteamID)); } }
public override CommandResult OnExecute(ICommandSource src, ICommandArgs args) { var player = src.ToPlayer(); var playerId = player.CSteamId; if (Cooldown.Has(playerId)) { return(CommandResult.Lang(EssLang.USE_COOLDOWN, TimeUtil.FormatSeconds((uint)Cooldown.GetRemaining(playerId)))); } Vector3 position; byte angle; if (player.RocketPlayer.Stance == EPlayerStance.DRIVING || player.RocketPlayer.Stance == EPlayerStance.SITTING) { return(CommandResult.Lang(EssLang.CANNOT_TELEPORT_DRIVING)); } if (!BarricadeManager.tryGetBed(player.CSteamId, out position, out angle)) { return(CommandResult.Lang(EssLang.WITHOUT_BED)); } var homeCommand = UEssentials.Config.HomeCommand; var delay = homeCommand.Delay; var cooldown = homeCommand.Cooldown; if (player.HasPermission("essentials.bypass.homecooldown")) { delay = 0; cooldown = 0; } if (delay > 0) { EssLang.TELEPORT_DELAY.SendTo(src, TimeUtil.FormatSeconds((uint)delay)); } var task = Tasks.New(t => { Delay.Remove(playerId.m_SteamID); if (!player.IsOnline) { return; } player.Teleport(position, angle); EssLang.TELEPORTED_BED.SendTo(src); }).Delay(delay * 1000); task.Go(); Delay.Add(playerId.m_SteamID, task); Cooldown.Add(playerId, cooldown); return(CommandResult.Success()); }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; if (!BarricadeManager.tryGetBed(player.CSteamID, out Vector3 pos, out byte rot)) { UnturnedChat.Say(caller, U.Translate("command_bed_no_bed_found_private")); throw new WrongUsageOfCommandException(caller, this); }
internal static bool CheckIfNearBed(UnturnedPlayer player) { if (Instance.Configuration.Instance.CancelOnBedRespawn) { byte bedAngle; Vector3 bedPos; if (BarricadeManager.tryGetBed(player.CSteamID, out bedPos, out bedAngle) && Vector3.Distance(bedPos, player.Position) < 15) { UnturnedChat.Say(player, Instance.Translate("canceled_bedrespawn"), UnturnedChat.GetColorFromName(Instance.Configuration.Instance.ProtectionMessageColor, Color.red)); return(true); } } return(false); }
public override CommandResult OnExecute(ICommandSource src, ICommandArgs args) { var player = src.ToPlayer(); var playerId = player.CSteamId; Vector3 position; byte angle; if (player.RocketPlayer.Stance == EPlayerStance.DRIVING || player.RocketPlayer.Stance == EPlayerStance.SITTING) { return(CommandResult.Lang("CANNOT_TELEPORT_DRIVING")); } if (!BarricadeManager.tryGetBed(player.CSteamId, out position, out angle)) { return(CommandResult.Lang("WITHOUT_BED")); } if (Delay.ContainsKey(player.CSteamId.m_SteamID)) { return(CommandResult.Lang("ALREADY_WAITING")); } var homeCommand = UEssentials.Config.Home; var delay = homeCommand.TeleportDelay; if (player.HasPermission("essentials.bypass.homecooldown")) { delay = 0; } if (delay > 0) { EssLang.Send(src, "TELEPORT_DELAY", TimeUtil.FormatSeconds((uint)delay)); } var task = Task.Create() .Delay(TimeSpan.FromSeconds(delay)) .Action(t => { Delay.Remove(playerId.m_SteamID); player.Teleport(position, angle); EssLang.Send(src, "TELEPORTED_BED"); }) .Submit(); Delay.Add(playerId.m_SteamID, task); return(CommandResult.Success()); }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; if (!BarricadeManager.tryGetBed(player.CSteamID, out Vector3 pos, out byte rot)) { UnturnedChat.Say(caller, U.Translate("command_bed_no_bed_found_private")); throw new WrongUsageOfCommandException(caller, this); } 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); } player.Teleport(pos, rot); }
public override void Execute(PointBlankPlayer executor, string[] args) { UnturnedPlayer player = (UnturnedPlayer)executor; if (player.Stance.stance == EPlayerStance.DRIVING || player.Stance.stance == EPlayerStance.SITTING) { UnturnedChat.SendMessage(executor, Translate("Home_Stance"), ConsoleColor.Red); return; } if (player.Metadata.ContainsKey("Home")) { UnturnedChat.SendMessage(executor, Translate("Home_Waiting"), ConsoleColor.Red); return; } if (!BarricadeManager.tryGetBed(player.SteamID, out Vector3 position, out byte angle)) { UnturnedChat.SendMessage(executor, Translate("Home_NoBed"), ConsoleColor.Red); return; } int delay = Configure <int>("Home_Delay_Seconds"); if (player.HasPermission("useressentials.bypass.homedelay")) { delay = 0; } if (delay > 0) { UnturnedChat.SendMessage(executor, Translate("Home_Delay", delay), ConsoleColor.Green); } player.Metadata.Add("Home", true); PointBlankTask.Create() .Delay(TimeSpan.FromSeconds(delay)) .Action((task) => { if (!UnturnedPlayer.IsInServer(player)) { return; } player.Teleport(position); player.Metadata.Remove("Home"); UnturnedChat.SendMessage(executor, Translate("Home_Success"), ConsoleColor.Green); }).Build(true); }
public async Task ExecuteAsync(ICommandContext context) { UnturnedPlayer player = ((UnturnedUser)context.User).Player; ITranslationCollection translations = ((RocketUnturnedHost)context.Container.Resolve <IHost>()).ModuleTranslations; if (!BarricadeManager.tryGetBed(player.CSteamID, out Vector3 pos, out byte rot)) { throw new CommandWrongUsageException(await translations.GetAsync("command_bed_no_bed_found_private")); } if (player.Entity.Stance == EPlayerStance.DRIVING || player.Entity.Stance == EPlayerStance.SITTING) { throw new CommandWrongUsageException(await translations.GetAsync("command_generic_teleport_while_driving_error")); } player.Entity.Teleport(pos.ToSystemVector(), rot); }
public override void Execute(ICommandContext context) { var player = ((UnturnedUser)context.User).Player; var playerId = player.CSteamID; var scheduler = context.Container.Resolve <ITaskScheduler>(); if (player.Entity.Stance == EPlayerStance.DRIVING || player.Entity.Stance == EPlayerStance.SITTING) { throw new CommandWrongUsageException(Translations.Get("CANNOT_TELEPORT_DRIVING")); } if (!BarricadeManager.tryGetBed(player.CSteamID, out var bedPosition, out var bedAngle)) { throw new CommandWrongUsageException(Translations.Get("WITHOUT_BED")); } if (Delay.ContainsKey(player.CSteamID.m_SteamID)) { throw new CommandWrongUsageException(Translations.Get("ALREADY_WAITING")); } var homeCommand = UEssentials.Config.Home; var delay = homeCommand.TeleportDelay; if (player.CheckPermission("essentials.bypass.homecooldown") == PermissionResult.Grant) { delay = 0; } if (delay > 0) { context.User.SendLocalizedMessage(Translations, "TELEPORT_DELAY", TimeUtil.FormatSeconds((uint)delay)); } var task = scheduler.ScheduleDelayed(UEssentials, () => { Delay.Remove(playerId.m_SteamID); player.Entity.Teleport(bedPosition.ToSystemVector(), bedAngle); context.User.SendLocalizedMessage(Translations, "TELEPORTED_BED"); }, "EssentialsHomeTeleport", TimeSpan.FromSeconds(delay)); Delay.Add(playerId.m_SteamID, task); }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; Vector3 pos; byte rot; if (!BarricadeManager.tryGetBed(player.CSteamID, out pos, out rot)) { UnturnedChat.Say(caller, U.Translate("command_bed_no_bed_found_private")); } else { if (player.Stance == EPlayerStance.DRIVING || player.Stance == EPlayerStance.SITTING) { UnturnedChat.Say(caller, U.Translate("command_generic_teleport_while_driving_error")); } else { player.Teleport(pos, rot); } } }
public void Execute(IRocketPlayer caller, string[] command) { player = (UnturnedPlayer)caller; if (player.Stance == EPlayerStance.DRIVING || player.Stance == EPlayerStance.SITTING) { // They are in a vehicle. UnturnedChat.Say(player, "You're in a vehicle, aborting teleport to bed.", Color.yellow); return; } if (!BarricadeManager.tryGetBed(player.CSteamID, out bedPos, out bedRot)) { UnturnedChat.Say(player, "You do not have a bed to teleport to.", Color.red); return; } if (player.IsAdmin) { player.Teleport(bedPos, bedRot); UnturnedChat.Say(player, "You were teleported to your bed.", Color.yellow); } else { if (DatasEssentialsManager.Instance.Configuration.Instance.bedWaitTime > 0) { someoneToTransport = true; UnturnedChat.Say(player, "You will be transported to your bed in " + DatasEssentialsManager.Instance.Configuration.Instance.bedWaitTime + " seconds.", Color.yellow); lastCalledHome = DateTime.Now; return; } goHome(); } }
public void Execute(IRocketPlayer caller, string[] command) { var player = (UnturnedPlayer)caller; if (Home.PlayersController.Contains(player.CSteamID)) { UnturnedChat.Say(player, Home.Instance.Translate("teleportation_in_proc"), Color.red); return; } if (!BarricadeManager.tryGetBed(player.CSteamID, out _, out _)) { UnturnedChat.Say(player, Home.Instance.Translate("bed_not_found"), Color.red); return; } Home.PlayersController.Add(player.CSteamID); Task.Run(async() => { UnturnedChat.Say(player, Home.Instance.Translate("teleport_info", Home.Config.TeleportDelay), Color.green); await Task.Delay(Home.Config.TeleportDelay * 1000); if (!Home.PlayersController.Contains(player.CSteamID)) { return; } Home.FinishTeleportTask(player.CSteamID); if (player.Player.teleportToBed()) { UnturnedChat.Say(player, Home.Instance.Translate("teleported_to_bed"), Color.cyan); return; } UnturnedChat.Say(player, Home.Instance.Translate("bed_not_found"), Color.red); }); }
public void Execute(IRocketPlayer caller, string[] command) { var unturnedPlayer = (UnturnedPlayer)caller; if (coolDown.ContainsKey(unturnedPlayer.CSteamID) || coolDown.FirstOrDefault(x => x.Key == unturnedPlayer.CSteamID).Value > DateTime.Now) { var secondsLeft = coolDown.FirstOrDefault(x => x.Key == unturnedPlayer.CSteamID).Value - DateTime.Now; ChatManager.serverSendMessage( $"<b>{secondsLeft}</b> seconds left".Replace("{", "<").Replace("}", ">"), Color.yellow, null, unturnedPlayer.SteamPlayer(), EChatMode.SAY, null, true); return; } if (coolDown.FirstOrDefault(x => x.Key == unturnedPlayer.CSteamID).Value > DateTime.Now) { coolDown.Remove(unturnedPlayer.CSteamID); } if (!BarricadeManager.tryGetBed(unturnedPlayer.CSteamID, out _, out _)) { ChatManager.serverSendMessage( $"no bed", Color.yellow, null, unturnedPlayer.SteamPlayer(), EChatMode.SAY, null, true); return; } if (unturnedPlayer.Stance == EPlayerStance.DRIVING || unturnedPlayer.Stance == EPlayerStance.DRIVING) { ChatManager.serverSendMessage( $"in vehicle", Color.yellow, null, unturnedPlayer.SteamPlayer(), EChatMode.SAY, null, true); return; } unturnedPlayer.Player.teleportToBed(); ChatManager.serverSendMessage( $"teleported to bed", Color.cyan, null, unturnedPlayer.SteamPlayer(), EChatMode.SAY, null, true); coolDown.Add(unturnedPlayer.CSteamID, DateTime.Now.AddSeconds(PSRMEssentials.Instance.Configuration.Instance.HomeConfig.Cooldown)); }
public void Execute(IRocketPlayer caller, string[] command) { // display hello world in world chat after typing /home with the caller name // ChatManager.sendChat(EChatMode.GLOBAL, caller.DisplayName + "has called /home"); //UnturnedChat.Say(caller.DisplayName + " has called /home"); UnturnedPlayer player = (UnturnedPlayer)caller; Vector3 playerPosition; playerPosition.x = player.Position.x; //new Vector3(); playerPosition.y = player.Position.y; playerPosition.z = player.Position.z; //UnturnedPlayer player = caller.to //BarricadeManager barricades; Vector3 bedPosition = new Vector3(); byte bedAngle; bool hasBed; //byte newByte = 0; //byte bedRotation = 0; hasBed = BarricadeManager.tryGetBed(player.CSteamID, out bedPosition, out bedAngle); if (hasBed) { player.Teleport(bedPosition, bedAngle); // upate player position playerPosition.x = player.Position.x; playerPosition.y = player.Position.y; playerPosition.z = player.Position.z; UnturnedChat.Say(caller.DisplayName + " has called /home and attempted to teleport"); UnturnedChat.Say(caller.DisplayName + " current location: x:" + playerPosition.x + " y:" + playerPosition.y + " z:" + playerPosition.z); UnturnedChat.Say(caller.DisplayName + " bed location: x:" + bedPosition.x + " y:" + bedPosition.y + " z:" + bedPosition.z); } else { UnturnedChat.Say(caller.DisplayName + " has called /home with no bed"); //UnturnedChat.Say(caller.DisplayName + " current location: x:" + playerPosition.x + " y:" + playerPosition.y + " z:" + playerPosition.z); } UnturnedChat.Say(caller.DisplayName + " current location: x:" + playerPosition.x + " y:" + playerPosition.y + " z:" + playerPosition.z); // This is intentionally Disatrous... will fix! // Get Bed Location // Get all Beds placed in the World?... //UnturnedNexus nexus = new UnturnedNexus(); //nexus.initialize(); //nexus.shutdown(); // I have no clue what this is... //UnturnedNexus testEvent; //testEvent. /* * UnturnedPlayerComponent playerC; * UnturnedPlayer player; * UnturnedPlayerFeatures playerF; * UnturnedPlayerEvents playerE; * UnturnedPlayerMovement playerM; */ //player.transform. //if (playerM.) //Vector3 bedLoc = new Vector3(); }