Beispiel #1
0
        public void dropdown(Plugin plugin, BasePlayer player, List <string> options, Rectangle rectangle, GuiContainer.Layer layer, string parent, GuiColor panelColor, GuiColor textColor, Action <string> callback, bool allowNew = false, int page = 0, Predicate <string> predicate = null)
        {
            if (allowNew)
            {
                options.Add("(add new)");
            }
            int maxItems = 5;

            rectangle.H *= ((float)options.Count / (float)maxItems);
            List <List <string> > ListOfLists = SplitIntoChunks <string>(options, maxItems);
            GuiContainer          container   = new GuiContainer(plugin, "dropdown_API", parent);

            double cfX = rectangle.W / 300;
            double cfY = rectangle.H / 570;

            Action <BasePlayer, string[]> up = (bPlayer, input) =>
            {
                dropdown(plugin, player, options, rectangle, layer, parent, panelColor, textColor, callback, allowNew, page - 1, predicate);
            };
            Action <BasePlayer, string[]> down = (bPlayer, input) =>
            {
                dropdown(plugin, player, options, rectangle, layer, parent, panelColor, textColor, callback, allowNew, page + 1, predicate);
            };

            if (page > 0)
            {
                container.addPlainButton("dropdown_up", new Rectangle(0, 1, 298, 36, 300, 570, true), new GuiColor(1, 1, 1, 0.4f), 0, 0, new GuiText("<b>∧</b>", (int)Math.Floor(22 * cfY), new GuiColor("black")), up, parent: "dropdown_background");
            }
            if (page < ListOfLists.Count - 1)
            {
                container.addPlainButton("dropdown_up", new Rectangle(0, 533, 298, 37, 300, 570, true), new GuiColor(1, 1, 1, 0.4f), 0, 0, new GuiText("<b>∨</b>", (int)Math.Floor(22 * cfY), new GuiColor("black")), down, parent: "dropdown_background");
            }

            int count = 0;

            foreach (string option in ListOfLists[page])
            {
                int       hEach = (int)(rectangle.H / ListOfLists[page].Count);
                Rectangle pos   = new Rectangle(0, 0 + (count * hEach), rectangle.W, hEach, rectangle.W, rectangle.H, true).WithParent(rectangle);

                Action <BasePlayer, string[]> btnCallback = null;
                if (option == "(add new)")
                {
                    btnCallback = (bPlayer, input) => dropdownAddNew(plugin, player, pos, callback, predicate);
                }
                else
                {
                    string selected = option;
                    btnCallback = (bPlayer, input) =>
                    {
                        callback(selected);
                    };
                }
                container.addPlainButton($"dropdown_option_{option}", pos, layer, panelColor, 0, 0, new GuiText(option, color: textColor), btnCallback, blur: GuiContainer.Blur.strong);
                count++;
            }

            container.display(player);
        }
Beispiel #2
0
        public void SmallConfirmPrompt(BasePlayer player, string header, Action <BasePlayer, string[]> yesCallback, Action <BasePlayer, string[]> noCallback)
        {
            GuiContainer containerGUI = new GuiContainer(this, "prompt");

            containerGUI.addPlainButton("close", new Rectangle(), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.3f), 0.1f, 0.1f, callback: noCallback, blur: GuiContainer.Blur.medium);
            containerGUI.addPlainPanel("background", new Rectangle(710, 465, 500, 150, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.6f), 0.1f, 0.1f, GuiContainer.Blur.medium);
            containerGUI.addPanel("header", new Rectangle(710, 465, 500, 60, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0), 0.1f, 0.1f, new GuiText(header, 25, new GuiColor(1, 1, 1, 0.7f)));
            containerGUI.addPlainButton("yes", new Rectangle(740, 545, 200, 50, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 1, 0, 0.6f), 0.1f, 0.1f, new GuiText("YES", 20, new GuiColor(1, 1, 1, 0.7f)), yesCallback, "prompt");
            containerGUI.addPlainButton("no", new Rectangle(980, 545, 200, 50, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(1, 0, 0, 0.6f), 0.1f, 0.1f, new GuiText("NO", 20, new GuiColor(1, 1, 1, 0.7f)), noCallback, "prompt");
            containerGUI.display(player);
        }
