예제 #1
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            ItemType type = ItemType.Item;

            if (command.Length >= 1)
            {
                type = command[0].ToLower() == "v" ? ItemType.Vehicle : ItemType.Item;
            }

            if (command.Length == (type == ItemType.Item ? 0 : 1) || command.Length > (type == ItemType.Item ? 1 : 2))
            {
                UnturnedChat.Say(caller, DShop.Instance.Translate("cost_help3"));
                return;
            }

            if (!DShop.Instance.Database.IsLoaded)
            {
                UnturnedChat.Say(caller, DShop.Instance.Translate("db_load_error"));
                return;
            }

            if (!DShop.GetItemID(caller, command, type, 0, out ushort itemID))
            {
                return;
            }
            if (itemID.AssetFromID(type) == null)
            {
                UnturnedChat.Say(caller, DShop.Instance.Translate("invalid_id"));
                return;
            }
            ShopObject shopObject = DShop.Instance.Database.GetItem(type, itemID);

            if (shopObject.ItemID != itemID)
            {
                Asset asset = itemID.AssetFromID(type);
                if (type == ItemType.Item)
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("item_not_in_db", (asset != null && ((ItemAsset)asset).itemName != null) ? ((ItemAsset)asset).itemName : string.Empty, itemID));
                }
                else
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("item_not_in_db", (asset != null && ((VehicleAsset)asset).vehicleName != null) ? ((VehicleAsset)asset).vehicleName : string.Empty, itemID));
                }
                return;
            }

            UnturnedChat.Say(caller, DShop.Instance.Translate(type == ItemType.Item ? "costs_item2" : "costs_vehicle2", shopObject.ItemName, shopObject.ItemID, Math.Round(shopObject.BuyCost, 2), Uconomy.Instance.Configuration.Instance.MoneyName,
                                                              Math.Round(decimal.Multiply(shopObject.BuyCost, shopObject.SellMultiplier), 2), Uconomy.Instance.Configuration.Instance.MoneyName, Enum.GetName(typeof(RestrictBuySell), shopObject.RestrictBuySell)));
        }
예제 #2
0
 protected override void Load()
 {
     Instance = this;
     if (Configuration.Instance.Backend == BackendType.MySQL)
     {
         Database = new MySQLDatabaseManager();
     }
     else
     {
         Database = new XMLDatabaseManager();
     }
     if (Database.IsLoaded)
     {
         Instance.Configuration.Instance.DefaultItems();
     }
     Instance.Configuration.Save();
     Debug = Instance.Configuration.Instance.Debug;
     if (Instance.Configuration.Instance.EnableBuySellLogging)
     {
         Instance.OnShopBuy  += Instance_OnShopBuy;
         Instance.OnShopSell += Instance_OnShopSell;
     }
 }
