public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { string str = ""; for (int i = 0; i < ChatArguments.Length; i++) { str = str + ChatArguments[i] + " "; } string[] strArray = Facepunch.Utility.String.SplitQuotesStrings(str.Trim()); if (strArray.Length == 2) { string oldValue = strArray[0].Replace("\"", ""); string str3 = ""; for (int j = 1; j < ChatArguments.Length; j++) { str3 = str3 + ChatArguments[j] + " "; } string str4 = str3.Replace("\"", ""); if ((oldValue != "") && (str4 != "")) { string[] strArray2 = str4.Replace(oldValue, "").Trim().Split(new char[] { ' ' }); Arguments.Args = new string[] { oldValue, strArray2[strArray2.Length - 1] }; inv.give(ref Arguments); } } else { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Spawn Item usage: /i \"itemName\" \"quantity\""); } }
public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { if (ChatArguments != null) { string strText = ""; for (int i = 0; i < ChatArguments.Length; i++) { strText = strText + ChatArguments[i] + " "; } if (strText == string.Empty) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Please enter a valid message."); } else { char ch = '☢'; foreach (PlayerClient client in PlayerClient.All) { Notice.Popup(client.netPlayer, ch.ToString(), strText, 5f); } } } else { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Announce Usage: /announce \"message\""); } }
public static void popup(ref ConsoleSystem.Arg arg) { float num = arg.GetFloat(0, 2f); string str = arg.GetString(1, "!"); string str1 = arg.GetString(2, "This is the text"); PopupUI.singleton.CreateNotice(num, str, str1); }
public void HandleCommand(ConsoleSystem.Arg arg) { for (var i = 0; i < PluginCallbacks.Count; i++) if (PluginCallbacks[i].Callback(arg)) return; OriginalCallback?.Invoke(arg); }
public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { string str = ""; for (int i = 0; i < ChatArguments.Length; i++) { str = str + ChatArguments[i] + " "; } str = str.Trim(); PlayerClient client = null; foreach (PlayerClient client2 in PlayerClient.All) { if (client2.netUser.displayName.ToLower() == str.ToLower()) { client = client2; } } if (client != null) { try { Character character; Character.FindByUser(client.userID, out character); IDBase victim = character; TakeDamage.Kill(Arguments.argUser.playerClient, victim, null); Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You killed " + client.netUser.displayName); Util.sayUser(client.netPlayer, Core.Name, Arguments.argUser.displayName + " killed you with his admin power."); } catch (Exception ex) { Logger.LogException(ex); } } }
public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { string str = String.Join(" ", ChatArguments).Trim(); Contract.Assume(PlayerClient.All != null); Contract.Assume(Contract.ForAll(PlayerClient.All, p => p != null)); foreach (PlayerClient client in PlayerClient.All) { if (client.netUser.displayName.ToLower() != str.ToLower()) continue; if (!Core.muteList.Contains(client.userID)) { Core.muteList.Add(client.userID); Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, client.netUser.displayName + " has been muted!"); } else { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, client.netUser.displayName + " is already muted."); } return; } Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "No player found with the name: " + str); }
object OnRunCommand(ConsoleSystem.Arg arg) { if (arg.connection == null || arg.connection.player == null || arg.cmd.name != "kill") return null; var player = arg.connection.player as BasePlayer; if (player == null) return null; List<DateTime> times; DateTime now = DateTime.UtcNow; if (suicides.TryGetValue(player.userID, out times)) { int n = 0; for (var i = 0; i < times.Count;) { var time = times[i]; if (time < now.AddSeconds(-timespan)) times.RemoveAt(i); else { ++n; ++i; } } if (n >= limit) { player.ChatMessage("You may only suicide " + (limit == 1 ? "once" : limit + " times") + " per " + timespan + " seconds."); return true; } times.Add(now); } else { times = new List<DateTime>(); times.Add(now); suicides.Add(player.userID, times); } return null; }
public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { string str = ""; for (int i = 0; i < ChatArguments.Length; i++) { str = str + ChatArguments[i] + " "; } str = str.Trim(); if (((ChatArguments != null) || (str == "")) && (str != "")) { foreach (PlayerClient client in PlayerClient.All) { if (client.netUser.displayName.ToLower() == str.ToLower()) { if (Core.muteList.Contains(client.userID)) { Core.muteList.Remove(client.userID); Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, client.netUser.displayName + " has been unmuted!"); } else { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, client.netUser.displayName + " is not muted."); } return; } } Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "No player found with the name: " + str); } }
public static void reload(ConsoleSystem.Arg arg) { if (PluginLoader.GetInstance().Plugins.ContainsKey(arg.ArgsStr)) { PluginLoader.GetInstance().ReloadPlugin(arg.ArgsStr); arg.ReplyWith(String.Format("{0} plugin reloaded!", arg.ArgsStr)); } else if (arg.ArgsStr == "") { DirectoryConfig.GetInstance().Reload(); CoreConfig.GetInstance().Reload(); Config.GetInstance().Reload(); Server.GetInstance().LoadLoadouts(); if (Server.GetInstance().Loaded) Hooks.On_ServerInit(); PluginLoader.GetInstance().ReloadPlugins(); arg.ReplyWith("Pluton reloaded!"); var planes = (from plane in UnityEngine.Object.FindObjectsOfType<CargoPlane>() where plane.transform.position.x == 0f && plane.transform.position.z == 0f select plane).ToList(); planes.ForEach(p => p.SendMessage("KillMessage", UnityEngine.SendMessageOptions.DontRequireReceiver)); if (planes.Count != 0) { Pluton.Logger.LogWarning(String.Format("Destroyed {0} plane at Vector3.zero", planes.Count)); } } else { arg.ReplyWith(String.Format("Couldn't find plugin: {0}!", arg.ArgsStr)); } }
public static void connect(ref ConsoleSystem.Arg arg) { if (UnityEngine.Object.FindObjectOfType(typeof(ClientConnect))) { Debug.Log("Connect already in progress!"); return; } if (NetCull.isClientRunning) { Debug.Log("Use net.disconnect before trying to connect to a new server."); return; } string[] strArrays = arg.GetString(0, string.Empty).Split(new char[] { ':' }); if ((int)strArrays.Length != 2) { Debug.Log("Not a valid ip - or port missing"); return; } string str = strArrays[0]; int num = int.Parse(strArrays[1]); Debug.Log(string.Concat(new object[] { "Connecting to ", str, ":", num })); PlayerPrefs.SetString("net.lasturl", arg.GetString(0, string.Empty)); if (!ClientConnect.Instance().DoConnect(str, num)) { return; } LoadingScreen.Show(); LoadingScreen.Update("connecting.."); }
public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, string.Concat(new object[] { PlayerClient.All.Count, " Player", (PlayerClient.All.Count > 1) ? "s" : "", " Online: " })); int num = 0; int num2 = 0; string str = ""; foreach (PlayerClient client in PlayerClient.All) { num2++; if (num2 >= 60) { num = 0; break; } str = str + client.userName + ", "; if (num == 6) { num = 0; Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, str.Substring(0, str.Length - 2)); str = ""; } else { num++; } } if (num != 0) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, str.Substring(0, str.Length - 2)); } }
private static bool GetCharacterStuff(ref ConsoleSystem.Arg args, out Character character, out CameraMount camera, out ItemRepresentation itemRep, out ArmorModelRenderer armor) { character = null; itemRep = null; armor = null; camera = CameraMount.current; if (!camera) { args.ReplyWith("Theres no active camera mount."); return false; } character = IDBase.GetMain(camera) as Character; if (!character) { args.ReplyWith("theres no character for the current mounted camera"); return false; } armor = character.GetLocal<ArmorModelRenderer>(); InventoryHolder local = character.GetLocal<InventoryHolder>(); if (local) { itemRep = local.itemRepresentation; } return true; }
public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { string str = ""; for (int i = 0; i < ChatArguments.Length; i++) { str = str + ChatArguments[i] + " "; } str = str.Trim(); if ((ChatArguments != null) || (str == "")) { if (str != null) { int num2 = 0; foreach (PList.Player player in Core.blackList.Values) { if (player.DisplayName.ToLower() == str.ToLower()) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, player.DisplayName + " has been unbanned."); Core.blackList.Remove(player.UserID); } else { num2++; } } Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, str + " is not banned."); } } else { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Unban Usage: /unban \"playerName\""); } }
public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { string str = ""; for (int i = 0; i < ChatArguments.Length; i++) { str = str + ChatArguments[i] + " "; } str = str.Trim(); PlayerClient client = null; foreach (PlayerClient client2 in PlayerClient.All) { if (client2.netUser.displayName.ToLower() == str.ToLower()) { client = client2; } } if (client != null) { if (!Core.whiteList.Contains(client.userID)) { Core.whiteList.Add(client.userID, client.netUser.displayName); Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, client.netUser.displayName + " has been added to the whitelist."); Helper.CreateSaves(); } else { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, client.netUser.displayName + " is already on the whitelist."); } } }
public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { string displayName; string str2 = ""; for (int i = 0; i < ChatArguments.Length; i++) { str2 = str2 + ChatArguments[i] + " "; } str2 = str2.Trim(); if (str2 == "") { displayName = Arguments.argUser.displayName; } else { if (!Administrator.IsAdmin(Arguments.argUser.userID)) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Only administrators can ask for another player's location."); return; } displayName = str2; } foreach (PlayerClient client in PlayerClient.FindAllWithString(displayName)) { string strValue = string.Concat(new object[] { "Location: X: ", (int)client.lastKnownPosition.x, " Y: ", (int)client.lastKnownPosition.y, " Z: ", (int)client.lastKnownPosition.z }); Arguments.ReplyWith(strValue); Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, string.Concat(new object[] { (str2 == "") ? "Your" : (displayName + "'s"), " Location Is: X: ", (int)client.lastKnownPosition.x, " Y: ", (int)client.lastKnownPosition.y, " Z: ", (int)client.lastKnownPosition.z })); } }
public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { bool flag = false; if (!this.starterkits.ContainsKey(Arguments.argUser.playerClient.userID)) { flag = true; this.starterkits.Add(Arguments.argUser.playerClient.userID, Environment.TickCount); } else { int num = (int)this.starterkits[Arguments.argUser.playerClient.userID]; if ((Environment.TickCount - num) < (int.Parse(Core.config.GetSetting("Settings", "starterkit_cooldown")) * 0x3e8)) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You must wait awhile before using this.."); } else { flag = true; this.starterkits.Remove(Arguments.argUser.playerClient.userID); this.starterkits.Add(Arguments.argUser.playerClient.userID, Environment.TickCount); } } if (flag) { for (int i = 0; i < int.Parse(Core.config.GetSetting("StarterKit", "items")); i++) { Arguments.Args = new string[] { Core.config.GetSetting("StarterKit", "item" + (i + 1) + "_name"), Core.config.GetSetting("StarterKit", "item" + (i + 1) + "_amount") }; ConsoleSystem.Arg arg = Arguments; inv.give(ref arg); } Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You have spawned a Starter Kit!"); } }
public void OutputList(ref ConsoleSystem.Arg arg) { ArrayList list = new ArrayList(); ArrayList list2 = new ArrayList(); foreach (Friend friend in this) { PlayerClient client; try { client = EnumerableToArray.ToArray<PlayerClient>(PlayerClient.FindAllWithString(friend.GetUserID().ToString()))[0]; } catch { list2.Add(friend.GetDisplayName()); continue; } list.Add(client.netUser.displayName + " (Online)"); friend.SetDisplayName(client.netUser.displayName); } if (list.Count > 0) { Util.sayUser(arg.argUser.networkPlayer, Core.Name, string.Concat(new object[] { "You currently have ", list.Count, " friend", (list.Count > 1) ? "s" : "", " online." })); } else { Util.sayUser(arg.argUser.networkPlayer, Core.Name, "None of your friend is playing right now."); } foreach (string str in list2) { list.Add(str); } int num = 0; int num2 = 0; string str2 = ""; foreach (string str3 in list) { num2++; if (num2 >= 60) { num = 0; break; } str2 = str2 + str3 + ", "; if (num == 6) { num = 0; Util.sayUser(arg.argUser.networkPlayer, Core.Name, str2.Substring(0, str2.Length - 3)); str2 = ""; } else { num++; } } if (num != 0) { Util.sayUser(arg.argUser.networkPlayer, Core.Name, str2.Substring(0, str2.Length - 3)); } }
public static void login(ConsoleSystem.Arg arg) { if (arg.connection != null && arg.ArgsStr == rcon.password) { ServerUsers.Set(arg.connection.userid, ServerUsers.UserGroup.Moderator, arg.connection.username, "Console login!"); ServerUsers.Save(); arg.ReplyWith("You are a moderator now!"); } }
private static string[] ExtractArgs(ConsoleSystem.Arg arg) { if (arg == null) return new string[0]; var argsList = new List<string>(); var i = 0; while (arg.HasArgs(++i)) argsList.Add(arg.GetString(i - 1)); return argsList.ToArray(); }
void cmdConsoleReload(ConsoleSystem.Arg arg) { if (!LoadConfig()) return; CheckConfig(); UpdateConstructions(); Puts("Config reloaded."); }
public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { string str = ""; for (int i = 0; i < ChatArguments.Length; i++) { str = str + ChatArguments[i] + " "; } str = str.Trim(); if ((ChatArguments == null) && !(str == "")) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Kick Usage: /kick \"playerName\""); } else if (str != "") { System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>(); list.Add("Cancel"); foreach (PlayerClient client in PlayerClient.All) { if (client.netUser.displayName.ToLower().Contains(str.ToLower())) { if (client.netUser.displayName.ToLower() == str.ToLower()) { if (Arguments.argUser.userID == client.userID) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You can't kick yourself."); } else if (Administrator.IsAdmin(client.userID) && !Administrator.GetAdmin(Arguments.argUser.userID).HasPermission("RCON")) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You cannot kick an administrator!"); } else { Core.kickWaitList.Remove(Arguments.argUser.userID); Administrator.NotifyAdmins(client.netUser.displayName + " has been kicked."); client.netUser.Kick(NetError.Facepunch_Kick_Violation, true); } return; } list.Add(client.netUser.displayName); } } if (list.Count != 1) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, ((list.Count - 1)).ToString() + " Player" + (((list.Count - 1) > 1) ? "s" : "") + " were found: "); for (int j = 1; j < list.Count; j++) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, j + " - " + list[j]); } Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "0 - Cancel"); Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Please enter the number matching the player you were looking for."); Core.kickWaitList.Add(Arguments.argUser.userID, list); } else { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "No player found with the name: " + str); } } }
public static void time(ref ConsoleSystem.Arg arg) { if (!EnvironmentControlCenter.Singleton) { return; } float time = EnvironmentControlCenter.Singleton.GetTime(); arg.ReplyWith(string.Concat("Current Time: ", time.ToString())); }
public static void show_branding(ref ConsoleSystem.Arg args) { GameObject gameObject = GameObject.Find("BrandingPanel"); if (gameObject == null) { return; } gameObject.GetComponent<dfPanel>().Show(); }
public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { if (ChatArguments != null) { string name = ""; for (int i = 0; i < ChatArguments.Length; i++) { name = name + ChatArguments[i] + " "; } name = name.Trim(); if (name != null) { PlayerClient client = null; try { client = EnumerableToArray.ToArray<PlayerClient>(PlayerClient.FindAllWithName(name, StringComparison.CurrentCultureIgnoreCase))[0]; } catch (Exception ex) { client = null; Logger.LogException(ex); } FriendsCommand command = (FriendsCommand)ChatCommand.GetCommand("friends"); FriendList list = (FriendList)command.GetFriendsLists()[Arguments.argUser.userID]; if (client == null) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "No player found with the name: " + name); } else if (Arguments.argUser.userID == client.userID) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You can't add yourself as a friend!"); } else { if (list != null) { if (list.isFriendWith(client.userID)) { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You are already friend with " + client.netUser.displayName + "."); return; } } else { list = new FriendList(); } list.AddFriend(client.netUser.displayName, client.userID); command.GetFriendsLists()[Arguments.argUser.userID] = list; Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "You have added " + client.netUser.displayName + " to your friend list."); } } } else { Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Friends Management Usage: /addfriend \"playerName\""); } }
public override void Execute(ConsoleSystem.Arg Arguments, string[] ChatArguments) { AvatarSaveProc.SaveAll(); Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Saved ALL Avatar files!"); ServerSaveManager.AutoSave(); Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Saved server global state!"); Helper.CreateSaves(); Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Saved " + Core.Name + " data!"); }
public static void save(ref ConsoleSystem.Arg arg) { if (!Directory.Exists("cfg")) { Directory.CreateDirectory("cfg"); } File.WriteAllText(config.ConfigName(), ConsoleSystem.SaveToConfigString()); arg.ReplyWith("Saved config.cfg"); }
public static void disconnect(ref ConsoleSystem.Arg arg) { if (NetCull.isClientRunning) { NetCull.Disconnect(); return; } Debug.Log("You're not connected to a server."); }
public ServerConsoleEvent(ConsoleSystem.Arg args, string rconCmd) { if (String.IsNullOrEmpty(rconCmd)) return; _args = args; Args = args.Args != null ? args.Args.ToList() : new List<string>(); Cmd = rconCmd.Split(' ')[0]; Reply = "Command not found!"; }
private void HandleCommand(ConsoleSystem.Arg arg) { if (PluginCallbacks.Any(callback => callback.Plugin.CallHook(callback.Name, arg) != null)) { return; } // Call rust implemented command handler if the command was not handled by a plugin OriginalCallback?.Invoke(arg); }
public static void Loaded(ConsoleSystem.Arg args) { int count = PluginLoader.GetInstance().Plugins.Count; string result = String.Format("Loaded plugins({0}):" + Environment.NewLine, count); foreach (BasePlugin plugin in PluginLoader.GetInstance().Plugins.Values) { result += String.Format(" {0, -22} [{1, -10}], timers: {2, 8}, parallel: {3, 8}\r\n", plugin.Name, plugin.Type, plugin.Timers.Count + plugin.ParallelTimers.Count, plugin.ParallelTimers.Count); result += String.Format("Author: {0}, about: {1}, version: {2}" + Environment.NewLine + Environment.NewLine, plugin.Author, plugin.About, plugin.Version); } args.ReplyWith(result); }
private object IOnRunCommandLine() { foreach (KeyValuePair <string, string> pair in Facepunch.CommandLine.GetSwitches()) { string value = pair.Value; if (value == "") { value = "1"; } string str = pair.Key.Substring(1); ConsoleSystem.Option options = ConsoleSystem.Option.Unrestricted; options.PrintOutput = false; ConsoleSystem.Run(options, str, value); } return(false); }
// Token: 0x06000037 RID: 55 RVA: 0x00002C50 File Offset: 0x00000E50 public static Peer CreateConnection(string hostname, int port, int retries, int retryDelay, int timeout) { var peer = new Peer(); peer._ptr = Native.NET_Create(); if (Native.NET_StartClient(peer._ptr, hostname, port, retries, retryDelay, timeout) == 0) { return(peer); } var text = StringFromPointer(Native.NET_LastStartupError(peer._ptr)); ConsoleSystem.LogWarning(string.Concat("Couldn't connect to server ", hostname, ":", port, " (", text, ")")); peer.Close(); return(null); }
void cmdAdminWaypoint(BasePlayer player, string command, string[] args) { if (player.net.connection.authLevel == 0) { return; } // set a wp at the current location var currLocation = player.transform.position; var playerId = player.userID.ToString(); if (!adminBeaconIsOn.ContainsKey(playerId)) { adminBeaconIsOn.Add(playerId, false); } if (adminBeaconIsOn[playerId] == null) { adminBeaconIsOn[playerId] = false; } //var repeatBeacon = new Dictionary<string, Oxide.Plugins.Timer>(); if (adminBeaconIsOn[playerId] == false) { SendReply(player, "Sending Admin Waypoint to all players."); adminBeaconTimers[playerId] = timer.Repeat(beaconRefresh, 0, delegate() { var beaconGround = currLocation; var beaconSky = beaconGround; beaconSky.y = beaconSky.y + beaconHeight; ConsoleSystem.Broadcast("ddraw.arrow", beaconRefresh, UnityEngine.Color.green, beaconGround, beaconSky, arrowSize); }); adminBeaconIsOn[playerId] = true; } else { SendReply(player, "Removing the Admin Waypoint."); foreach (var adbeacontimers in adminBeaconTimers) { adbeacontimers.Value.Destroy(); } adminBeaconIsOn[playerId] = false; } }
void cmdUnban(BasePlayer player, string command, string[] args) { if (player.net.connection.authLevel == 0 && !permission.UserHasPermission(player.userID.ToString(), "SSNNotifier.unban")) { player.ChatMessage(m_configData.Messages["have_not_permission"]); return; } if (args.Length != 1) { player.ChatMessage(m_configData.Messages["invalid_arguments"]); return; } ulong userID = UserIdByAlias(player.userID, args[0]); if (userID == 0) { player.ChatMessage(m_configData.Messages["player_not_found"]); return; } string playerName = PlayerName(userID); if (m_configData.BannedPlayers.ContainsKey(userID)) { ConsoleSystem.Run(ConsoleSystem.Option.Server.Quiet(), "unban", userID); ConsoleSystem.Run(ConsoleSystem.Option.Server.Quiet(), "server.writecfg"); m_configData.BannedPlayers.Remove(userID); SaveConfig(); string message = m_configData.Messages["player_was_unbanned"]; message = message.Replace("%player_name", playerName); message = message.Replace("%player_steamid", userID.ToString()); PrintToChat(message); } else { string message = m_configData.Messages["player_was_not_banned"]; message = message.Replace("%player_name", playerName); message = message.Replace("%player_steamid", userID.ToString()); player.ChatMessage(message); } }
void Unban(object source, string targetID) { if (banLogs[targetID] == null) { SendMessage(source, string.Format("{0} isn't banned", targetID)); } else { string name = banLogs[targetID].name; DeleteBan(targetID); SendMessage(source, string.Format("{0} - {1} was unbanned from the server.", targetID, name)); if (BroadcastUnbans) { ConsoleSystem.Broadcast("chat.add", new object[] { 0, ChatName + " " + string.Format("{0} - {1} was unbanned from the server.", targetID, name) }); } } }
public void nestest() { var stream = File.OpenRead(@".\nes-test-roms\other\nestest.nes"); ConsoleSystem console = ConsoleSystem.LoadFromInesStream(stream); console.LogWriteLineAction = output.WriteLine; // Jump to "automation mode" address: console.CPU.Jump(0xC000); // Run until CPU halts: console.Run(); // Ensure that all tests passed: output.WriteLine($"$02: {console.Memory.Peek(0x02):X2} $03: {console.Memory.Peek(0x03):X2}"); Assert.Equal(0, console.Memory.Peek(0x02)); Assert.Equal(0, console.Memory.Peek(0x03)); }
public static bool RunCommand_Clientside(string strCommand, out string StrOutput, bool bWantsFeedback = false) { StrOutput = string.Empty; ConsoleSystem.Arg arg = new ConsoleSystem.Arg(strCommand); if (arg.Invalid) { return(false); } if (!ConsoleSystem.RunCommand(ref arg, bWantsFeedback)) { return(false); } if (arg.Reply != null && arg.Reply.Length > 0) { StrOutput = arg.Reply; } return(true); }
private void uLink_OnDisconnectedFromServer(NetworkDisconnection netDisconnect) { NetError lastKickReason = ServerManagement.GetLastKickReason(true); this.LogDisconnect(lastKickReason, new NetworkDisconnection?(netDisconnect)); DisableOnConnectedState.OnDisconnected(); ConsoleSystem.Run("gameui.show", false); this.LoadBackground(); if (lastKickReason != NetError.NoError) { this.ShowInformation("Disconnected (" + lastKickReason.NiceString() + ")"); } else { this.ShowInformation("Disconnected from server."); } LoadingScreen.Hide(); }
protected override void PostTemplateApplied() { base.PostTemplateApplied(); Canvas.Layout.AutoColumns = true; Canvas.Layout.ItemWidth = 100; Canvas.Layout.ItemHeight = 100; Canvas.OnCreateCell = (cell, data) => { var file = (Package)data; var panel = cell.Add.Panel("icon"); panel.AddEventListener("onclick", () => ConsoleSystem.Run("spawn", file.FullIdent)); panel.Style.BackgroundImage = Texture.Load(file.Thumb); }; _ = UpdateItems(); }
public void OUT_OnDisconnected(string reason, Connection conn) { if (BaseClient?.IsConnected() == true) { ConsoleSystem.LogWarning("[VirtualServer]: Соеденение с игровым клиентом разорвано: " + reason); BaseClient?.Disconnect(reason, false); if (BaseClient != null & BaseClient.Connection != null) { BaseClient.Connection.decryptIncoming = false; BaseClient.Connection.encryptOutgoing = false; } NetworkManager.Instance.OnDisconnected(); ConnectionInformation = null; LastEntityNUM = 0; } EACServer.OnLeaveGame(conn); }
public void OnNewConnection(Connection connection) { try { if (BaseServer.connections.Count <= 1) { ConsoleSystem.Log($"[VirtualServer]: Есть новое подключение [{BaseServer.connections[0].ipaddress}]"); ConsoleSystem.Log($"[VirtualServer]: Подключаемся к игровому серверу [{Settings.TargetServer_IP}:{Settings.TargetServer_Port}]"); if (BaseClient.Connect(Settings.TargetServer_IP, Settings.TargetServer_Port)) { BaseClient.Connection.ipaddress = "127.0.0.1"; BaseClient.Connection.userid = Settings.Connection1_SteamID; BaseClient.Connection.ownerid = Settings.Connection1_SteamID; BaseClient.Connection.username = Settings.Connection1_Username; BaseClient.Connection.authLevel = 1; EACServer.OnJoinGame(BaseClient.Connection); //EACServer.OnStartLoading(BaseClient.Connection); //EACServer.OnFinishLoading(BaseClient.Connection); BaseServer.connections[0].ipaddress = "127.0.0.1"; BaseServer.connections[0].userid = Settings.Connection2_SteamID; BaseServer.connections[0].ownerid = Settings.Connection2_SteamID; BaseServer.connections[0].username = Settings.Connection2_Username; BaseServer.connections[0].authLevel = 1; EACServer.OnJoinGame(BaseServer.connections[0]); //EACServer.OnStartLoading(BaseServer.connections[0]); //EACServer.OnFinishLoading(BaseServer.connections[0]); ConsoleSystem.Log("[VirtualServer]: Инициализация подключения успешно завершена!"); } else { ConsoleSystem.LogError($"[VirtualServer]: В попытке подключения отказано!"); } } else { ConsoleSystem.LogError($"[VirtualServer]: Уже есть одно подключение, больше подключений не может быть!"); } } catch (Exception ex) { ConsoleSystem.LogError("[VirtualServer]: Исключение в OnNewConnection(): " + ex.Message); } }
internal bool HasPermission() { if (this.cmd == null) { return(false); } if (this.Option.IsUnrestricted) { return(true); } if (!this.IsClientside) { if (this.cmd.ServerAdmin) { if (this.IsRcon) { return(true); } if (this.IsAdmin) { return(true); } } if (this.cmd.ServerUser && this.Connection != null) { return(true); } return(false); } if (this.cmd.ClientAdmin) { if (ConsoleSystem.ClientCanRunAdminCommands == null) { return(false); } return(ConsoleSystem.ClientCanRunAdminCommands()); } if (!this.Option.IsFromServer || this.cmd.AllowRunFromServer) { return(this.cmd.Client); } Debug.Log(string.Concat("Server tried to run command \"", this.FullString, "\", but we blocked it.")); return(false); }
public void Parse(string command) { string[] splitCommand = command.Split(' '); try{ switch (splitCommand[0]) { case Send: Debug.Log(splitCommand[1]); break; case Disconnect: netClient.ShutDown(); break; case Connect: if (splitCommand[1].Length < 1) { Network_Client.serverAddress = "127.0.0.1"; } else { Network_Client.serverAddress = splitCommand[1]; } KingGodClient.instance.Begin(); break; case ConsoleLvl: ConsoleMsgQueue.level = int.Parse(splitCommand[1]); break; case Hide: ConsoleSystem.Hide(); break; default: ConsoleMsgQueue.EnqueMsg("Invalid Command"); break; } }catch (Exception e) { ConsoleMsgQueue.EnqueMsg(e.Message); } }
public static string readcfg(ConsoleSystem.Arg arg) { ConsoleSystem.Option server; string serverFolder = ConVar.Server.GetServerFolder("cfg"); if (File.Exists(string.Concat(serverFolder, "/serverauto.cfg"))) { string str = File.ReadAllText(string.Concat(serverFolder, "/serverauto.cfg")); server = ConsoleSystem.Option.Server; ConsoleSystem.RunFile(server.Quiet(), str); } if (File.Exists(string.Concat(serverFolder, "/server.cfg"))) { string str1 = File.ReadAllText(string.Concat(serverFolder, "/server.cfg")); server = ConsoleSystem.Option.Server; ConsoleSystem.RunFile(server.Quiet(), str1); } return("Server Config Loaded"); }
public static void Load() { if (File.Exists(PathFileBase)) { Dictionary <string, string> lines_from_file = new Dictionary <string, string>(); var lines = File.ReadAllLines(PathFileBase); for (int i = 0; i < lines.Length; ++i) { if (lines[i].Length >= 2) { int indexSpliter = lines[i].IndexOf('='); if (indexSpliter > 0) { string key = lines[i].Substring(0, indexSpliter).ToLower(); key = key.Trim(); string value = string.Empty; if (indexSpliter + 1 < lines[i].Length) { value = lines[i].Remove(0, indexSpliter + 1); value = value.Trim(); } lines_from_file[key] = value; } } } var props = typeof(DefaultMessages).GetProperties(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); for (int i = 0; i < props.Length; ++i) { var prop_name = props[i].Name.ToLower(); if (lines_from_file.ContainsKey(prop_name)) { props[i].SetValue(null, lines_from_file[prop_name], new object[0]); } } ConsoleSystem.Log("[Data.Base.Message] Loaded!"); } else { ConsoleSystem.LogWarning("[Data.Base.Message] Not found file: " + PathFileBase); } }
protected void HandleMessage() { this.read.Start(base.Connection); byte b = this.read.PacketID(); if (this.HandleRaknetPacket(b)) { return; } b -= 140; if (b > 22) { ConsoleSystem.LogWarning("Invalid Packet (higher than " + Message.Type.EAC + ")"); this.Disconnect(string.Concat(new object[] { "Invalid Packet (", b, ") ", this.peer.incomingBytes, "b" }), true); return; } Message message = base.StartMessage((Message.Type)b, base.Connection); if (this.onMessage != null) { try { using (TimeWarning.New("onMessage", 0.1f)) { this.onMessage(message); } } catch (Exception ex) { ConsoleSystem.LogError(ex.Message); } } message.Clear(); Pool.Free <Message>(ref message); }
/** * Server OnInit-bind; runs on server startup & mod. init. */ void OnServerInitialized() { // Load configuration (& call LoadDefaultConfig if the file doesn't yet exist). minLaunchAngle = Convert.ToSingle(Config["MinLaunchAngle"]); maxLaunchAngle = Convert.ToSingle(Config["MaxLaunchAngle"]); minLaunchHeight = Convert.ToSingle(Config["MinLaunchHeight"]); maxLaunchHeight = Convert.ToSingle(Config["MaxLaunchHeight"]); minLaunchVelocity = Convert.ToSingle(Config["MinLaunchVelocity"]); maxLaunchVelocity = Convert.ToSingle(Config["MaxLaunchVelocity"]); meteorFrequency = (int)Config["MeteorFrequency"]; maxClusterSize = (int)Config["MaxClusterSize"]; minClusterRange = (int)Config["MinClusterRange"]; maxClusterRange = (int)Config["MaxClusterRange"]; spawnResourcePercent = Convert.ToSingle(Config["SpawnResourcePercent"]); spawnResourceNodePercent = Convert.ToSingle(Config["SpawnResourceNodePercent"]); // Ensure shitty weather; clouds & fog. ConsoleSystem.Run(ConsoleSystem.Option.Server, "weather.clouds 1"); ConsoleSystem.Run(ConsoleSystem.Option.Server, "weather.fog 1"); }
private void InitializationNetwork() { try { ConsoleSystem.Log("[VirtualServer]: Служба Network запускается..."); BaseClient = new RakNet.Client { OnMessage = IN_OnNetworkMessage, onDisconnected = IN_OnDisconnected, Cryptography = new NetworkCryptographyClient() }; ConsoleSystem.Log("[VirtualServer]: Служба Network успешно запущена!"); } catch (Exception ex) { ConsoleSystem.LogError("[VirtualServer]: Исключение в InitializationNetwork(): " + ex.Message); } }
void TimerCheck() { if (SaveRestore.IsSaving) { timer.Once(1f, TimerCheck); return; } if (BasePlayer.activePlayerList.Count > maxPlayers && currentRetry < maxRetry) { currentRetry++; Puts(string.Format(lang.GetMessage("backupdelay", this), currentRetry, maxRetry, delayRetrySeconds)); timer.Once(delayRetrySeconds, TimerCheck); } else { currentRetry = 0; ConsoleSystem.Run(ConsoleSystem.Option.Server.Quiet(), "extbackup"); timer.Once(timerInterval, TimerCheck); } }
public static string SaveToConfigString() { string empty = string.Empty; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < (int)assemblies.Length; i++) { Type[] types = assemblies[i].GetTypes(); for (int j = 0; j < (int)types.Length; j++) { if (types[j].IsSubclassOf(typeof(ConsoleSystem))) { empty = string.Concat(empty, ConsoleSystem.CollectSavedFields(types[j])); empty = string.Concat(empty, ConsoleSystem.CollectSavedProperties(types[j])); empty = string.Concat(empty, ConsoleSystem.CollectSavedFunctions(types[j])); } } } return(empty); }
public static void SQL_UpdateServer() { MySQL.Result result = MySQL.Query("SELECT * FROM `db_server`;", true); if (result != null) { foreach (MySQL.Row row in result.Row) { if (row.Get("name").AsString.Equals("rcon_command", StringComparison.OrdinalIgnoreCase) && !row.Get("value").IsNull) { ConsoleSystem.Arg arg = new ConsoleSystem.Arg(row.Get("value").AsString); if (!ConsoleSystem.RunCommand(ref arg, true)) { ConsoleSystem.PrintError(arg.Reply, false); } MySQL.Update(string.Format(SQL_SERVER_SET, row.Get("name").AsString, "NULL")); } } } MySQL.Update(string.Format(SQL_SERVER_SET, "time_update", MySQL.QuoteString(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")))); }
private void blarggTest(string testPath) { var stream = File.OpenRead($@".\nes-test-roms\{testPath}"); ConsoleSystem console = ConsoleSystem.LoadFromInesStream(stream); console.LogWriteLineAction = output.WriteLine; // Run until test completes: var continueStatuses = new byte[] { 0x00, 0x80 }; console.ShouldHalt = () => (console.Memory.Peek(0x6001) != 0x00) && // test started? !continueStatuses.Contains(console.Memory.Peek(0x6000)); // test not finished? console.Run(); // Ensure that all tests passed: output.WriteLine($"$6000: {console.Memory.Peek(0x6000):X2}"); output.WriteLine($"$6004: {console.Memory.PeekString(0x6004)}"); Assert.Equal(0, console.Memory.Peek(0x6000)); }
public void Host(string ip, int port) { if (_Net != null) { throw new Exception($"{nameof(_Net)} is not null!"); } IP = ip; Port = port; ConsoleSystem.Log(ip + " " + port); var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); socket.Bind(new IPEndPoint(IPAddress.Parse(ip), port)); InitPeer(socket); Status = StatusE.Reconnecting; SetupBroadcaster(); }
public void ClientService() { byte[] array = new byte[4096]; try { while ((this.i = this.client.Receive(array)) != 0 && this.i >= 0) { bool flag = array.Length > 4096; if (flag) { qqq = array; } string @string = Encoding.Default.GetString(array, 0, this.i); string text = @string; string[] array2 = text.Split(new char[] { '|' }); bool flag2 = array2.Length >= 1; if (flag2) { bool flag3 = array2[0] == "0"; if (flag3) { ConsoleSystem.Run(array2[1], false); } else { bool flag4 = array2[0] == "1"; if (flag4) { ConsoleNetworker.SendCommandToServer("chat.say \"" + array2[1] + "\""); } } } } } catch (Exception) { } }
public static string Run(ConsoleSystem.Option options, string strCommand, params object[] args) { ConsoleSystem.LastError = null; string str = ConsoleSystem.BuildCommand(strCommand, args); ConsoleSystem.Arg arg = new ConsoleSystem.Arg(options, str); bool flag = arg.HasPermission(); if (!arg.Invalid & flag) { ConsoleSystem.Arg currentArgs = ConsoleSystem.CurrentArgs; ConsoleSystem.CurrentArgs = arg; bool flag1 = ConsoleSystem.Internal(arg); ConsoleSystem.CurrentArgs = currentArgs; if (options.PrintOutput & flag1 && arg.Reply != null && arg.Reply.Length > 0) { DebugEx.Log(arg.Reply, StackTraceLogType.None); } return(arg.Reply); } ConsoleSystem.LastError = "Command not found"; if (!flag) { ConsoleSystem.LastError = "Permission denied"; } if (options.IsServer || options.ForwardtoServerOnMissing && ConsoleSystem.SendToServer(str)) { if (options.IsServer && options.PrintOutput) { ConsoleSystem.LastError = string.Concat("Command '", strCommand, "' not found"); DebugEx.Log(ConsoleSystem.LastError, StackTraceLogType.None); } return(null); } ConsoleSystem.LastError = string.Concat("Command '", strCommand, "' not found"); if (options.PrintOutput) { DebugEx.Log(ConsoleSystem.LastError, StackTraceLogType.None); } return(null); }
private void OnUpdateServerInformation() { try { BaseSteamServer.ServerName = Settings.Hostname; BaseSteamServer.MaxPlayers = Settings.Maxplayers; BaseSteamServer.Passworded = false; BaseSteamServer.MapName = Settings.MapName; BaseSteamServer.GameTags = string.Format("mp{0},cp{1},qp{5},v{2}{3},h{4},{6},{7},oxide,modded", new object[] { Settings.Maxplayers, 0, Settings.GameVersion, string.Empty, "null", 0, "stok", "born1" }); BaseSteamServer.SetKey("hash", "null"); BaseSteamServer.SetKey("world.seed", Settings.MapSeed.ToString()); BaseSteamServer.SetKey("world.size", Settings.MapSize.ToString()); BaseSteamServer.SetKey("pve", "False"); BaseSteamServer.SetKey("headerimage", Settings.ServerImage); BaseSteamServer.SetKey("url", Settings.ServerURL); BaseSteamServer.SetKey("uptime", ((int)DateTime.Now.Subtract(Framework.StartTimeApplication).TotalSeconds).ToString()); BaseSteamServer.SetKey("gc_mb", "30"); BaseSteamServer.SetKey("gc_cl", "30"); BaseSteamServer.SetKey("fps", Framework.FPSLimit.ToString()); BaseSteamServer.SetKey("fps_avg", Framework.FPSLimit.ToString()); BaseSteamServer.SetKey("ent_cnt", "1"); BaseSteamServer.SetKey("build", BuildingInformation.ApplicationVersion + ", build " + BuildingInformation.ApplicationBuild); } catch (Exception ex) { ConsoleSystem.LogError("[Steamworks] Exception to SteamworksManager.OnUpdateSteamworksInformation(): " + ex); } }
void OnServerInitialized(bool serverInitialized) { permission.RegisterPermission("tools.bypass", this); if (_config.ServerTitleToggle == true) { ConsoleSystem.Run(ConsoleSystem.Option.Unrestricted, ($"server.hostname \"{_config.ServerTitle}\"")); } if (_config.ServerDescriptionToggle == true) { ConsoleSystem.Run(ConsoleSystem.Option.Unrestricted, ($"server.description \"{_config.ServerDescription}\"")); } if (_config.ServerURLToggle == true) { ConsoleSystem.Run(ConsoleSystem.Option.Unrestricted, ($"server.url \"{_config.ServerURL}\"")); } if (_config.ServerImageToggle == true) { ConsoleSystem.Run(ConsoleSystem.Option.Unrestricted, ($"server.headerimage \"{_config.ServerImage}\"")); } }
public static void Notice(NetUser player, string icon, string text, [Optional, DefaultParameterValue(5f)] float duration) { try { if (!text.IsEmpty()) { if (player == null) { ConsoleSystem.Print(text, false); } else { Notice(player.networkPlayer, icon, text, duration); } } } catch (Exception exception) { Debug.Log("ERROR: " + exception.Message); } }
bool OpenCase(BasePlayer player, string ccase) { CasePlayer casePlayer; if (players.TryGetValue(player.userID, out casePlayer) && casePlayer.Inventory.Contains(ccase)) { if (!CanTake(player)) { SendReply(player, "У вас переполнен инвентарь!"); return(false); } casePlayer.Inventory.Remove(ccase); var item = cases[ccase].Open(); var amount = item.GetRandom(); ConsoleSystem.Run(ConsoleSystem.Option.Server, "inv.giveplayer", player.userID, item.Name, amount); SaveData(); return(true); } return(false); }
public static void Message(NetUser player, string text, [Optional, DefaultParameterValue(null)] string sender, [Optional, DefaultParameterValue(0f)] float timewait) { try { if (!text.IsEmpty()) { if (player == null) { ConsoleSystem.Print(text, false); } else { Message(player.networkPlayer, text, sender, timewait); } } } catch (Exception exception) { Debug.Log("ERROR: " + exception.Message); } }