Beispiel #3
0
        public void prompt(BasePlayer player, string header, string msg, Action <BasePlayer, string[]> Callback = null)
        {
            GuiContainer containerGUI = new GuiContainer(this, "prompt");

            containerGUI.addPlainButton("close", new Rectangle(), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.3f), 0.1f, 0.1f, blur: GuiContainer.Blur.medium);
            containerGUI.addPlainPanel("background", new Rectangle(710, 390, 500, 300, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.6f), 0.1f, 0.1f, GuiContainer.Blur.medium);
            containerGUI.addPanel("header", new Rectangle(710, 390, 500, 60, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0), 0.1f, 0.1f, new GuiText(header, 25, new GuiColor(1, 1, 1, 0.7f)));
            containerGUI.addPanel("msg", new Rectangle(735, 400, 450, 150, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0), 0.1f, 0.1f, new GuiText(msg, 14, new GuiColor(1, 1, 1, 0.7f)));
            containerGUI.addPlainButton("ok", new Rectangle(860, 520, 200, 50, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 1, 0.6f), 0.1f, 0.1f, new GuiText("OK", 20, new GuiColor(1, 1, 1, 0.7f)), Callback, "prompt");
            containerGUI.display(player);
        }
Beispiel #4
0
            private void SendHuePicker()
            {
                GuiContainer c = new GuiContainer(PluginInstance, "HuePicker", nameof(ColorPicker));

                int    baseX        = 610;
                int    y            = 732;
                double width        = 700d / hueRes;
                int    height       = 30;
                double hueIncrement = 360d / hueRes;

                for (int i = 0; i < hueRes; i++)
                {
                    Rectangle pos   = new Rectangle(baseX + i * width, y, width, height, resX, resY, true);
                    GuiColor  color = new GuiColor(i * hueIncrement, 1, 1, 1);
                    int       hue   = (int)(i * hueIncrement);

                    int index = i;

                    Action <BasePlayer, string[]> callback = (p, a) =>
                    {
                        Hue = hue;
                        SendHueSelector(index);
                        SendVSPicker();
                    };

                    c.addPlainButton($"hue_{i}", pos, layer, color, fadeIn, fadeOut, callback: callback);
                }

                c.display(Player);

                SendHueSelector(0);
                SendVSPicker();
            }
Beispiel #5
0
        public void Tickbox(BasePlayer player, Plugin plugin, Rectangle parentRectangle, GuiContainer.Layer layer, string name, string parentContainer, Action <BasePlayer, string[]> onTick, Action <BasePlayer, string[]> onUntick, bool initialState = false, bool disabled = false, float fadeIn = 0, float fadeOut = 0)
        {
            GuiContainer c         = new GuiContainer(plugin, name + "_APITickbox", parentContainer);
            GuiColor     lightGrey = new GuiColor(0.5f, 0.5f, 0.5f, 1);
            GuiColor     darkGrey  = new GuiColor(0.8f, 0.8f, 0.8f, 1);

            if (initialState)
            {
                Rectangle fgPos = new Rectangle(0.15f, 0.15f, 0.72f, 0.72f, 1f, 1f, true).WithParent(parentRectangle);
                c.addPlainButton("bg", parentRectangle, layer, disabled ? lightGrey : GuiColor.White, fadeIn, fadeOut, callback: disabled ? null : onUntick);
                c.addPlainButton("fg", fgPos, layer, disabled ? darkGrey : GuiColor.Black, fadeIn, fadeOut, callback: disabled ? null : onUntick);
            }
            else
            {
                c.addPlainButton("bg", parentRectangle, layer, disabled ? lightGrey : GuiColor.White, fadeIn, fadeOut, callback: disabled ? null : onTick);
            }

            c.display(player);
        }
