コード例 #1
0
        void sil(BasePlayer player, string command, string[] args)
        {
            if (args.Length == 0)
            {
                player.ChatMessage(Syntax);
                return;
            }

            if (!HasPerm(player, "signartist.url"))
            {
                player.ChatMessage(NoPerm);
                return;
            }

            float cd;

            if (CoolDowns.TryGetValue(player, out cd) && cd > Time.realtimeSinceStartup && !HasPerm(player, "signartist.cd"))
            {
                player.ChatMessage(string.Format(CooldownMsg, ToReadableString(cd - Time.realtimeSinceStartup)));
                return;
            }

            RaycastHit hit;
            Signage    sign = null;

            if (Physics.Raycast(player.eyes.HeadRay(), out hit, MaxDist))
            {
                sign = hit.transform.GetComponentInParent <Signage>();
            }

            if (sign == null)
            {
                player.ChatMessage(NoSignFound);
                return;
            }

            if (!sign.CanUpdateSign(player) && !HasPerm(player, "signartist.owner"))
            {
                player.ChatMessage(NotYourSign);
                return;
            }

            var raw = args.Length > 1 && args[1].Equals("raw", StringComparison.OrdinalIgnoreCase);

            if (raw && !HasPerm(player, "signartist.raw"))
            {
                player.ChatMessage(NoPerm);
                return;
            }
            UWeb.Add(args[0], player, sign, raw);
            player.ChatMessage(AddedToQueue);
            if (UrlCooldown > 0)
            {
                CoolDowns[player] = Time.realtimeSinceStartup + UrlCooldown;
            }
        }
コード例 #2
0
        void silt(BasePlayer player, string command, string[] args)
        {
            if (args.Length == 0)
            {
                player.ChatMessage(Syntax);
                return;
            }

            if (!HasPerm(player, "signartist.url"))
            {
                player.ChatMessage(NoPerm);
                return;
            }

            float cd;

            if (CoolDowns.TryGetValue(player, out cd) && cd > Time.realtimeSinceStartup && !HasPerm(player, "signartist.cd"))
            {
                player.ChatMessage(string.Format(CooldownMsg, ToReadableString(cd - Time.realtimeSinceStartup)));
                return;
            }

            RaycastHit hit;
            Signage    sign = null;

            if (Physics.Raycast(player.eyes.HeadRay(), out hit, MaxDist))
            {
                sign = hit.transform.GetComponentInParent <Signage>();
            }

            if (sign == null)
            {
                player.ChatMessage(NoSignFound);
                return;
            }

            if (!sign.CanUpdateSign(player) && !HasPerm(player, "signartist.owner"))
            {
                player.ChatMessage(NotYourSign);
                return;
            }

            var raw = args.Length > 1 && args[1].Equals("raw", StringComparison.OrdinalIgnoreCase);

            if (raw && !HasPerm(player, "signartist.raw"))
            {
                player.ChatMessage(NoPerm);
                return;
            }
            string txt      = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(args[0])).TrimEnd('=');
            int    textSize = 80;
            string txtClr   = "000";
            string bg       = "0FFF";

            if (args.Length > 2)
            {
                int.TryParse(args[2], out textSize);
            }
            if (args.Length > 3)
            {
                txtClr = args[3];
            }
            if (args.Length > 4)
            {
                bg = args[4];
            }
            var width  = (int)Math.Round(100 * sign.bounds.size.x * .9);
            var height = (int)Math.Round(100 * sign.bounds.size.y * .9);
            var url    = $"http://placeholdit.imgix.net/~text?fm=png32&txtsize={textSize}&txt64={txt}&w={width}&h={height}&txtclr={txtClr}&bg={bg}";

            UWeb.Add(url, player, sign, raw);
            SendReply(player, AddedToQueue);
            if (UrlCooldown > 0)
            {
                CoolDowns[player] = Time.realtimeSinceStartup + UrlCooldown;
            }
        }