public InputFieldComponent OnTextChange(Action <string> callback, RustPlugin plugin) { var cmd = (Game.Rust.Libraries.Command)plugin.GetType().GetField("cmd", BindingFlags.Instance).GetValue(plugin); cmd.AddConsoleCommand($"gui_input_change_${_inputFieldNum}", plugin, (args) => { callback.Invoke(args.GetString(0)); OnStateChanged(args.Player()); return(true); }); _inputFieldNum++; return(this); }
public ButtonComponent OnClick(Action <BasePlayer> callback, RustPlugin plugin) { var cmd = (Game.Rust.Libraries.Command)plugin.GetType().GetField("cmd", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(plugin); var commandName = $"gui_button_click_${_buttonNum}"; Command = commandName; cmd.AddConsoleCommand(commandName, plugin, args => { callback?.Invoke(args.Player()); return(true); }); _buttonNum++; return(this); }
void OnPluginLoaded(object plugin) { if (plugin.GetType().BaseType == typeof(RustPlugin)) { RustPlugin rustPlugin = (RustPlugin)plugin; if (rustPlugin.Title == "Friends") { FriendsAPI = rustPlugin; } if (rustPlugin.Title == "Clans") { Clans = rustPlugin; } } }
public static void setupDatabase(RustPlugin plugin) { sqlConnection = sqlite.OpenDb($"Plagued.db", plugin); var sql = new Oxide.Core.Database.Sql(); sql.Append(@"CREATE TABLE IF NOT EXISTS players ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id TEXT UNIQUE NOT NULL, name TEXT, plague_level INTEGER, kin_changes_count INTEGER, pristine INTEGER );"); sql.Append(@"CREATE TABLE IF NOT EXISTS associations ( id INTEGER PRIMARY KEY AUTOINCREMENT, player_id integer NOT NULL, associate_id integer NOT NULL, level INTEGER, FOREIGN KEY (player_id) REFERENCES players(id), FOREIGN KEY (associate_id) REFERENCES players(id) );"); sql.Append(@"CREATE TABLE IF NOT EXISTS kin ( self_id integer NOT NULL, kin_id integer NOT NULL, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (self_id) REFERENCES players(id), FOREIGN KEY (kin_id) REFERENCES players(id), PRIMARY KEY (self_id,kin_id) );"); sql.Append(@"CREATE TABLE IF NOT EXISTS kin_request ( requester_id integer NOT NULL, target_id integer NOT NULL, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (requester_id) REFERENCES players(id), FOREIGN KEY (target_id) REFERENCES players(id), PRIMARY KEY (requester_id,target_id) );"); sqlite.Insert(sql, sqlConnection); }
/** * Called when specified plugin has been loaded */ private void OnPluginLoaded(RustPlugin pluginName) { string epicLanterns = "Oxide.Plugins.EpicLanterns"; if (epicLanterns.Equals(pluginName.GetType().Name)) { this._isLoaded = true; if (this._isInitialized) { this.createLanternsCache(); // Calculate correct lanters state int currentTime = Convert.ToInt16(Math.Floor(TOD_Sky.Instance.Cycle.Hour)); // Toggle on, because it is after time to turn on all lanterns if (currentTime >= (int)Config["toggleOnAt"]) { echo("Lanterns should light up."); this._areTurnedOn = true; } // Toggle off, because it is after time to turn off all lanterns, but before time to turn them on else if (currentTime >= (int)Config["toggleOffAt"] && currentTime < (int)Config["toggleOnAt"]) { echo("Lanterns should not light up."); this._areTurnedOn = false; } // If none of the above did not work, it means that currently it is time between toggling on and toggling off, so turn them on else if (currentTime < (int)Config["toggleOffAt"]) { echo("Lanterns should light up."); this._areTurnedOn = true; } // Apply current state to all lanterns smartToggleLanterns(); } } }
//////////////////////////////////////// /// On Plugin Loaded //////////////////////////////////////// void Loaded() { FriendsAPI = (RustPlugin)plugins.Find("Friends"); Clans = (RustPlugin)plugins.Find("Clans"); LoadMessages(); LoadConfig(); if (FriendsAPI == null) { PrintError($"FriendsAPI could not be found! You need to have FriendsAPI installed for the plugin '{this.Title}' to work! Get it here: http://oxidemod.org/plugins/686/"); } if (Clans == null) { PrintWarning($"Clans could not be found! Clans is an OPTIONAL addition for '{this.Title}'! Get it here: http://oxidemod.org/plugins/842/"); } if (Config["Settings", "Block Damage"] != null) { blockDamage = (bool)Config["Settings", "Block Damage"]; } }
public void RemoveOnClick(RustPlugin plugin) { var cmd = (Game.Rust.Libraries.Command)plugin.GetType().GetField("cmd", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(plugin); cmd.RemoveConsoleCommand(Command, plugin); }
public GUILibrary() { Owner = this; }