Beispiel #6
0
        public void creatorButton(BasePlayer player, createErrorType error = createErrorType.none, BountyBP bp = null)
        {
            GuiContainer c         = new GuiContainer(this, "createButton", "bountyCreator");
            Rectangle    ButtonPos = new Rectangle(710, 856, 500, 100, resX, resY, true);

            List <GuiText> textOptions = new List <GuiText>
            {
                new GuiText("Create Bounty", guiCreator.getFontsizeByFramesize(13, ButtonPos), lightGreen),
                new GuiText("Target not found!", guiCreator.getFontsizeByFramesize(17, ButtonPos), lightRed),
                new GuiText("Invalid reward!", guiCreator.getFontsizeByFramesize(15, ButtonPos), lightRed),
                new GuiText("Can't afford reward!", guiCreator.getFontsizeByFramesize(20, ButtonPos), lightRed),
                new GuiText("Reason missing!", guiCreator.getFontsizeByFramesize(15, ButtonPos), lightRed)
            };

            Action <BasePlayer, string[]> cb = (p, a) =>
            {
                if (bp.target == null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    creatorButton(player, createErrorType.missingTarget, bp);
                }
                else if (bp.reward == 0)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    creatorButton(player, createErrorType.badReward, bp);
                }
                else if (config.requireReason && string.IsNullOrEmpty(bp.reason))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    creatorButton(player, createErrorType.missingReason, bp);
                }
                else
                {
                    Effect.server.Run(successSound, player.transform.position);
                    bp.init(player);
                    GuiTracker.getGuiTracker(player).destroyGui(this, "bountyCreator");
                }
            };

            c.addPlainButton("button", ButtonPos, GuiContainer.Layer.hud, (error == createErrorType.none) ? darkGreen : darkRed, FadeIn, FadeOut, textOptions[(int)error], cb, blur: GuiContainer.Blur.medium);
            c.display(player);

            if (error != createErrorType.none)
            {
                PluginInstance.timer.Once(2f, () =>
                {
                    if (GuiTracker.getGuiTracker(player).getContainer(this, "bountyCreator") != null)
                    {
                        creatorButton(player, bp: bp);
                    }
                });
            }
        }
Beispiel #7
0
        private void imgrawPreviewCommand(BasePlayer player, string command, string[] args)
        {
            if (!permission.UserHasPermission(player.UserIDString, "gui.demo"))
            {
                PrintToChat(player, lang.GetMessage("noPermission", this, player.UserIDString));
                return;
            }
            GuiContainer container = new GuiContainer(this, "imgPreview");

            container.addRawImage("img", new Rectangle(710, 290, 500, 500, 1920, 1080, true), args[0], GUICreator.GuiContainer.Layer.hud);
            container.addPlainButton("close", new Rectangle(0.15f, 0.15f, 0.1f, 0.1f), new GuiColor(1, 0, 0, 0.8f), 0, 0, new GuiText("close"));
            container.display(player);
        }
Beispiel #8
0
        public void SubmitPrompt(BasePlayer player, string header, Action <BasePlayer, string> inputCallback)
        {
            GuiContainer containerGUI = new GuiContainer(this, "prompt");

            containerGUI.addPlainButton("close", new Rectangle(), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.3f), 0.1f, 0.1f, blur: GuiContainer.Blur.medium);
            containerGUI.addPlainPanel("background", new Rectangle(710, 425, 500, 230, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.6f), 0.1f, 0.1f, GuiContainer.Blur.medium);
            containerGUI.addPanel("header", new Rectangle(710, 435, 500, 60, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0), 0.1f, 0.1f, new GuiText(header, 25, new GuiColor(1, 1, 1, 0.7f)));
            Submission submission = new Submission();
            Action <BasePlayer, string[]> inputFieldCallback = (p, a) =>
            {
                submission.Input = string.Join(" ", a);
            };

            containerGUI.addInput("input", new Rectangle(735, 505, 450, 60, 1920, 1080, true), inputFieldCallback, GuiContainer.Layer.overall, null, new GuiColor(1, 1, 1, 1), 100, new GuiText("", 14, new GuiColor(0, 0, 0, 1)), 0.1f, 0.1f);
            Action <BasePlayer, string[]> cb = (p, a) =>
            {
                inputCallback(p, submission.Input);
            };

            containerGUI.addPlainButton("submit", new Rectangle(860, 583, 200, 50, 1920, 1080, true), GuiContainer.Layer.overall, new GuiColor(1, 0, 0, 0.6f), 0.1f, 0.1f, new GuiText("SUBMIT", 20, new GuiColor(1, 1, 1, 0.7f)), cb, "prompt");
            containerGUI.display(player);
        }
