Moving an item to StorageContainer?Solved
            StorageContainer bloonfule = bloon.GetComponent<StorageContainer>();
      
            Item i1 = ItemManager.CreateByName("lowgradefuel", 200);
            i1.MoveToContainer(bloonfule);​

Argument `#1' cannot convert `StorageContainer' expression to type `ItemContainer

Any ideas

StorageContainer represents the entity (or BaseCombatEntity or BaseEntity) in the game world.  The actual ItemContainer is StorageContainer.inventory.

i1.MoveToContainer(bloonfule.inventory);​​
This is what i got and its still throwing an error when running idn what im missing?
BaseEntity bloon = GameManager.server.CreateEntity("assets/prefabs/deployable/hot air balloon/hotairballoon.prefab", playerPos, playerRot);
            bloon.Spawn();
            StorageContainer bloonfule = bloon.GetComponent<StorageContainer>();          
            Item item = ItemManager.CreateByName("lowgradefuel", 200);
            item.MoveToContainer(bloonfule.inventory);
            bloon.SetFlag(BaseEntity.Flags.On, true);        ​

(01:53:06) | Failed to call hook 'test1' on plugin 'SleeperMark v1.0.1' (NullReferenceException: Object reference not set to an instance of an object)
  at Oxide.Plugins.SleeperMark.test1 (BasePlayer player) [0x000c6] in <1ab3751dc4bc4ecfb5ebfa9e57bd5797>:0 

  at Oxide.Plugins.SleeperMark.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x005ad] in <1ab3751dc4bc4ecfb5ebfa9e57bd5797>: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​
NRE's are difficult to diagnose without subtantial testing.  I would suggest process of elimination to determine which line is causing the NRE and then compare your implementation to existing implementations (plenty of plugins operate on storage containers).
this line  if i remove it command runs no errors bloon spawns just no fule
            item.MoveToContainer(bloonfule.inventory);
​
There is some initialization code that's required when spawning a container.  I grabbed this from Bank, you will need to test it yourself..

int slots = 1;
ItemContainer container = new ItemContainer ();
container.ServerInitialize (null, slots);
container.GiveUID ();
/// DO YOUR STUFF HERE, LIKE..
bloonfule.inventory = container;
Im Still trying to learn this folowing other plugins examples this is what i got..
       public BaseEntity bloon;
       private StorageContainer bloonfule;


            BaseEntity bloon = GameManager.server.CreateEntity("assets/prefabs/deployable/hot air balloon/hotairballoon.prefab", playerPos, playerRot);
            bloonfule = bloon.GetComponent<StorageContainer>();

     if (bloonfule != null) {
            bloonfule.inventorySlots = 1;           
            bloonfule.SendNetworkUpdate();
             bloon.Spawn();
                }​

so i see now that bloonfule is returning null...witch is tossing the error unshue why.
is there an easer way to make that entity not require fuel? 



Merged post

Guess im not sure how containers work would it not spawn the container with the entity?

Merged post

so this works to spawn item in a box but not in the hotairbloon..
var bloon = GameManager.server.CreateEntity("assets/prefabs/deployable/woodenbox/woodbox_deployed.prefab", playerPos, playerRot);

bloon.Spawn();

var bloonfule = bloon.GetComponent<StorageContainer>();
Item item = ItemManager.CreateByItemID(-946369541, 1);


int slots = 1;
ItemContainer container = new ItemContainer ();
container.ServerInitialize (null, slots);
container.GiveUID ();
bloonfule.inventory = container;
item.MoveToContainer(bloonfule.inventory);​
In response to Razor ():
Im Still trying to learn this folowing other plugins examples this is what i got..
publ...
global::StorageContainer component = this.fuelStorageInstance.Get(base.isServer).GetComponent<global::StorageContainer>();
Thanks for posting your solution
It did not work i got....
BaseEntity bloon = GameManager.server.CreateEntity("assets/prefabs/deployable/hot air balloon/hotairballoon.prefab", playerPos, playerRot);
fuelTank = bloon.fuelStorageInstance.Get(true).GetComponent<StorageContainer>();​

And i get.
 error CS1061: Type `BaseEntity' does not contain a definition for `fuelStorageInstance' and no extension method `fuelStorageInstance' of type `BaseEntity' could be found. Are you missing an assembly reference?


Merged post

I got it working will post solution shortly 

Merged post

var  controller = entity.GetComponent<HotAirBalloon>();
                  fuelTank = controller.fuelStorageInstance.Get(true).GetComponent<StorageContainer>();
                  Item item = ItemManager.CreateByItemID(-946369541, 5);
                  item.MoveToContainer(fuelTank.inventory, -1, true);
Locked automatically