Suggestion : Shop price auto-balancing.Not An Issue

There used to be a feature in this plugin, and it has vanished.

It used to "Balance" the prices of the items dependant on how much was bought and sold. a player buys a lot of an item, the price goes up. Players sells a lot of the item, the price goes down.  If the shop was badly set up, it meant that it was exploitable, but not anything that attentive set-up couldn't fix. 

The following forum posts make it clear that this was indeed happening. I personally used this, and took the time to fix the exploit. Then I retired the shop from my server for a while, and when I wanted to use the plugin again, but this feature was missing:

The oldest version of GUIShop I can find is 1.4.6, when the plugin was still maintained by Nogrod / Reneb. 

It has a config for "Balance" which maps to a boolean in the plugin, 

        double GetBuyPrice(ItemData data)
        {
            if (!Balance || data.Fixed) return data.Buy;
            return Math.Round(data.Buy * GetFactor(data), 2);
        }

So this function IF the Balance is set to false, will return the value in Data.Buy, but if set true, it will instead return a math rounded version of the data.Buy multiplied by GetFactor(data) to two decimal place. 

GetFactor is itself a double defined by :

double GetFactor(ItemData data)
        {
            if (data.Shortname == null) return 1;
            var itemname = data.Shortname;
            ulong buy;
            if (!buyed.TryGetValue(itemname, out buy))
                buy = 1;
            ulong sell;
            if (!selled.TryGetValue(itemname, out sell))
                sell = 1;
            return Math.Min(Math.Max(buy / (double)sell, .25), 4);
        }

https://umod.org/community/gui-shop/11270-prices-in-shop-change-without-edit?page=1#post-2

https://umod.org/community/gui-shop/20072-prices-changing-with-every-buysell?page=1#post-2

https://umod.org/community/gui-shop/13974-players-exploiting-for-unlimited-money?page=1#post-1

This was useful, as it would nerf out easy to farm stuff, and would incentivize people to sell expensive items, but with diminishing returns, it encourages having varied items to farm.

 

 

An actual auto-balancing of prices "feature" based on player's individual transactions in GUIShop has never existed in any GUIShop release/version.

People have constantly miss understood what it did since its release.

All that does is say you set a price of buy to 10 and a sell of 2 it would return 8
( "Which is the diminished return of which you speak about" )

But it would always give you back that same value "8" no matter how many times you sold that item would always return 8.
( So it is not actually diminishing returns for each transaction it is just changing what you have set your buy and sell prices needlessly )

You already have to set the prices for the items anyways so instead of doing a crap ton of extra logic for nothing you may as well just set them for how much you want to be bought & sold for in the config.

After playing with it on dotnetfiddle you can even see for yourself that's all it does. 
The older versions only had toggle options (true/false) to either enable it globally or on individual items was all. 

using System;
                    
public class Program
{
    public static bool Balance = true;
    
    public class ItemData
    {
        public bool Fixed = false;
        public string Shortname = "rifle.ak";
        public ulong Buy = 10;
        public ulong Sell = 2;
    }
    
    public static void Main()
    {
        Console.WriteLine("Get Sell Price: " + GetSellPrice(new ItemData()));
    }
    
    static double GetSellPrice(ItemData data)
    {
        if (!Balance || data.Fixed) 
            return data.Sell;

        return Math.Round(data.Sell * GetFactor(data), 2);
    }
    
    static double GetFactor(ItemData data)
    {
        if (data.Shortname == null) 
            return 1;

        return Math.Min(Math.Max(data.Buy / (double)data.Sell, .25), 4);
    }
}​

 

I was literally kicked and banned off the only server I ever got banned from because I used the exploit in the old posts I linked, buying charcoal to up the price and then selling all at the inflated price. I had something silly like 108 million server currency. It's in fact why I first started running a server. 

 

Locked automatically