1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  1. Hey, i'm new to coding with C# but have quite a bit of r-lua experience. ( About 2 years) And I wanted to get into modding in rust, I'am currently attempting to make a furnace generate pookies ( For a event ). But when i attempt to create the pookies that work's fine. After i attempt to put them in a furnace it tells me the OnConsumeFuel hook failed to call. Any help would be greatly appreciated

    Heres my code so far. ( Please don't give me a entire answer to how to make it generate them. Just hint me somewhere please )
    Code:
    using System.Collections.Generic;
    using System;
    using Newtonsoft.Json;
    using Oxide.Core.Plugins;
    using Oxide.Core.Configuration;
    using System.Linq;
    
    namespace Oxide.Plugins
    {
        [Info("FurnaceModifier", "CasperYep", "0.0.1")]
        [Description("Generates pookies from furnaces,")]
    
        public partial class FurnaceModifier : RustPlugin
        {
    
            void OnConsumeFuel(BaseOven oven, Item fuel, ItemModBurnable burnable)
            {
            var pookie = ItemManager.CreateByName("Pookie Bear", 1);
    
                if (!pookie.MoveToContainer(oven.inventory));
                {
                }
            }
        }
    }
    And here's the entire error message
    Code:
    Failed to call hook 'OnConsumeFuel' on plugin 'FurnaceModifier v0.0.1' (NullReferenceException: Object reference not set to an instance of an object)
      at Oxide.Plugins.FurnaceModifier.OnConsumeFuel (BaseOven oven, Item fuel, ItemModBurnable burnable) [0x0000e] in <7a251d0bf75c4f8784bc5f1578af8199>:0
      at Oxide.Plugins.FurnaceModifier.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00032] in <7a251d0bf75c4f8784bc5f1578af8199>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <9affce1cd15c4ec183941adef8db1722>:0
      at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <4452f821def6406d834e4149849fe7ea>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <4452f821def6406d834e4149849fe7ea>:0
    Sorry if my post violates any rules.
     
  2. Your mistake is here :p
    Code:
    var pookie = ItemManager.CreateByName("Pookie Bear", 1);
     
  3. Thanks! I can't believe how stupid I am! It was such a easy fix when I finally noticed my issue. Anyway's now i'm having the issue of stack-sizes if you got any hints on how i can make so they all just go into the same one that would be great!
    Currently the pookies go like this if the X represents a slot.

    X X X X

    I want it to be

    X = 1 + 1 +1 +1 Etc

    This is probably really simple to fix. I sadly can't find any documentation on it nor any documentation of MoveToContainer. Thanks jet again. <3
     
  4. Wulf

    Wulf Community Admin

    There wouldn't be any documentation for it as it's Rust code, not something Oxide provides.
     
  5. :/ Yeah I have been attempting to stack them for like 3 hours now. Starting to get annoying. Looking around my decompiler constantly but can't find any useful information.
    Code:
    Item PookieItem = oven.inventory.FindItemByItemID(definition.itemid);
    Tried to just find how many pookies total was in the furnace and then removing the old ones. And adding old ones to a number + 1 and putting them back in again. But its not going very well
     
  6. Can always do something like this,

    Code:
    void OnItemAddedToContainer(ItemContainer container, Item item)
    {
        // IF Container has pookies, Count them
        // Delete existing pookies
        // Create new stack of pookies, use ItemManager.CreateBy with pookies equal to the current count of pookies + the amount you want to add
    }
    Give that a try!