Exemplo n.º 1
0
        private CommandResult ShutdownCommand(ICommandSource src, ICommandArgs args)
        {
            int delay = 0;

            if (args.Length > 0)
            {
                if (!args[0].IsInt)
                {
                    return(CommandResult.Lang("INVALID_NUMBER", args[0]));
                }
                else if ((delay = args[0].ToInt) < 0)
                {
                    delay = 0;
                }
            }
            // Will only send the messages if delay > 0
            if (delay > 0)
            {
                if (args.Length > 1)
                {
                    UServer.Broadcast(args.Join(1)); // Broadcast <reason>
                }
                EssLang.Send(src, "SHUTDOWN_DELAY_SENDER", TimeUtil.FormatSeconds((uint)delay));
            }
            Provider.shutdown(delay);
            return(CommandResult.Success());
        }
Exemplo n.º 2
0
        public void Broadcast(params object[] replacers)
        {
            var message = _message.Clone() as string;
            var color   = ColorUtil.GetColorFromString(ref message);

            UServer.Broadcast(replacers == null
                               ? message
                               : string.Format(message, replacers), color);
        }
Exemplo n.º 3
0
        public static void Broadcast(string key, params object[] args)
        {
            var   message = Translate(key, args);
            Color color;

            if (message == null)
            {
                color   = Color.red;
                message = string.Format(KEY_NOT_FOUND_MESSAGE, key);
            }
            else
            {
                color = ColorUtil.GetColorFromString(ref message);
            }

            UServer.Broadcast(message, color);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Start broadcasting
        /// </summary>
        public void Start()
        {
            var messageIndex = 0;
            var rand         = new Random();

            Tasks.New(t => {
                var messagesCount = Messages.Count;

                messageIndex = RandomMessages
                    ? rand.Next(messagesCount)
                    : (++messageIndex == messagesCount ? 0 : messageIndex);

                var message      = (string)Messages[messageIndex].Clone();
                var messageColor = ColorUtil.GetColorFromString(ref message);

                UServer.Broadcast(message, messageColor);
            }).Delay(MessageInterval * 1000).Interval(MessageInterval * 1000).Go();
        }
Exemplo n.º 5
0
        private void DeathMessages(UnturnedPlayer player, EDeathCause cause, ELimb limb, CSteamID killer)
        {
            if (!(EssLang.GetEntry($"DEATH_{cause}") is string message))
            {
                return;
            }

            var hasKiller = killer != CSteamID.Nil;
            var arguments = new object[hasKiller ? 3 : 2];
            var color     = ColorUtil.GetColorFromString(ref message);

            arguments[0] = player.CharacterName;
            arguments[1] = EssLang.Translate($"LIMB_{limb}") ?? "?";
            if (hasKiller)
            {
                arguments[2] = UPlayer.From(killer)?.CharacterName ?? "?";
            }

            UServer.Broadcast(string.Format(message, arguments), color);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Start broadcasting
        /// </summary>
        public void Start()
        {
            var messageIndex = 0;
            var rand         = RandomMessages ? new Random() : null;

            Task.Create()
            .Id("AutoMessage Executor")
            .Interval(TimeSpan.FromSeconds(Interval))
            .UseIntervalAsDelay()
            .Action(() => {
                messageIndex = RandomMessages
                        ? rand.Next(Messages.Count)
                        : (++messageIndex == Messages.Count ? 0 : messageIndex);

                var message      = (string)Messages[messageIndex].Clone();
                var messageColor = ColorUtil.GetColorFromString(ref message);

                UServer.Broadcast(message, messageColor);
            })
            .Submit();
        }