Пример #1
0
 public ItemVendor(Item item, int invIndex, long price, short amount, int id)
 {
     this.item = item;
     this.invIndex = invIndex;
     this.price = price;
     this.amount = amount;
     this.id = id;
 }
Пример #2
0
        public static void loadCargo(Character chr)
        {
            Cargo cargo = chr.getCargo();

            using(var con = new MySqlConnection(MasterServer.Instance.SqlConnection.mConnectionString))
            using(var cmd = con.CreateCommand())
            {
                con.Open();
                cmd.CommandText = "SELECT * FROM chars_inv WHERE charID=" + chr.getuID();
                using(var reader = cmd.ExecuteReader())
                {
                    reader.Read();

                    if(!reader.HasRows)
                    {
                        return;
                    }
                    else
                    {
                        List<int> seqhash = new List<int>();

                        int val = 0;
                        long ending;
                        short amount;
                        Item it;
                        for(int i = 0;i < 240;i++)
                        {
                            val = reader.GetInt32(i * 4 + 1);
                            amount = reader.GetInt16(i * 4 + 3);
                            it = null;
                            if(val != 0 && amount != 0)
                            {
                                it = new Item(val, amount);
                            }
                            val = reader.GetInt32(i * 4 + 2);
                            ending = reader.GetInt64(i * 4 + 4);
                            seqhash.Add(val);
                            if(it != null)
                            {
                                cargo.putIntoCargo(val % 100, val / 100, it);
                            }
                        }

                        cargo.saveCargo();
                        cargo.setSeqSaved(seqhash);
                    }
                }
            }
        }
Пример #3
0
        public static void SaveInventories(Character chr)
        {
            Inventory inv = chr.getInventory();
            StringBuilder sb = new StringBuilder();
            for(int i = 0;i < inv.getPages() * 40;i++) {
                Item item = new Item();
                if(inv.getSeqSaved()[i] != -1)
                    item = inv.getInvSaved()[inv.getSeqSaved()[i]];
                sb.Append(",i" + i + "=" + item.getItemID());
                sb.Append(",h" + i + "=" + inv.getSeqSaved()[i]);
                sb.Append(",q" + i + "=" + item.getQuantity());
                sb.Append(",e" + i + "=" + item.getEnding());
            }

            Save("chars_inv", sb, "charID", chr.getuID());
            return;
        }
Пример #4
0
        public static void SaveEquipments(Character chr)
        {
            Equipment eq = chr.getEquipment();
            StringBuilder sb = new StringBuilder();
            for(byte i = 0;i<17;i++)
            {
                Item item = new Item();
                if(eq.getEquipments().ContainsKey(i))
                    item = eq.getEquipItem(i);
                sb.Append(",s" + i + "=" + item.getItemID());
                sb.Append(",e" + i + "=" + item.getEnding());
            }

            Save("chars_eq", sb, "charID", chr.getuID());
            return;
        }
Пример #5
0
        public static void SaveCargo(Character chr)
        {
            Cargo cargo = chr.getCargo();
            StringBuilder sb = new StringBuilder();
            for(int i = 0;i < 120;i++)
            {
                Item item = new Item();
                if(cargo.getSeqSaved()[i] != -1)
                    item = cargo.getCargoSaved()[cargo.getSeqSaved()[i]];
                sb.Append(",i" + i + "=" + item.getItemID());
                sb.Append(",h" + i + "=" + cargo.getSeqSaved()[i]);
                sb.Append(",q" + i + "=" + item.getQuantity());
                sb.Append(",e" + i + "=" + item.getEnding());
            }

            Save("chars_cargo", sb, "charID", chr.getuID());
            return;
        }