BlackSpigot
Custom Vending Setup for Rust

ULTRA Custom Vending Setup for Rust 2.10.3


  • Video tutorial
  • Features
  • Optional plugins
  • How it works
    • Limitations regarding the map and drone marketplaces
    • Limitations regarding the travelling vendor
    • Data providers
  • Permissions
  • Screenshots
  • Configuration
  • Localization
  • FAQ
    • How do I buy items faster (no transaction delay)?
    • How do I make items restock instantly?
    • How do I allow players to purchase more items in bulk?
    • Why do some items show more stock than configured?
    • Why is stock different than vanilla?
    • Can I sell more than 7 items?
    • How do I display custom item names?
    • How do I setup custom monuments?
  • Developer API
    • API_IsCustomized
    • API_RefreshDataProvider
  • Developer Hooks
    • OnCustomVendingSetup
    • OnCustomVendingSetupGiveSoldItem
    • OnCustomVendingSetupDataProvider
  • Credits
seller-gallery-1.jpg

Features​

  • Allows customizing items sold at monument vending machines
  • Supports vendors that have invisible vending machines, such as those at bandit camp and fishing villages
  • Supports the travelling vendor
  • Supports all monument types, including custom monuments
  • Saves customizations for future restarts and wipes, based on the vending machine's relative position to the monument
  • Synchronizes edits with copies of the vending machines at duplicate monuments
  • Compatible with NPC vending machines spawned at monuments by plugins such as Monument Addons
  • Allows bypassing dynamic pricing per vending machine
  • Allows customizing vending machine skins
  • Allows disabling vending machine map markers
  • Allows disabling delivery drone access
  • Supports Economics and Server Rewards as both payment and merchandise
  • Supports blueprints, as well as items with custom skins and names
  • Supports attachments and other child items
  • Supports alternative ammo types and amounts
Note: Does not affect player vending machines.

How it works​

When you open an NPC vending machine, if you have permission, you will see an edit button. Clicking that edit button will reveal a container UI where you can customize the vending machine.
seller-gallery-2.png

seller-gallery-3.png

seller-gallery-4.png

Code:
{
  "Enable liquid currency": false,
  "Economics integration": {
    "Enabled": false,
    "Item short name": "paper",
    "Item skin ID": 2420097877
  },
  "Server Rewards integration": {
    "Enabled": false,
    "Item short name": "paper",
    "Item skin ID": 2420097877
  },
  "Override item max stack sizes (shortname: amount)": {}
}
Code:
"Override item max stack sizes (shortname: amount)": {
  "wood": 10000,
  "stones": 5000
}
This can happen for vending machines that sell an item for multiple amounts (e.g., scrap to wood, and stones to wood). This happens because each vending machine uses a single stock container for all items it sells, so it will try to stock the amount required for whichever sale offer requires the most stock.
Code:
bool API_IsCustomized(NPCVendingMachine vendingMachine)
Code:
void API_RefreshDataProvider(NPCVendingMachine vendingMachine)
Code:
object OnCustomVendingSetup(NPCVendingMachine vendingMachine)
Code:
void OnCustomVendingSetupGiveSoldItem(NPCVendingMachine vendingMachine, Item item, BasePlayer player)
Code:
[PluginReference]
Plugin CustomVendingSetup;

void OnCustomVendingSetupGiveSoldItem(NPCVendingMachine vendingMachine, Item item, BasePlayer player)
{
    // Run some logic to count the purchase
}

void OnNpcGiveSoldItem(NPCVendingMachine vendingMachine, Item item, BasePlayer player)
{
    // Don't count the purchase if CustomVendingSetup is controlling the vending machine,
    // since `OnCustomVendingSetupGiveSoldItem` will also be called in that case
    if (CustomVendingSetup?.Call("API_IsCustomized", vendingMachine) is true)
        return;

    // Run some logic to count the purchase
}
Code:
Dictionary<string, object> OnCustomVendingSetupDataProvider(NPCVendingMachine vendingMachine)
Code:
class PluginData
{
    [JsonProperty("VendingProfile")]
    public object VendingProfile;
}

PluginData _pluginData;

void Init()
{
    _pluginData = Interface.Oxide.DataFileSystem.ReadObject<PluginData>("Test_VendingProfile") ?? new PluginData();
}

Dictionary<string, object> OnCustomVendingSetupDataProvider(NPCVendingMachine vendingMachine)
{
    if (vendingMachine.net.ID == 123456)
    {
        return new Dictionary<string, object>
        {
            ["Plugin"] = this,
            ["GetData"] = new System.Func<JObject>(() =>
            {
                return _pluginData.VendingProfile as JObject;
            }),
            ["SaveData"] = new System.Action<JObject>(data =>
            {
                _pluginData.VendingProfile = data;
                Interface.Oxide.DataFileSystem.WriteObject("Test_VendingProfile", _pluginData);
            }),
        };
    }

    return null;
}
Author
Wifi
Downloads
0
Views
1
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from Wifi

Top