Hackable crate broken

When the loot is generated for the hackable crate it removes the map marker for it, but the crate stays and is fully functional. Would be great if this is fixed as it kinda ruins competition for the crates since no one knows they are there.

There is no function in BetterLoot for a marker, what plugin are you using for the hackable crate ? , Guarded crate marker is working and so is DangerousTreasures,

There are no config's for a locked crate in betterloot. it has never used hackable crates but it will add contents to crates for other plugins. in case i am wrong could you point out the config for the marker ?

This is happening to me as well. I narrowed it down to this plugin.

Merged post

I fixed it with a custom plugin I wrote. You can find it here https://umod.org/plugins/GjKwZ3LyL1

FIX YOUR PLUGIN OR HAND IT OFF TO A BETTER DEVELOPER :)

Be patient and remember that all plugins presented on this site are "as is" and that there are NO guarantees they will work on all servers , the devs have their own lives and these plugins are not their primary concerns, I have no problems with this plugin and its functions and as stated before, please show the config in this plugin for hackable crates .

I did submit a patch for this but it hasnt been added yet 

In `PopulateContainer` after line 584 add this 

            if (container is HackableLockedCrate crate)
            {
                crate.inventory.onItemAddedRemoved = null;
            }

 

the updated `PopulateContainer` should look like this 

 

        private bool PopulateContainer(LootContainer container)
        {
            Dictionary<string, object> con;
            object containerobj;
            if (!lootTables.TryGetValue(container.PrefabName, out containerobj))
                return false;
            con = containerobj as Dictionary<string, object>;
            if (!(bool)con["Enabled"])
                return false;
            var lootitemcount = (con["ItemList"] as Dictionary<string, object>)?.Count();
            int itemCount = Mathf.RoundToInt(UnityEngine.Random.Range(Convert.ToSingle(Mathf.Min((int)con["ItemsMin"], (int)con["ItemsMax"])) * 100f, Convert.ToSingle(Mathf.Max((int)con["ItemsMin"], (int)con["ItemsMax"])) * 100f) / 100f);
            if (lootitemcount > 0 && itemCount > lootitemcount && lootitemcount < 36)
                itemCount = (int)lootitemcount;
            if (container.inventory == null)
            {
                container.inventory = new ItemContainer();
                container.inventory.ServerInitialize(null, 36);
                container.inventory.GiveUID();
            }
            else
            {
                container.inventory.Clear();
                container.inventory.capacity = 36;
                ItemManager.DoRemoves();
            }
            //prevent the crate map marker being removed
            if (container is HackableLockedCrate crate)
            {
                crate.inventory.onItemAddedRemoved = null;
            }

            var items = new List<Item>();
            var itemNames = new List<string>();
            var itemBlueprints = new List<int>();
            var maxRetry = 10;
            for (int i = 0; i < itemCount; ++i)
            {
                if (maxRetry == 0)
                {
                    break;
                }
                var item = MightyRNG(container.PrefabName, itemCount, (bool)(itemBlueprints.Count >= (int)con["MaxBPs"]));

                if (item == null)
                {
                    --maxRetry;
                    --i;
                    continue;
                }
                if (itemNames.Contains(item.info.shortname) || (item.IsBlueprint() && itemBlueprints.Contains(item.blueprintTarget)))
                {
                    item.Remove();
                    --maxRetry;
                    --i;
                    continue;
                }
                else
                    if (item.IsBlueprint())
                    itemBlueprints.Add(item.blueprintTarget);
                else
                    itemNames.Add(item.info.shortname);
                items.Add(item);
                if (storedBlacklist.ItemList.Contains(item.info.shortname))
                {
                    items.Remove(item);
                    item.Remove(); // broken item fix
                }
            }
            foreach (var item in items.Where(x => x != null && x.IsValid()))
                if (!item.MoveToContainer(container.inventory, -1, false)) { item.DoRemove(); } // broken item fix / fixes full container 
            if ((int)con["Scrap"] > 0)
            {
                int scrapCount = (int)con["Scrap"];
                Item item = ItemManager.Create(ItemManager.FindItemDefinition("scrap"), scrapCount * _config.Loot.scrapMultiplier, 0uL);
                if (!item.MoveToContainer(container.inventory, -1, false)) { item.DoRemove(); } // broken item fix
            }
            container.inventory.capacity = container.inventory.itemList.Count;
            container.inventory.MarkDirty();
            container.SendNetworkUpdate();
            populatedContainers++;
            return true;
        }

The marker is supposed to disappear when an item is removed, so by doing this you break that instead.

firingLaserz

The marker is supposed to disappear when an item is removed, so by doing this you break that instead.

No the marker is still removed when a player loots the crate, this fixes the marker being removed when the loot is populated on server start up,

it was a change FP made a few wipes ago and this plugin wasnt updated for it 

if you look where the code is updated in my snippit, you will understand it better as it only applied here `

private bool PopulateContainer(LootContainer container)

so the updated code breaks nothing, it only fixes a change from months ago that was never applied to this plugin yet 

firingLaserz

The marker is supposed to disappear when an item is removed, so by doing this you break that instead.

I can attest that this patch works great. 👍🏻
Thanks to Mabel for fixing half the plugins on this site from shat devs. 

@DeadNasty , I cannot understand  your attitude towards the devs who create and maintain their plugins as much as they are able to,
You dont pay anything for them , You dont spend any time maintaining them and trying to fix the problems that FP changes create, All you do is live up to your name , If you dont like the way the Devs manage their plugins Dont use them instead of acting like a spoilt child.

nMyfFlEnglczTD3.jpg pookins

@DeadNasty , I cannot understand  your attitude towards the devs who create and maintain their plugins as much as they are able to,
You dont pay anything for them , You dont spend any time maintaining them and trying to fix the problems that FP changes create, All you do is live up to your name , If you dont like the way the Devs manage their plugins Dont use them instead of acting like a spoilt child.

Lol who
Asked
You.
Live up to your name
Poo 💩 haha. Imagine haha L

I have been here many years longer than you and will be still be here when you have left school and got a job, I respect the devs here and follow the rules.

Apart from the above code is there anything else people have noticed??

Does the NamesList notepad need updating when new items get added??

Someone take this plugin on :) its a good plugin