// NameTagToggle.cs // A /nametags chat command that turns player name tags on or off in this world. // // /nametags off hide every player's name tag // /nametags on show them again // /nametags off hide one player's tag (for everyone) // /nametags on show that one player's tag again // // A name tag is the floating username shown when you hover, tap or point at a player. This overrides the // scene's "Show player name tags" setting for the current world only; leaving the world clears it. using IHXR.Simulation; public class NameTagToggle : ScriptBase { public override void Start() { RegisterChatCommand("nametags", OnNameTags); Log("Type /nametags on|off (optionally a username) to control player name tags."); } void OnNameTags(ChatCommandInfo info) { if (info == null || info.Args == null || info.Args.Length == 0) { SendScriptChat("Usage: /nametags on|off (add a username to target one player)."); return; } string state = info.Args[0].Trim().ToLowerInvariant(); bool show = state == "on" || state == "show" || state == "1" || state == "true"; bool off = state == "off" || state == "hide" || state == "0" || state == "false"; if (!show && !off) { SendScriptChat("Say 'on' or 'off', for example /nametags off"); return; } if (info.Args.Length >= 2) { string username = info.Args[1].Trim(); SetPlayerNameTag(username, show); SendScriptChat((show ? "Showing" : "Hiding") + " the name tag for " + username + "."); } else { SetAllPlayerNameTags(show); SendScriptChat("Player name tags " + (show ? "shown" : "hidden") + " for everyone."); } } }