コード例 #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());
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #4
0
 public GamepadServer()
 {
     try
     {
         jc = new AndroidJavaClass("org.unity.UnityAPIBridge");
     }
     catch (Exception)
     {
         //如果加载sdk失败,则启动脚本Server,且实例化对应的解包器
         uServer = new UServer();
         kServer = new KServer(3899)
         {
             OnReciveCallBack = OnReciveMessage
         };
         packager = new CShaperPackager();
     }
 }
コード例 #5
0
ファイル: AutoAnnouncer.cs プロジェクト: demiit/uEssentials
        /// <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();
        }
コード例 #6
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);
        }
コード例 #7
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();
        }
コード例 #8
0
ファイル: Bootstrap.cs プロジェクト: dogfood1/UServer3
 public static void Main(string[] args) => UServer.Initialization();