Change loot amounts with loot containersSolved

I'm trying to change specific items within loot containers to double them with the following code:

    object OnLootSpawn(LootContainer container) {
      foreach (Item item in container.inventory.itemList) {
        string shortname = item.info.shortname;
        if (shortname == "scrap") item.amount *= 2;
       // etc
      }
      return null;
    }​

however it doesnt appear to do anything as nothing is doubled even after deleting every single LootContainer and checking newly spawned ones
so im not quite sure what to do
I have tried to use container.PopulateLoot(); at the beginning but it seems to add more scrap and an extra item to what it should be giving

Add a delay... when you call this hook, the container is not yet filled...

        private void OnLootSpawn(LootContainer container) {
            NextTick(() => {
                if (container == null || container.IsDestroyed) return;
                foreach (Item item in container.inventory.itemList) {
                    string shortname = item.info.shortname;
                    if (shortname == "scrap") item.amount *= 2;
                }
            });
        }​

Sorry but, ended up just looking at where OnLootSpawn is called and saw that if i return true then it stops the rust server code from filling the container
so i just had to do the below which is essentially straight from the server code

container.PopulateLoot();      

// other code

if (!container.shouldRefreshContents) return true;
container.Invoke(new Action(container.SpawnLoot), UnityEngine.Random.Range(container.minSecondsBetweenRefresh, container.maxSecondsBetweenRefresh));
return true;​
Locked automatically