예제 #3
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            {
                ItemType            type        = ItemType.Item;
                RaycastInfo         raycastInfo = null;
                InteractableVehicle vehicle     = null;
                if (command.Length >= 1)
                {
                    type = command[0].ToLower() == "v" ? ItemType.Vehicle : ItemType.Item;
                }

                if (command.Length == 0 || command.Length > (type == ItemType.Item ? 2 : 1))
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("sell_help4"));
                    return;
                }

                if (!DShop.Instance.Database.IsLoaded)
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("db_load_error"));
                    return;
                }

                ushort itemID = 0;
                ushort count  = 1;

                if (command.Length == 2 && type == ItemType.Item)
                {
                    if (!ushort.TryParse(command[1], out count))
                    {
                        if (command[1].ToLower() == "all" || command[1].ToLower() == "a")
                        {
                            count = ushort.MaxValue;
                        }
                        else
                        {
                            UnturnedChat.Say(caller, DShop.Instance.Translate("invalid_amount"));
                            return;
                        }
                    }
                    if (count == 0)
                    {
                        count = 1;
                    }
                }


                UnturnedPlayer player = caller as UnturnedPlayer;
                if (!ushort.TryParse(command[0], out itemID))
                {
                    if (type == ItemType.Item && command[0].ToLower() == "h")
                    {
                        itemID = player.Player.equipment.itemID;
                        if (itemID == 0)
                        {
                            UnturnedChat.Say(caller, DShop.Instance.Translate("no_item_held"));
                            return;
                        }
                    }
                    else if (type == ItemType.Item)
                    {
                        itemID = command[0].AssetIDFromName(type);
                    }
                    else if (type == ItemType.Vehicle)
                    {
                        // Try to grab the vehicle that the player is looking at.
                        raycastInfo = DShop.RaycastInfoVehicle(player, 10);
                        if (raycastInfo.vehicle == null)
                        {
                            UnturnedChat.Say(caller, DShop.Instance.Translate("vehicle_sell_to_far2"));
                            return;
                        }
                        else
                        {
                            itemID  = raycastInfo.vehicle.id;
                            vehicle = raycastInfo.vehicle;
                            // Run checks before accepting this vehicle to run through ShopVehicle.sell.
                            if (vehicle.isDead)
                            {
                                // Don't allow a destroyed vehicle to be sold.
                                UnturnedChat.Say(caller, DShop.Instance.Translate("vehicle_sell_dead"));
                                return;
                            }
                            if (!vehicle.isLocked)
                            {
                                // Vehicle isn't locked to any player.
                                UnturnedChat.Say(caller, DShop.Instance.Translate("vehicle_sell_unlocked2"));
                                return;
                            }
                            if (vehicle.isLocked && vehicle.lockedOwner != player.CSteamID)
                            {
                                // This vehicle isn't locked to this player.
                                UnturnedChat.Say(caller, DShop.Instance.Translate("vehicle_sell_locked_mismatch"));
                                return;
                            }
                            if (!vehicle.isEmpty)
                            {
                                // The vehicle still has players in it, don't sell.
                                UnturnedChat.Say(caller, DShop.Instance.Translate("vehicle_has_player2"));
                                return;
                            }
                        }
                    }
                }
                if (itemID.AssetFromID(type) == null)
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("invalid_id"));
                    return;
                }
                ShopObject sObject = DShop.Instance.Database.GetItem(type, itemID);
                if (sObject.ItemID != itemID)
                {
                    Asset asset = itemID.AssetFromID(type);
                    if (type == ItemType.Item)
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("item_not_in_db", (asset != null && ((ItemAsset)asset).itemName != null) ? ((ItemAsset)asset).itemName : string.Empty, itemID));
                    }
                    else
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("item_not_in_db", (asset != null && ((VehicleAsset)asset).vehicleName != null) ? ((VehicleAsset)asset).vehicleName : string.Empty, itemID));
                    }
                    return;
                }

                decimal balance              = Uconomy.Instance.Database.GetBalance(caller.Id);
                decimal newCost              = sObject.BuyCost;
                decimal totalCost            = 0;
                short   actualCount          = 0;
                decimal totalAttatchmentCost = 0;
                string  moneyName            = Uconomy.Instance.Configuration.Instance.MoneyName;

                if (type == ItemType.Item)
                {
                    ShopItem sItem = sObject as ShopItem;
                    if (sItem.Sell(balance, player, count, out newCost, out totalCost, out actualCount, out totalAttatchmentCost))
                    {
                        if (totalAttatchmentCost > 0)
                        {
                            UnturnedChat.Say(caller, DShop.Instance.Translate("sold_items_complete_w_attatchments", actualCount, sObject.ItemName, sObject.ItemID,
                                                                              Math.Round(totalCost, 2), moneyName, Math.Round(totalAttatchmentCost, 2), moneyName, Math.Round(balance + totalCost, 2), moneyName));
                        }
                        else
                        {
                            UnturnedChat.Say(caller, DShop.Instance.Translate("sold_items_complete", actualCount, sObject.ItemName, sObject.ItemID, Math.Round(totalCost, 2), moneyName, Math.Round(balance + totalCost, 2), moneyName));
                        }
                    }
                    else
                    {
                        if (actualCount == 0)
                        {
                            UnturnedChat.Say(caller, DShop.Instance.Translate("no_items_sell", sObject.ItemName, sObject.ItemID));
                            return;
                        }
                        if (actualCount == -1)
                        {
                            UnturnedChat.Say(caller, DShop.Instance.Translate("item_buy_only", sObject.ItemName, sObject.ItemID));
                            return;
                        }
                        if (actualCount < count)
                        {
                            if (totalAttatchmentCost > 0)
                            {
                                UnturnedChat.Say(caller, DShop.Instance.Translate("sold_items_partial_w_attatchments", actualCount, count, sObject.ItemName, sObject.ItemID,
                                                                                  Math.Round(totalCost, 2), moneyName, Math.Round(totalAttatchmentCost, 2), moneyName, Math.Round(balance + totalCost, 2), moneyName));
                            }
                            else
                            {
                                UnturnedChat.Say(caller, DShop.Instance.Translate("sold_items_partial", actualCount, count, sObject.ItemName, sObject.ItemID,
                                                                                  Math.Round(totalCost, 2), moneyName, Math.Round(balance + totalCost, 2), moneyName));
                            }
                        }
                    }
                }
                else
                {
                    ShopVehicle sVehicle = sObject as ShopVehicle;
                    // placeholder code until the vehicle buy/sell tracking update.
                    if (!DShop.Instance.Configuration.Instance.CanSellVehicles)
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("vehicle_sell_not_allowed"));
                        return;
                    }
                    if (sVehicle.Sell(balance, player, raycastInfo, out totalCost, out actualCount))
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("vehicle_sold2", sObject.ItemName, sObject.ItemID, Math.Round(totalCost, 2), moneyName, Math.Round(balance + totalCost, 2), moneyName));
                    }
                    else
                    {
                        if (actualCount == -1)
                        {
                            UnturnedChat.Say(caller, DShop.Instance.Translate("vehicle_buy_only2"));
                            return;
                        }
                        if (actualCount == -2)
                        {
                            UnturnedChat.Say(caller, DShop.Instance.Translate("vehicel_sell_no_own2"));
                            return;
                        }
                    }
                }
                if (totalCost > 0)
                {
                    Uconomy.Instance.Database.IncreaseBalance(caller.Id, (Math.Round(totalCost, 2)));
                }
            }
        }
