Пример #1
0
        public virtual void OnRequestSellItem(Player player, uint itemId)
        {
            Item item = player.Inventory.GetItem(itemId);

            if (item == null)
            {
                return;
            }

            int SellGoldValue = item.ItemDefinition.BaseGoldValue / 25; // Cost of item to sell is splitted into 25 of her BaseGoldValue (Buy price) [Necrosummon]

            decimal.Floor(SellGoldValue);

            item.Attributes[Net.GS.Message.GameAttribute.Special_Inventory_Has_Sold] = true;
            item.Attributes[Net.GS.Message.GameAttribute.Item_Time_Sold]             = 0;
            item.Attributes.BroadcastChangedIfRevealed();
            _vendorGrid.AddSelledItem(item);
            player.Inventory.SellItem(item);

            if (SellGoldValue <= 1) // if the operation have like a result less than 1, always vendor give you 1 gold for the item.
            {
                player.Inventory.AddGoldAmount(1);
            }
            else
            {
                player.Inventory.AddGoldAmount(SellGoldValue);
            }

            //RefreshInventoryToClient(player);
        }