Beispiel #9
0
        private void SendEntry(BasePlayer player, KeyValuePair <BasePlayer, PlayerSummary> kvp, int count, int sizeEach, int gap, Action <BasePlayer> callback)
        {
            if (GuiTracker.getGuiTracker(player).getContainer(PluginInstance, "PlayerSearch") == null)
            {
                return;
            }

            GuiColor black60 = new GuiColor(0, 0, 0, 0.6f);
            GuiColor black40 = new GuiColor(0, 0, 0, 0.4f);
            GuiColor white70 = new GuiColor(1, 1, 1, 0.7f);

            GuiContainer c = new GuiContainer(PluginInstance, $"{count}ImageContainer", "PlayerSearch");

            //background
            Rectangle entryBgPos = new Rectangle(715, 360 + count * (sizeEach + gap), 490, 80, 1920, 1080, true);

            c.addPlainPanel($"{count}EntryBG", entryBgPos, GuiContainer.Layer.overall, black60, 0.2f, 0);

            //ID
            Rectangle idPos  = new Rectangle(795, 365 + count * (sizeEach + gap), 405, 35, 1920, 1080, true);
            GuiText   idText = new GuiText($"[{kvp.Key.userID}]", 14, white70);

            c.addText($"{count}id", idPos, GuiContainer.Layer.overall, idText, 0.2f, 0);

            //Name
            Rectangle namePos  = new Rectangle(795, 400 + count * (sizeEach + gap), 405, 35, 1920, 1080, true);
            GuiText   nameText = new GuiText($"{kvp.Key.displayName}", getFontsizeByFramesize(kvp.Key.displayName.Length, namePos), white70);

            c.addText($"{count}name", namePos, GuiContainer.Layer.overall, nameText, 0.2f, 0);

            //button
            Action <BasePlayer, string[]> buttonCb = (p2, a) =>
            {
                GuiTracker.getGuiTracker(player).destroyGui(PluginInstance, "PlayerSearch");
                callback(kvp.Key);
            };

            c.addPlainButton($"{count}btnOverlay", entryBgPos, GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0), 0.2f, 0, callback: buttonCb, CursorEnabled: true);

            Rectangle imgPos = new Rectangle(720, 365 + count * (sizeEach + gap), 70, 70, 1920, 1080, true);

            c.addButton($"{count}Image", imgPos, GuiContainer.Layer.overall, null, 0.2f, 0, callback: buttonCb, close: "PlayerSearch", imgName: kvp.Key.UserIDString);

            c.display(player);
        }
Beispiel #10
0
            private void SendButton()
            {
                GuiContainer c = new GuiContainer(PluginInstance, "Ok", nameof(ColorPicker));

                Rectangle pos   = new Rectangle(1160, 540, 150, 60, resX, resY, true);
                GuiColor  color = new GuiColor(0, 1, 0, 0.5f);
                GuiText   text  = new GuiText("OK", 30, GuiColor.White.withAlpha(0.7f));

                Action <BasePlayer, string[]> callback = (p, a) =>
                {
                    Callback?.Invoke(new GuiColor(Hue, Value, Saturation, 1));
                    GuiTracker.getGuiTracker(Player).destroyGui(PluginInstance, nameof(ColorPicker));
                };

                c.addPlainButton("button", pos, layer, color, fadeIn, fadeOut, text, callback);

                c.display(Player);
            }
Beispiel #11
0
        public void imgPreview(BasePlayer player, string url)
        {
            Action callback = () =>
            {
                Rectangle    rectangle = new Rectangle(710, 290, 500, 500, 1920, 1080, true);
                GuiContainer container = new GuiContainer(PluginInstance, $"imgPreview");
                container.addRawImage($"img", rectangle, ImageLibrary.Call <string>("GetImage", $"GUICreator_preview_{url}"), "Hud");
                container.addPlainButton("close", new Rectangle(0.15f, 0.15f, 0.1f, 0.1f), new GuiColor(1, 0, 0, 0.8f), 0, 0, new GuiText("close"));
                container.display(player);
            };

            if (ImageLibrary.Call <bool>("HasImage", $"GUICreator_preview_{url}", (ulong)0))
            {
                callback();
            }
            else
            {
                ImageLibrary.Call <bool>("AddImage", url, $"GUICreator_preview_{url}", (ulong)0, callback);
            }
        }
