public void Execute(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(translations.Get("command_bed_no_bed_found_private")); } if (player.Entity.Stance == EPlayerStance.DRIVING || player.Entity.Stance == EPlayerStance.SITTING) { throw new CommandWrongUsageException(translations.Get("command_generic_teleport_while_driving_error")); } player.Entity.Teleport(pos.ToSystemVector(), rot); }
public void Execute(ICommandContext context) { ITranslationCollection translations = ((RocketUnturnedHost)context.Container.Resolve <IHost>()).ModuleTranslations; UnturnedPlayer player = (UnturnedPlayer)context.Player; if (context.Parameters.Length != 1 && context.Parameters.Length != 3) { throw new CommandWrongUsageException(); } if (player.Entity.Stance == EPlayerStance.DRIVING || player.Entity.Stance == EPlayerStance.SITTING) { throw new CommandWrongUsageException( translations.Get("command_generic_teleport_while_driving_error")); } float?x = null; float?y = null; float?z = null; if (context.Parameters.Length == 3) { x = context.Parameters.Get <float>(0); y = context.Parameters.Get <float>(1); z = context.Parameters.Get <float>(2); } if (x != null) { player.Entity.Teleport(new System.Numerics.Vector3((float)x, (float)y, (float)z)); context.User.SendLocalizedMessage(translations, "command_tp_teleport_private", null, (float)x + "," + (float)y + "," + (float)z); return; } if (context.Parameters.Get <IPlayer>(0) is UnturnedPlayer otherplayer && otherplayer != player) { player.Entity.Teleport(otherplayer); context.User.SendLocalizedMessage(translations, "command_tp_teleport_private", null, otherplayer.CharacterName); return; } Node item = LevelNodes.nodes.FirstOrDefault(n => n.type == ENodeType.LOCATION && ((LocationNode)n).name.ToLower().Contains(context.Parameters.Get <string>(0).ToLower())); if (item != null) { Vector3 c = item.point + new Vector3(0f, 0.5f, 0f); player.Entity.Teleport(c.ToSystemVector()); context.User.SendLocalizedMessage(translations, "command_tp_teleport_private", null, ((LocationNode)item).name); return; } context.User.SendLocalizedMessage(translations, "command_tp_failed_find_destination"); }
public void Execute(ICommandContext context) { ITranslationCollection translations = ((RocketUnturnedHost)context.Container.Resolve <IHost>()).ModuleTranslations; if (context.Parameters.Length != 1) { throw new CommandWrongUsageException(); } UnturnedPlayer target = (UnturnedPlayer)context.Parameters.Get <IPlayer>(0); SteamPlayer otherPlayer = target.SteamPlayer; context.User.SendMessage(translations.Get("command_investigate_private", otherPlayer.playerID.characterName, otherPlayer.playerID.steamID.ToString())); }
[CommandUser(typeof(IConsole))] // only console can call it public void Broadcast(IUser sender, string[] args) { userManager.Broadcast(sender, translations.Get("broadcast", sender, string.Join(" ", args))); }
/// <summary> /// Broadcasts a localized message to all players /// </summary> /// <param name="userManager">The user manager.</param> /// <param name="translations">The translation soruce</param> /// <param name="translationKey">The key of the translated message to send</param> /// <param name="arguments">The arguments for the message</param> public static void BroadcastLocalized(this IUserManager userManager, ITranslationCollection translations, IEnumerable <IUser> receivers, string translationKey, Color?color = null, params object[] arguments) { userManager.Broadcast(null, receivers, translations.Get(translationKey, arguments), color); }
/// <summary> /// Broadcasts a localized message to all players /// </summary> /// <param name="userManager">The user manager.</param> /// <param name="translations">The translation soruce</param> /// <param name="translationKey">The key of the translated message to send</param> /// <param name="arguments">The arguments for the message</param> public static void BroadcastLocalized(this IUserManager userManager, ITranslationCollection translations, string translationKey, params object[] arguments) { userManager.Broadcast(null, translations.Get(translationKey, arguments)); }
/// <summary> /// Sends a localized message to the given player /// </summary> /// <param name="userManager">The user manager.</param> /// <param name="translations">The translation source.</param> /// <param name="user">The message receiver.</param> /// <param name="translationKey">The translation key.</param> /// <param name="arguments">The arguments for the message.</param> public static void SendLocalizedMessage(this IUserManager userManager, ITranslationCollection translations, IUser user, string translationKey, params object[] arguments) { userManager.SendMessage(user, translations.Get(translationKey, arguments)); }
/// <summary> /// Sends a localized (translatable) message to the user. /// </summary> /// <param name="User">The message receiver.</param> /// <param name="translations">The translations source.</param> /// <param name="translationKey">The translation key.</param> /// <param name="arguments">The arguments for the message. See <see cref="string.Format(string, object[])" /></param> public static void SendLocalizedMessage(this IUser User, ITranslationCollection translations, string translationKey, Color?color = null, params object[] arguments) { User.SendMessage(translations.Get(translationKey, arguments), color); }