コード例 #1
0
ファイル: ToggleTag.cs プロジェクト: KarlOfDuty/ToggleTag
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            // Check if userid is included
            if (args.Length > 0)
            {
                // Check if already visible
                if (plugin.tagsToggled.Remove(args[0]))
                {
                    // Gets the player name for the feedback and sets the playeer's tag status if they are online
                    string           name   = "";
                    Smod2.API.Player player = plugin.Server.GetPlayers(args[0])?[0];
                    if (player != null)
                    {
                        player.HideTag(false);
                        name = player.Name;
                    }
                    else
                    {
                        name = "offline player";
                    }

                    plugin.SaveTagsToFile();
                    return(new[] { "Tag revealed of " + name + "." });
                }
                else
                {
                    // Still set the tag just in case it's status is not synced with the plugin's status for some reason
                    Smod2.API.Player player = plugin.Server.GetPlayers(args[0])?[0];
                    player?.HideTag(false);
                    return(new[] { "Tag was already revealed." });
                }
            }
            return(new[] { "Not enough arguments provided. 'console_showtag <userid>'" });
        }
コード例 #2
0
ファイル: ToggleTag.cs プロジェクト: KarlOfDuty/ToggleTag
        public void OnAdminQuery(AdminQueryEvent ev)
        {
            // Check if user or console command
            if (ev.Query == "REQUEST_DATA PLAYER_LIST SILENT" || ev.Admin?.UserID == null)
            {
                return;
            }

            if (ev.Admin.HasPermission("toggletag.savetag"))
            {
                // Check normal version of command
                if (ev.Query == "hidetag")
                {
                    plugin.tagsToggled.Add(ev.Admin.UserID);
                    plugin.SaveTagsToFile();
                    return;
                }
                else if (ev.Query == "showtag")
                {
                    plugin.tagsToggled.Remove(ev.Admin.UserID);
                    plugin.SaveTagsToFile();
                    return;
                }
            }

            if (ev.Admin.HasPermission("toggletag.saveoverwatch"))
            {
                // Check overwatch command
                if (ev.Query.Split(' ')[0] == "overwatch" && ev.Query.Split(' ')[1] == ev.Admin.PlayerID.ToString() + ".")
                {
                    if (ev.Query.Split(' ')[2] == "0")
                    {
                        plugin.overwatchToggled.Remove(ev.Admin.UserID);
                    }
                    else
                    {
                        plugin.overwatchToggled.Add(ev.Admin.UserID);
                    }
                    plugin.SaveTagsToFile();
                }
            }
        }