コード例 #1
0
            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);
            }
コード例 #2
0
            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);
            }
コード例 #3
0
        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;
                }
            }
        }
コード例 #4
0
            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);
            }
コード例 #5
0
ファイル: EpicLanterns.cs プロジェクト: wilddip/oxideplugins
        /**
         *  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();
                }
            }
        }
コード例 #6
0
        ////////////////////////////////////////
        ///     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"];
            }
        }
コード例 #7
0
            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);
            }
コード例 #8
0
ファイル: GUILibrary.cs プロジェクト: romgerman/CGUI
 public GUILibrary()
 {
     Owner = this;
 }