예제 #4
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            ItemType type = ItemType.Item;

            if (command.Length >= 1)
            {
                type = command[0].ToLower() == "v" ? ItemType.Vehicle : ItemType.Item;
            }

            if (command.Length == (type == ItemType.Item ? 0 : 1) || command.Length > 2)
            {
                UnturnedChat.Say(caller, DShop.Instance.Translate("buy_help3"));
                return;
            }

            if (!DShop.Instance.Database.IsLoaded)
            {
                UnturnedChat.Say(caller, DShop.Instance.Translate("db_load_error"));
                return;
            }

            ushort count = 1;

            if (command.Length == 2 && type == ItemType.Item)
            {
                if (!ushort.TryParse(command[1], out count))
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("invalid_amount"));
                    return;
                }
                if (count > DShop.Instance.Configuration.Instance.MaxBuyCount)
                {
                    count = DShop.Instance.Configuration.Instance.MaxBuyCount;
                }
                if (count == 0)
                {
                    count = 1;
                }
            }

            UnturnedPlayer player = caller as UnturnedPlayer;

            if (!DShop.GetItemID(caller, command, type, 0, out ushort itemID))
            {
                return;
            }
            ShopObject sObject = DShop.Instance.Database.GetItem(type, itemID);

            if (sObject.ItemID != itemID)
            {
                Asset asset = itemID.AssetFromID(type);
                if (type == ItemType.Item)
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("item_not_in_db", (asset != null && ((ItemAsset)asset).itemName != null) ? ((ItemAsset)asset).itemName : string.Empty, itemID));
                }
                else
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("item_not_in_db", (asset != null && ((VehicleAsset)asset).vehicleName != null) ? ((VehicleAsset)asset).vehicleName : string.Empty, itemID));
                }
                return;
            }

            decimal balance = Uconomy.Instance.Database.GetBalance(caller.Id);

            decimal newCost     = sObject.BuyCost;
            decimal totalCost   = 0;
            short   actualCount = 0;
            string  moneyName   = Uconomy.Instance.Configuration.Instance.MoneyName;

            if (type == ItemType.Item)
            {
                ShopItem sItem = sObject as ShopItem;
                if (sItem.Buy(balance, player, count, out newCost, out totalCost, out actualCount))
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("bought_item_complete", actualCount, sObject.ItemName, sObject.ItemID, Math.Round(totalCost, 2), moneyName, Math.Round(balance - totalCost, 2), moneyName));
                }
                else
                {
                    if (actualCount == 0)
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("not_enough_to_buy", moneyName, sObject.ItemName, sObject.ItemID));
                        return;
                    }
                    if (actualCount == -2)
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("bought_item_error", sObject.ItemName, sObject.ItemID));
                        return;
                    }
                    if (actualCount == -3)
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("item_sell_only", sObject.ItemName, sObject.ItemID));
                        return;
                    }
                    if (actualCount < count)
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("bought_item_partial", actualCount, count, sObject.ItemName, sObject.ItemID, Math.Round(totalCost, 2), moneyName, Math.Round(balance - totalCost, 2), moneyName));
                    }
                }
            }
            else
            {
                ShopVehicle sVehicle = sObject as ShopVehicle;
                if (sVehicle.Buy(balance, player, out totalCost, out actualCount))
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("bought_vehicle", sObject.ItemName, sObject.ItemID, Math.Round(totalCost, 2), moneyName, Math.Round(balance - totalCost, 2), moneyName));
                }
                else
                {
                    if (actualCount == 0)
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("not_enough_to_buy", moneyName, sObject.ItemName, sObject.ItemID));
                        return;
                    }
                    if (actualCount == -2)
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("bought_vehicle_error", sObject.ItemName, sObject.ItemID));
                        return;
                    }
                    if (actualCount == -3)
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("vehicle_sell_only", sObject.ItemName, sObject.ItemID));
                        return;
                    }
                }
            }
            if (totalCost > 0)
            {
                Uconomy.Instance.Database.IncreaseBalance(caller.Id, -(Math.Round(totalCost, 2)));
            }
        }
