Exemple #1
0
        public byte[] addItem(ItemVendor item, int state, int x, int y)
        {
            int check = -1;
            check = owner.getInventory().getSeqSaved()[item.getInvIndex()];
            if(check < 0)
                Console.WriteLine("Item does not exist in inventory");

            if(totalMoney + item.getPrice()*item.getQuantity() > moneyCap - owner.getCoin())
                Console.WriteLine("You reached the selling value cap. The total of all items cannot be more if the sum is more as " + moneyCap + ".");

            totalMoney += item.getPrice();
            itemsMap.Add(item.getItemID(), item);
            itemCoords.Add(item.getItemID(), new Point(x, y));
            return VendingPackets.addItemToVendor(item, state, owner, x, y);
        }
Exemple #2
0
        public byte[] addItem(ItemVendor item, int state, int x, int y)
        {
            int check = -1;

            check = owner.getInventory().getSeqSaved()[item.getInvIndex()];
            if (check < 0)
            {
                Console.WriteLine("Item does not exist in inventory");
            }

            if (totalMoney + item.getPrice() * item.getQuantity() > moneyCap - owner.getCoin())
            {
                Console.WriteLine("You reached the selling value cap. The total of all items cannot be more if the sum is more as " + moneyCap + ".");
            }

            totalMoney += item.getPrice();
            itemsMap.Add(item.getItemID(), item);
            itemCoords.Add(item.getItemID(), new Point(x, y));
            return(VendingPackets.addItemToVendor(item, state, owner, x, y));
        }
Exemple #3
0
        public static byte[] addItemToVendor(ItemVendor item, int state, Character cur, int x, int y)
        {
            Console.WriteLine("Adding item " + item.getItemID() + " of index " + item.getInvIndex() + " on position(x, y) (" + x + ", " + y +")");
            byte[] price = BitTools.longToByteArray(item.getPrice());
            byte[] chid = BitTools.intToByteArray(cur.getuID());
            byte[] venItem = new byte[36];

            venItem[0] = (byte)venItem.Length;
            venItem[4] = (byte)0x04;
            venItem[6] = (byte)0x39;

            venItem[8] = (byte)0x01;
            venItem[9] = (byte)0x04; //f5 need when remove?
            venItem[10] = (byte)0x67; //10 need when remove?
            venItem[11] = (byte)0x28; //29 need when remove?

            for(int i=0;i<4;i++) {
                venItem[12+i] = chid[i];
            }

            venItem[16] = (byte)0x01;

            //Status: 1 = add, 0 = remove
            venItem[18] = (byte)state;

            //item inventory id
            venItem[19] = (byte)item.getInvIndex();
            //item number (Unique id for vendor UI)
            venItem[20] = (byte)item.getItemID();

            //y
            venItem[21] = (byte)y;
            //x
            venItem[22] = (byte)x;

            //amount
            venItem[24] = (byte)item.getQuantity();

            venItem[26] = (byte)0x0f;
            venItem[27] = (byte)0xbf;

            //price 6 bytes long
            //first byte can be 0x00 when high number
            venItem[28] = price[0];
            for(int i=0;i<price.Length-1;i++)
            {
                venItem[29+i] = price[1+i];
            }
            return venItem;
        }
Exemple #4
0
        public Boolean soldItem(Character buy, long price, byte index, int invSlot, int x, int y, short amount)
        {
            if (buy.getCoin() - (price * amount) < 0 || owner.getCoin() + (price * amount) > long.MaxValue)
            {
                Console.WriteLine("Let me show you, where i've been.");
                return(false);
            }
            if (!itemsMap.ContainsKey(index))
            {
                Console.WriteLine("no shit sherlock, item doesn't exist!");
                return(false);
            }

            ItemVendor item = itemsMap[index];

            if (item == null)
            {
                Console.WriteLine("Item does not exist!");
                return(false);
            }

            if (amount > item.getQuantity())
            {
                Console.WriteLine("This is not the right amount.");
                return(false);
            }

            buy.setCoin(owner.getCoin() - (price * amount));
            owner.setCoin(owner.getCoin() + (price * amount));

            //when item not deleted
            if (item.getQuantity() > 1 && amount != item.getQuantity())
            {
                item.decrementAmount(amount);
                //replace with new values in vendor
                itemsMap[index] = item;
            }
            else
            {
                //remove item vendor
                removeItemList(index);
            }

            //remove/decrement item
            owner.getInventory().updateInv();
            if (!owner.getInventory().removeItem(invSlot, amount))
            {
                Console.WriteLine("chuj kurwa");
                return(false);
            }
            owner.getInventory().saveInv();

            //add item
            Item newItem = new Item(item.getItemID(), item.getQuantity());

            Console.WriteLine("ItemID: " + newItem.getItemID());
            buy.getInventory().updateInv();
            if (!buy.getInventory().addItem(y, x, newItem))
            {
                Console.WriteLine("Something went wrong while adding the item");
                return(false);
            }
            buy.getInventory().saveInv();
            buy.getAccount().mClient.WriteRawPacket(VendingPackets.buyItemFromVendor(buy, owner, index, invSlot, x, y, amount));
            owner.getAccount().mClient.WriteRawPacket(VendingPackets.buyItemFromVendorSecondSite(buy, owner, index, invSlot, x, y, amount));
            return(true);
        }