// PrivateMediaScreenChat.cs // Adds a /privatevideo chat command: it changes what the media screens show for the player who typed it only. // Everyone else keeps watching what they were watching. // // /privatevideo every media screen, for you only // /privatevideo one media screen (its Screen ID in the Inspector), for you only // // (/yt is the world's built-in command that changes the screens for everybody, in sync.) using IHXR.Simulation; public class PrivateMediaScreenChat : ScriptBase { [Tooltip("The chat command, without the slash. Built-in commands such as yt cannot be used.")] public string CommandName = "privatevideo"; public override void Start() { string command = (CommandName ?? "").Trim().TrimStart('/'); if (command.Length == 0) command = "privatevideo"; RegisterChatCommand(command, OnPrivateVideoCommand); Log("Registered /" + command + "."); } void OnPrivateVideoCommand(ChatCommandInfo info) { if (info == null || info.Args == null || info.Args.Length == 0) { Log("Usage: /" + CommandName + " or /" + CommandName + " "); return; } string screenId = info.Args.Length == 1 ? "*" : info.Args[0]; string url = info.Args.Length == 1 ? info.Args[0] : info.Args[1]; if (string.IsNullOrWhiteSpace(url)) { Log("The video address cannot be empty."); return; } SetMediaScreenUrlForUser(info.Username, screenId, url); Log(info.Username + " is now privately watching '" + url + "' on " + (screenId == "*" ? "every screen" : "screen '" + screenId + "'") + "."); } }