예제 #5
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length == 0)
            {
                UnturnedChat.Say(caller, DShop.Instance.Translate("shop_help"));
                return;
            }

            if (!DShop.Instance.Database.IsLoaded)
            {
                UnturnedChat.Say(caller, DShop.Instance.Translate("db_load_error"));
                return;
            }

            ItemType type = ItemType.Item;

            if (command.Length >= 2 && command[1].ToLower() == "v")
            {
                type = ItemType.Vehicle;
            }
            ShopObject shopObject = null;

            switch (command[0].ToLower())
            {
            case "convert":
            {
                if (command.Length != 2)
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("convert_help"));
                    return;
                }
                BackendType backend;
                try
                {
                    backend = (BackendType)Enum.Parse(typeof(BackendType), command[1], true);
                    UnturnedChat.Say(caller, DShop.Instance.Translate("converting", backend.ToString()));
                    if (DShop.Instance.Database.ConvertDB(backend))
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("conversion_success"));
                    }
                    else
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("conversion_fail"));
                    }
                }
                catch (Exception ex)
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("invalid_db_type", ex.Message));
                }
                break;
            }

            case "add":
            {
                if (command.Length < (type == ItemType.Item ? 2 : 3) || command.Length > (type == ItemType.Item ? 8 : 6))
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("add_help5"));
                    return;
                }
                if (!DShop.GetItemID(caller, command, type, 1, out ushort itemID))
                {
                    return;
                }
                if (itemID.AssetFromID(type) == null)
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("invalid_id"));
                    return;
                }
                shopObject = DShop.Instance.Database.GetItem(type, itemID);
                if (shopObject.ItemID == itemID)
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("duplicate"));
                }

                // Parse the vars used in command, if short of variables, or can't parse, defaults would be used for those vars.
                decimal buyCost = DShop.Instance.Configuration.Instance.DefaultBuyCost;
                if (command.Length >= (type == ItemType.Item ? 3 : 4) && !decimal.TryParse(type == ItemType.Item ? command[2] : command[3], out buyCost))
                {
                    buyCost = DShop.Instance.Configuration.Instance.DefaultBuyCost;
                    UnturnedChat.Say(caller, DShop.Instance.Translate("parse_fail_cost"));
                }

                decimal sellMultiplier = DShop.Instance.Configuration.Instance.DefaultSellMultiplier;
                if (command.Length >= (type == ItemType.Item ? 4 : 5) && !decimal.TryParse(type == ItemType.Item ? command[3] : command[4], out sellMultiplier))
                {
                    decimal fraction = 0;
                    if ((type == ItemType.Item && command[3].IsFraction(out fraction)) || (type == ItemType.Vehicle && command[4].IsFraction(out fraction)))
                    {
                        sellMultiplier = fraction;
                    }
                    else
                    {
                        sellMultiplier = DShop.Instance.Configuration.Instance.DefaultSellMultiplier;
                        UnturnedChat.Say(caller, DShop.Instance.Translate("parse_fail_mult"));
                    }
                }
                decimal minBuyPrice = DShop.Instance.Configuration.Instance.MinDefaultBuyCost;
                if (type == ItemType.Item && command.Length >= 5 && !decimal.TryParse(command[4], out minBuyPrice))
                {
                    minBuyPrice = DShop.Instance.Configuration.Instance.MinDefaultBuyCost;
                    UnturnedChat.Say(caller, DShop.Instance.Translate("parse_fail_minprice"));
                }

                decimal changeRate = DShop.Instance.Configuration.Instance.DefaultIncrement;
                if (type == ItemType.Item && command.Length >= 6 && !decimal.TryParse(command[5], out changeRate))
                {
                    changeRate = DShop.Instance.Configuration.Instance.DefaultIncrement;
                    UnturnedChat.Say(caller, DShop.Instance.Translate("parse_fail_changerate"));
                }

                decimal maxBuyPrice = 0;
                if (type == ItemType.Item && command.Length >= 7 && !decimal.TryParse(command[6], out maxBuyPrice))
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("parse_fail_maxprice"));
                }

                RestrictBuySell restrictBuySell = RestrictBuySell.None;
                if (command.Length >= (type == ItemType.Item ? 8 : 6))
                {
                    try
                    {
                        restrictBuySell = (RestrictBuySell)Enum.Parse(typeof(RestrictBuySell), type == ItemType.Item ? command[7] : command[5], true);
                    }
                    catch
                    {
                        restrictBuySell = RestrictBuySell.None;
                        UnturnedChat.Say(caller, DShop.Instance.Translate("parse_fail_shoprestrict"));
                    }
                }

                // Construct new item to add to the database.
                shopObject = (type == ItemType.Item ? (ShopObject) new ShopItem(itemID, buyCost, sellMultiplier, minBuyPrice, changeRate, maxBuyPrice, restrictBuySell) : new ShopVehicle(itemID, buyCost, sellMultiplier, restrictBuySell));

                if (DShop.Instance.Database.AddItem(type, shopObject))
                {
                    UnturnedChat.Say(caller, FormatItemInfo("format_item_info_p1_addv2", shopObject, type));
                }
                else
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("item_add_fail"));
                }
                break;
            }

            case "rem":
            case "remove":
            {
                if (command.Length != (type == ItemType.Item ? 2 : 3))
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("remove_help3"));
                    return;
                }
                if (!DShop.GetItemID(caller, command, type, 1, out ushort itemID))
                {
                    return;
                }
                if (itemID.AssetFromID(type) == null)
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("invalid_id"));
                    return;
                }

                shopObject = DShop.Instance.Database.GetItem(type, itemID);

                if (DShop.Instance.Database.DeleteItem(type, itemID))
                {
                    UnturnedChat.Say(caller, FormatItemInfo("format_item_info_p1_deletev2", shopObject, type));
                }
                else
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("item_not_in_shop_db"));
                }
                break;
            }

            case "get":
            {
                if (command.Length != (type == ItemType.Item ? 2 : 3))
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("get_help3"));
                    return;
                }
                if (!DShop.GetItemID(caller, command, type, 1, out ushort itemID))
                {
                    return;
                }
                if (itemID.AssetFromID(type) == null)
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("invalid_id"));
                    return;
                }
                shopObject = DShop.Instance.Database.GetItem(type, itemID);
                if (shopObject.ItemID == itemID)
                {
                    UnturnedChat.Say(caller, FormatItemInfo("format_item_info_p1_getv2", shopObject, type));
                }
                else
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("item_not_in_shop_db"));
                }
                break;
            }

            case "upd":
            case "update":
            {
                if (command.Length > (type == ItemType.Item ? 4 : 5) || command.Length < (type == ItemType.Item ? 2 : 4))
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("update_help5"));
                    return;
                }
                type = ItemType.Item;
                if (command.Length >= 3 && command[2].ToLower() == "v")
                {
                    type = ItemType.Vehicle;
                }
                if (command.Length == (type == ItemType.Item ? 4 : 5))
                {
                    if (!DShop.GetItemID(caller, command, type, 2, out ushort itemID))
                    {
                        return;
                    }
                    if (itemID.AssetFromID(type) == null)
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("invalid_id"));
                        return;
                    }
                    shopObject = DShop.Instance.Database.GetItem(type, itemID);
                    if (shopObject.ItemID != itemID)
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("item_not_in_shop_db"));
                        return;
                    }
                }
                switch (command[1].ToLower())
                {
                case "cost":
                {
                    if (command.Length != (type == ItemType.Item ? 4 : 5))
                    {
                        goto default;
                    }

                    decimal buyCost = DShop.Instance.Configuration.Instance.DefaultBuyCost;
                    if (!decimal.TryParse(type == ItemType.Item ? command[3] : command[4], out buyCost))
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("bad_cost"));
                        return;
                    }
                    shopObject.BuyCost = buyCost;
                    goto set;
                }

                case "mult":
                {
                    if (command.Length != (type == ItemType.Item ? 4 : 5))
                    {
                        goto default;
                    }

                    decimal sellMult = DShop.Instance.Configuration.Instance.DefaultSellMultiplier;
                    if (!decimal.TryParse(type == ItemType.Item ? command[3] : command[4], out sellMult))
                    {
                        decimal fraction = 0;
                        if ((type == ItemType.Item && command[3].IsFraction(out fraction)) || (type == ItemType.Vehicle && command[4].IsFraction(out fraction)))
                        {
                            sellMult = fraction;
                        }
                        else
                        {
                            UnturnedChat.Say(caller, DShop.Instance.Translate("bad_mult"));
                            return;
                        }
                    }
                    shopObject.SellMultiplier = sellMult;
                    goto set;
                }

                case "min":
                {
                    if (command.Length != 4)
                    {
                        goto default;
                    }

                    decimal minCost = DShop.Instance.Configuration.Instance.MinDefaultBuyCost;
                    if (!decimal.TryParse(command[3], out minCost))
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("bad_minprice"));
                        return;
                    }
                    ((ShopItem)shopObject).MinBuyPrice = minCost;
                    goto set;
                }

                case "rate":
                {
                    if (command.Length != 4)
                    {
                        goto default;
                    }

                    decimal rate = DShop.Instance.Configuration.Instance.DefaultIncrement;
                    if (!decimal.TryParse(command[3], out rate))
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("bad_chagerate"));
                        return;
                    }
                    ((ShopItem)shopObject).Change = rate;
                    goto set;
                }

                case "max":
                {
                    if (command.Length != 4)
                    {
                        goto default;
                    }

                    decimal maxCost = 0;
                    if (!decimal.TryParse(command[3], out maxCost))
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("bad_maxprice"));
                        return;
                    }
                    ((ShopItem)shopObject).MaxBuyPrice = maxCost;
                    goto set;
                }

                case "sr":
                {
                    if (command.Length != (type == ItemType.Item ? 4 : 5))
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("update_shoprestrict_help"));
                        return;
                    }

                    RestrictBuySell restrictBuySell = RestrictBuySell.None;
                    try
                    {
                        restrictBuySell = (RestrictBuySell)Enum.Parse(typeof(RestrictBuySell), type == ItemType.Item ? command[3] : command[4], true);
                    }
                    catch
                    {
                        UnturnedChat.Say(caller, DShop.Instance.Translate("bad_shoprestrict"));
                        return;
                    }
                    shopObject.RestrictBuySell = restrictBuySell;
                    goto set;
                }

                default:
                {
                    UnturnedChat.Say(caller, DShop.Instance.Translate("update_help4"));
                    return;
                }
set:
                    {
                        if (DShop.Instance.Database.AddItem(type, shopObject))
                        {
                            UnturnedChat.Say(caller, FormatItemInfo("format_item_info_p1_updatev2", shopObject, type));
                        }
                        else
                        {
                            UnturnedChat.Say(caller, DShop.Instance.Translate("update_fail"));
                        }
                        break;
                    }
                }

                break;
            }

            default:
                UnturnedChat.Say(caller, Syntax);
                return;
            }
        }