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()); }
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); }
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); }
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(); } }
/// <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(); }
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); }
/// <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(); }
public static void Main(string[] args) => UServer.Initialization();