Beispiel #12
0
            private void SendBackgound()
            {
                GuiContainer c = new GuiContainer(PluginInstance, nameof(ColorPicker));

                //clickout
                c.addPlainButton("close", new Rectangle(), layer, GuiColor.Transparent);

                //Panel
                Rectangle panelPos   = new Rectangle(560, 265, 800, 550, resX, resY, true);
                GuiColor  panelColor = new GuiColor(0, 0, 0, 0.5f);

                c.addPlainPanel("bgPanel", panelPos, layer, panelColor, fadeIn, fadeOut, GuiContainer.Blur.medium);

                //Label
                Rectangle labelPos  = new Rectangle(560, 265, 800, 60, resX, resY, true);
                GuiText   labelText = new GuiText(header, 30, GuiColor.White.withAlpha(0.7f));

                c.addText("bgLabel", labelPos, layer, labelText, fadeIn, fadeOut);

                c.display(Player);
            }
Beispiel #13
0
            private void SendVSPicker()
            {
                GuiContainer c = new GuiContainer(PluginInstance, "SVPicker", nameof(ColorPicker));

                int    baseX        = 610;
                int    baseY        = 330;
                double width        = 525d / (satRes + 1);
                double height       = 375d / (valueRes + 1);
                double satIncrement = 1d / satRes;
                double valIncrement = 1d / valueRes;

                for (int v = 0; v <= valueRes; v++)
                {
                    for (int s = 0; s <= satRes; s++)
                    {
                        double    saturation = s * satIncrement;
                        double    value      = (valueRes - v) * valIncrement;
                        Rectangle pos        = new Rectangle(baseX + s * width, baseY + v * height, width, height, resX, resY, true);
                        GuiColor  color      = new GuiColor(Hue, saturation, value, 1);

                        int si = s;
                        int vi = v;

                        Action <BasePlayer, string[]> callback = (p, a) =>
                        {
                            Saturation = saturation;
                            Value      = value;
                            SendSVSelector(si, vi);
                            SendPreview();
                        };

                        c.addPlainButton($"sv_{s}_{v}", pos, layer, color, fadeIn, fadeOut, callback: callback);
                    }
                }

                c.display(Player);

                SendPreview();
            }
Beispiel #14
0
        private void SendPlayerSearchUI(BasePlayer player, KeyValuePair <BasePlayer, PlayerSummary>[] results, Action <BasePlayer> callback, int page = 0)
        {
            List <List <KeyValuePair <BasePlayer, PlayerSummary> > > listOfLists = SplitIntoChunks(results.ToList(), 5);

            GuiContainer c = new GuiContainer(PluginInstance, "PlayerSearch");

            //clickout
            c.addPlainButton("close", new Rectangle(), GuiContainer.Layer.overall, new GuiColor(0, 0, 0, 0.3f), 0.1f, 0.1f, blur: GuiContainer.Blur.medium);

            GuiColor black60 = new GuiColor(0, 0, 0, 0.6f);
            GuiColor black40 = new GuiColor(0, 0, 0, 0.4f);
            GuiColor white70 = new GuiColor(1, 1, 1, 0.7f);

            //background
            Rectangle bgPos = new Rectangle(710, 260, 500, 560, 1920, 1080, true);

            c.addPlainPanel("background", bgPos, GuiContainer.Layer.overall, black60, 0.2f, 0, GuiContainer.Blur.medium);
            c.addPlainPanel("background2", bgPos, GuiContainer.Layer.overall, black60, 0.2f, 0, GuiContainer.Blur.greyout);

            //header
            Rectangle headerPos  = new Rectangle(710, 260, 500, 60, 1920, 1080, true);
            GuiText   headerText = new GuiText("Players found:", 20, white70);

            c.addText("header", headerPos, GuiContainer.Layer.overall, headerText, 0.2f, 0);

            //navigators
            if (page != 0)
            {
                //up
                Rectangle upPos = new Rectangle(945, 325, 30, 30, 1920, 1080, true);
                Action <BasePlayer, string[]> upCb = (p, a) =>
                {
                    SendPlayerSearchUI(player, results, callback, page - 1);
                };
                c.addButton("upbtn", upPos, GuiContainer.Layer.overall, white70, 0.2f, 0, callback: upCb, imgName: "triangle_up");
            }
            if (page != listOfLists.Count - 1)
            {
                //down
                Rectangle downPos = new Rectangle(945, 785, 30, 30, 1920, 1080, true);
                Action <BasePlayer, string[]> downCb = (p, a) =>
                {
                    SendPlayerSearchUI(player, results, callback, page + 1);
                };
                c.addButton("downbtn", downPos, GuiContainer.Layer.overall, white70, 0.2f, 0, callback: downCb, imgName: "triangle_down");
            }

            c.display(player);

            //entries
            int count    = 0;
            int sizeEach = 80;
            int gap      = 5;

            foreach (KeyValuePair <BasePlayer, PlayerSummary> kvp in listOfLists[page])
            {
                int    ccount    = count;
                int    csizeEach = sizeEach;
                int    cgap      = gap;
                Action imageCb   = () =>
                {
                    SendEntry(player, kvp, ccount, csizeEach, cgap, callback);
                };
                registerImage(PluginInstance, kvp.Key.UserIDString, kvp.Value.avatarfull, imageCb, true);
                count++;
            }
        }
