Jump to content

Infinite stock

Pending 1.0.4

mecwerks
mecwerks

Posted

Hello, is there currently a way to do infinite stock in cases of an outpost shop? Use case here is selling legendary weapons, and don't have a good way to keep it stocked.

 

Thanks for all the cool plugins!

  • Curator
imthenewguy

Posted

Hey mate, there is not.

 

  • Like 1
mecwerks

Posted

Thanks for the quick response! Any chance you plan on adding this or not on your roadmap? Thanks again.

  • Curator
imthenewguy

Posted

Its under consideration but it's not a simple change to make so it's not a priority atm.

 

mecwerks

Posted (edited)

diff --git a/plugins/CustomItemVending.cs b/plugins/CustomItemVending.cs
index 0975882..26df4b7 100644
--- a/plugins/CustomItemVending.cs
+++ b/plugins/CustomItemVending.cs
@@ -561,6 +561,7 @@ namespace Oxide.Plugins
             public int ShoppyStockBalance;
             public int ServerRewardsBalance;
             public bool Broadcast = true;
+            public bool infiniteStock;
 
             public int GetAvailableAmount(ItemData itemData)
             {
@@ -1819,13 +1820,35 @@ namespace Oxide.Plugins
                         continue;
                     }
 
-                    player.GiveItem(newItem);
+                    if (vmData.infiniteStock)
+                    {
+                        var itemCopy = ItemManager.Create(item.info, item.amount, item.skin);
+                        itemCopy.name = itemData.displayName;
+                        itemCopy.text = itemData.text;
+                        itemCopy.SetItemOwnership("Market Item", $"Purchased from the outpost by {player.displayName}.");
+                        player.GiveItem(itemCopy);
+                    }
+                    else
+                    {
+                        player.GiveItem(newItem);
+                    }
                     break;
                 }
                 else
                 {
                     paid += item.amount;
-                    player.GiveItem(item);
+                    if (vmData.infiniteStock)
+                    {
+                        var itemCopy = ItemManager.Create(item.info, item.amount, item.skin);
+                        itemCopy.name = itemData.displayName;
+                        itemCopy.text = itemData.text;
+                        itemCopy.SetItemOwnership("Market Item", $"Purchased from the outpost by {player.displayName}.");
+                        player.GiveItem(itemCopy);
+                    }
+                    else
+                    {
+                        player.GiveItem(item);
+                    }
                 }
 
                 if (paid >= purchaseAmount) break;

Here is a patch of my quick and dirty way to do it. Does not currently have UI to toggle it on so the plugin has to be unloaded, config changed, then reopened. Probably better to have an admin command for it. Also wasn't sure how to get the ownership tag from the existing item so just set it to a generic tag for now. Feel free to use this is you would like to. Love all your plugins!

Edited by mecwerks
  • Love 1
2.1m

Downloads

Total number of downloads.

9.7k

Customers

Total customers served.

141.2k

Files Sold

Total number of files sold.

3m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.