Beispiel #15
0
        public void huntButton(BasePlayer player, Bounty bounty, huntErrorType error = huntErrorType.none)
        {
            GuiContainer c         = new GuiContainer(this, "huntButton", "bountyPreview");
            Rectangle    ButtonPos = new Rectangle(710, 856, 500, 100, resX, resY, true);

            List <GuiText> textOptions = new List <GuiText>
            {
                new GuiText("Start Hunting", guiCreator.getFontsizeByFramesize(13, ButtonPos), lightGreen),
                new GuiText("You are already hunting", guiCreator.getFontsizeByFramesize(23, ButtonPos), lightRed),
                new GuiText("Target is already being hunted", guiCreator.getFontsizeByFramesize(30, ButtonPos), lightRed),
                new GuiText("Target can't be hunted yet", guiCreator.getFontsizeByFramesize(26, ButtonPos), lightRed),
                new GuiText("Hunt Active", guiCreator.getFontsizeByFramesize(11, ButtonPos), lightRed),
                new GuiText("You can't hunt yourself!", guiCreator.getFontsizeByFramesize(24, ButtonPos), lightRed),
                new GuiText("Target is offline", guiCreator.getFontsizeByFramesize(17, ButtonPos), lightRed),
                new GuiText("Too close to the target!", guiCreator.getFontsizeByFramesize(24, ButtonPos), lightRed),
            };

            Action <BasePlayer, string[]> cb = (p, a) =>
            {
                TimeSpan targetCooldown   = TimeSpan.Zero;
                TimeSpan creationCooldown = new TimeSpan(0, 0, config.creationCooldown - (int)bounty.timeSinceCreation.TotalSeconds);
                if (error == huntErrorType.huntActive)
                {
                    return;
                }
                else if (bounty.target == null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.offline);
                }
                else if (bounty.target.IsSleeping())
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.offline);
                }
                else if (bounty.hunt != null || HuntData.getHuntByHunter(p) != null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.hunterAlreadyHunting);
                }
                else if (HuntData.getHuntByTarget(bounty.target) != null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.targetAlreadyHunted);
                }
                else if ((bounty.timeSinceCreation.TotalSeconds < config.creationCooldown || CooldownData.isOnCooldown(bounty.target, out targetCooldown)) && !hasPermission(player, permissions.admin))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.targetCooldown);
                    TimeSpan select = creationCooldown;
                    if (targetCooldown > creationCooldown)
                    {
                        select = targetCooldown;
                    }
                    player.ChatMessage($"Cooldown: {select.ToString(@"hh\:mm\:ss")}");
                }
                else if (bounty.target == player && !hasPermission(player, permissions.admin))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.selfHunt);
                }
                else if (Vector3.Distance(player.transform.position, bounty.target.transform.position) < config.safeDistance && !hasPermission(player, permissions.admin))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.tooClose);
                }
                else
                {
                    Effect.server.Run(successSound, player.transform.position);
                    bounty.startHunt(p);
                    BountyData.removeBounty(bounty.noteUid);
                    player.GetActiveItem()?.Remove();
                    closeBounty(player);
                }
            };

            c.addPlainButton("button", ButtonPos, GuiContainer.Layer.hud, (error == huntErrorType.none)?darkGreen:darkRed, FadeIn, FadeOut, textOptions[(int)error], cb, blur: GuiContainer.Blur.medium);
            c.display(player);

            if (error != huntErrorType.none && error != huntErrorType.huntActive)
            {
                PluginInstance.timer.Once(2f, () =>
                {
                    if (GuiTracker.getGuiTracker(player).getContainer(this, "bountyPreview") != null)
                    {
                        huntButton(player, bounty);
                    }
                });
            }
        }