Esempio n. 1
0
        static void OnRegisterVendor(WorldConnection connection, WORLDMSG msgID, BinReader data)
        {
            ulong    vGUID = data.ReadUInt64();
            uint     id    = data.ReadUInt32();
            uint     level = data.ReadUInt32();
            string   name  = data.ReadString();
            DBVendor vendor;

            if (id == 0)
            {
                Console.WriteLine("SpawnID was 0 for vendor registration");
            }
            DataObject[] objs = DataServer.Database.SelectObjects(typeof(DBVendor), "SpawnID = '" + id + "'");
            if (objs.Length == 0)
            {
                vendor         = new DBVendor();
                vendor.SpawnID = id;
                vendor.GUID    = vGUID;
                vendor.Name    = name;
                vendor.Level   = level;
                DataServer.Database.AddNewObject(vendor);
                Console.WriteLine("Vendor " + vendor.ObjectId + " created");
            }
            else
            {
                vendor       = (DBVendor)objs[0];
                vendor.GUID  = vGUID;
                vendor.Level = level;
                Console.WriteLine("Vendor " + vendor.ObjectId + " registered");
                DataServer.Database.SaveObject(vendor);
            }
            return;
        }
Esempio n. 2
0
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            Vendor v = Pool.Instance.GetObject <Vendor>(character.Playfield.Identity, target);

            if (v != null)
            {
                int        pfid = character.Playfield.Identity.Instance;
                StatelData sd   =
                    PlayfieldLoader.PFData[pfid].Statels.FirstOrDefault(x => x.Identity.Equals(v.OriginalIdentity));
                if (sd != null)
                {
                    int instance = (((sd.Identity.Instance) >> 16) & 0xff
                                    | (character.Playfield.Identity.Instance << 16));
                    DBVendor dbv = new DBVendor();
                    dbv.Id         = instance;
                    dbv.Playfield  = pfid;
                    dbv.X          = sd.X;
                    dbv.Y          = sd.Y;
                    dbv.Z          = sd.Z;
                    dbv.HeadingX   = sd.HeadingX;
                    dbv.HeadingY   = sd.HeadingY;
                    dbv.HeadingZ   = sd.HeadingZ;
                    dbv.HeadingW   = sd.HeadingW;
                    dbv.Name       = "New shop, please fill me";
                    dbv.TemplateId = sd.TemplateId;
                    dbv.Hash       = "";
                    VendorDao.Instance.Delete(dbv.Id);
                    VendorDao.Instance.Add(dbv, dontUseId: false);
                }
            }
        }
Esempio n. 3
0
 public Connection Add(Enum connectionName, DBVendor dbVendor, string usedDBParameterPrefix)
 {
     lock (Map.lockerForMap) {
         ConnectionMapper.NewConnection(connectionName, dbVendor, usedDBParameterPrefix);
         return(new Connection());
     }
 }
Esempio n. 4
0
 public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
 {
     Vendor v = Pool.Instance.GetObject<Vendor>(character.Playfield.Identity, target);
     if (v != null)
     {
         int pfid = character.Playfield.Identity.Instance;
         StatelData sd =
             PlayfieldLoader.PFData[pfid].Statels.FirstOrDefault(x => x.Identity.Equals(v.OriginalIdentity));
         if (sd != null)
         {
             int instance = (((sd.Identity.Instance) >> 16) & 0xff
                             | (character.Playfield.Identity.Instance << 16));
             DBVendor dbv = new DBVendor();
             dbv.Id = instance;
             dbv.Playfield = pfid;
             dbv.X = sd.X;
             dbv.Y = sd.Y;
             dbv.Z = sd.Z;
             dbv.HeadingX = sd.HeadingX;
             dbv.HeadingY = sd.HeadingY;
             dbv.HeadingZ = sd.HeadingZ;
             dbv.HeadingW = sd.HeadingW;
             dbv.Name = "New shop, please fill me";
             dbv.TemplateId = sd.TemplateId;
             dbv.Hash = "";
             VendorDao.Instance.Delete(dbv.Id);
             VendorDao.Instance.Add(dbv, dontUseId: false);
         }
     }
 }
Esempio n. 5
0
        static bool OnvAddItem(LoginClient client, string input)
        {
            if (client.Account.AccessLvl < ACCESSLEVEL.GM)
            {
                Chat.System(client, "You do not have access to this command");
                return(true);
            }

            string[] split = input.Split(' ');
            if (split.Length < 3)
            {
                return(false);
            }
            DBVendorItem item = new DBVendorItem();

            DataObject[] obj = DataServer.Database.SelectObjects(typeof(DBVendor), "GUID='" + client.Character.Selected + "'");
            if (obj == null || obj.Length == 0)
            {
                Chat.System(client, "Vendor not found");
                return(true);
            }
            DBVendor vendor = (DBVendor)obj[0];

            item.VendorID = vendor.ObjectId;

            item.TemplateID = (uint)int.Parse(split[1]);
            DBItemTemplate template = (DBItemTemplate)DataServer.Database.FindObjectByKey(typeof(DBItemTemplate), item.TemplateID);

            if (template == null)
            {
                Chat.System(client, "Item template not found for " + item.TemplateID);
                item = null;
                return(false);
            }
            item.CurrentQty = int.Parse(split[2]);
            if (split.Length > 3)
            {
                item.Price = int.Parse(split[3]);
            }
            else if (template.BuyPrice > 0)
            {
                item.Price = template.BuyPrice;
            }
            else
            {
                item.Price = (int)10;
            }
            DataServer.Database.AddNewObject(item);
            DataServer.Database.SaveObject(item);
            Chat.System(client, "Added item " + template.Name + " to vendor " + vendor.Name);
            DataServer.Database.FillObjectRelations(vendor);
            DataServer.Database.FillObjectRelations(item);

            return(true);
        }
Esempio n. 6
0
        //connectionstring config dosyasında girilmişse kullanılabilir
        internal static void NewConnection(Enum connectionName, DBVendor dbVendor, string usedDBParameterPrefix)
        {
            DB.throwIfNullOrEmpty <MappingException>(connectionName, "Connection name");
            DB.throwIfKeyAlreadyExists <string, ConnectionMapping, MappingException>(Map.connectionMappingDictionaryAtMapper, connectionName.ToString());

            ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings[connectionName.ToString()];

            //ConnectionStringSettings connectionStringSettings = DB.ConnectionStringSettingsCollection[connectionName.ToString()];

            DB.throwIfNullOrEmpty <MappingException>(connectionStringSettings, "Connection settings");
            DB.throwIfNullOrEmpty <MappingException>(connectionStringSettings.ConnectionString, "Connection string");

            NewConnection(connectionName, connectionStringSettings.ConnectionString, dbVendor, usedDBParameterPrefix);
        }
Esempio n. 7
0
        static bool OnInitTrainer(LoginClient client, string input)
        {
            if (client.Account.AccessLvl < ACCESSLEVEL.GM)
            {
                Chat.System(client, "You do not have access to this command");
                return(true);
            }

            string[] split = input.Split(' ');
            if (split.Length < 2)
            {
                return(false);
            }


            DataObject[] obj = DataServer.Database.SelectObjects(typeof(DBVendor), "GUID='" + client.Character.Selected + "'");
            if (obj == null || obj.Length == 0)
            {
                Chat.System(client, "Vendor not found");
                return(true);
            }
            DBVendor vendor   = (DBVendor)obj[0];
            CLASS    tmpClass = CLASS.MAGE;

            try
            {
                tmpClass = (CLASS)Enum.Parse(typeof(CLASS), split[1].ToUpper());
            }
            catch (Exception) { Chat.System(client, "Invalid class"); return(false); }
            vendor.Class = (int)tmpClass;
            Chat.System(client, "Setting Trainer Class:" + vendor.Class);
            DataServer.Database.SaveObject(vendor);
            DataServer.Database.FillObjectRelations(vendor);
            string classstr = tmpClass.ToString();

            classstr = classstr.Substring(0, 1).ToUpper() + classstr.Substring(1).ToLower();
            string      chatcmd = "!title " + '\"' + classstr + " Trainer" + '\"';
            WorldPacket pkg     = new WorldPacket(WORLDMSG.CLIENT_MESSAGE);

            pkg.Write(client.Character.ObjectId);
            pkg.Write((int)CMSG.MESSAGECHAT);
            pkg.Write((int)0);
            pkg.Write((int)0);
            pkg.Write(chatcmd);
            client.SendWorldServer(pkg);
            return(true);
        }
Esempio n. 8
0
        static bool BuyItemVendor(LoginClient client, CMSG msgID, BinReader data)
        {
            ulong vendorGUID2 = data.ReadUInt64();
            int   itembuy     = data.ReadInt32();
            byte  targetslot  = 0;

            if (msgID == CMSG.BUY_ITEM_IN_SLOT)
            {
                data.ReadUInt64();
                targetslot = data.ReadByte();
            }
            DataObject[] obj = DataServer.Database.SelectObjects(typeof(DBVendor), "GUID = '" + vendorGUID2 + "'");
            if (obj.Length == 0)
            {
                Chat.System(client, "Vendor not found");
                return(true);
            }

            DBVendor tvendor = (DBVendor)obj[0];

            foreach (DBVendorItem item in tvendor.VendorItems)
            {
                if (item.TemplateID == itembuy)
                {
                    DBItem newItem = new DBItem();
                    newItem.OwnerID    = client.Character.ObjectId;
                    newItem.OwnerSlot  = targetslot;                    //temp, checks for open slot on world side
                    newItem.TemplateID = item.TemplateID;
                    newItem.Template   = item.Template;
                    DataServer.Database.AddNewObject(newItem);
                    client.WorldConnection.Send(newItem);

                    ScriptPacket Item = new ScriptPacket(SCRMSG.BUYITEM);

                    Item.Write(client.Character.ObjectId);
                    Item.Write(newItem.ObjectId);
                    Item.Write(item.Price);
//					Item.Write(23); // NEED TO MAKE THE SCRIPT SEND TO NEXT-FREE-SLOT, INSTEAD OF FIRST
                    client.WorldConnection.Send(Item);

//					Chat.System(client, "Buy Item Working, Vendor GUI = "+vendorGUID2+" and item = "+itembuy+" on LoginServer");
                    return(true);
                }
            }
            Chat.System(client, "Item not found on this vendor");
            return(true);
        }
        public static void SpawnVendorFromDatabaseTemplate(DBVendor vendor, IPlayfield playfield)
        {
            Identity pfIdentity = new Identity() { Type = IdentityType.Playfield, Instance = vendor.Playfield };
            Identity freeIdentity = new Identity()
                                    {
                                        Type = IdentityType.VendingMachine,
                                        Instance =
                                            Pool.Instance.GetFreeInstance<Vendor>(
                                                0x70000000,
                                                IdentityType.VendingMachine)
                                    };

            Vendor v = new Vendor(pfIdentity, freeIdentity, vendor.Hash);

            v.RawCoordinates = new Vector3(vendor.X, vendor.Y, vendor.Z);
            v.Heading = new Quaternion(vendor.HeadingX, vendor.HeadingY, vendor.HeadingZ, vendor.HeadingW);
            v.Playfield = playfield;
        }
Esempio n. 10
0
        static bool VendorLisr(LoginClient client, CMSG msgID, BinReader data)
        {
            BinWriter pkg2 = LoginClient.NewPacket(SMSG.LIST_INVENTORY);

            ulong vendorGUID = data.ReadUInt64();

            DataObject[] obj = DataServer.Database.SelectObjects(typeof(DBVendor), "GUID = '" + vendorGUID + "'");
            if (obj.Length == 0)
            {
                Chat.System(client, "Vendor not found");
                return(true);
            }

            DBVendor tvendor = (DBVendor)obj[0];

            pkg2.Write(tvendor.GUID);                                                           // Vendor GUID (OK)
            if (tvendor.VendorItems == null)
            {
                pkg2.Write((int)0);
                client.Send(pkg2);
                return(true);
            }
            int Lenght = tvendor.VendorItems.Length;
            int i      = 1;

            pkg2.Write((byte)Lenght);                                                           // item counter (OK)
            foreach (DBVendorItem item in tvendor.VendorItems)
            {
                pkg2.Write((int)i);                                             // item counter number (OK)
                pkg2.Write((int)item.TemplateID);                               // item template (OK)
                pkg2.Write((int)item.Template.DisplayID);                       // item icon display_id (OK)
                pkg2.Write((int)item.CurrentQty);                               // Quantity (OK)
                pkg2.Write((int)item.Price);                                    // Price (OK)
                pkg2.Write(0);                                                  // Dunno
                pkg2.Write((int)item.Template.ReqLevel);                        // Item Level (OK)
                i++;
            }

            client.Send(pkg2);
            return(true);
        }
        public static void SpawnVendorsForPlayfield(IPlayfield playfield, StatelData[] rdbVendors)
        {
            IEnumerable <DBVendor> vendors = VendorDao.Instance.GetWhere(new { Playfield = playfield.Identity.Instance });

            foreach (StatelData sd in rdbVendors)
            {
                int id = (((sd.Identity.Instance) >> 16) & 0xff | (playfield.Identity.Instance << 16));

                DBVendor vendor = vendors.FirstOrDefault(x => x.Id == id);
                if (vendor is null)
                {
                    LogUtil.Debug(DebugInfoDetail.Statel, sd.Identity.ToString() + " -    " + sd.TemplateId);
                    SpawnEmptyVendorFromTemplate(sd, playfield, id);
                }
                else
                {
                    LogUtil.Debug(DebugInfoDetail.Statel, sd.Identity.ToString() + " - DB " + vendor.TemplateId);
                    SpawnVendorFromDatabaseTemplate(vendor, playfield);
                }
            }
        }
        public static void SpawnVendorFromDatabaseTemplate(DBVendor vendor, IPlayfield playfield)
        {
            Identity pfIdentity = new Identity()
            {
                Type     = IdentityType.Playfield,
                Instance = vendor.Playfield
            };

            Identity freeIdentity = new Identity()
            {
                Type     = IdentityType.VendingMachine,
                Instance = Pool.Instance.GetFreeInstance <Vendor>(0x70000000, IdentityType.VendingMachine)
            };

            Vendor v = new Vendor(pfIdentity, freeIdentity, vendor.Hash)
            {
                RawCoordinates = new Vector3(vendor.X, vendor.Y, vendor.Z),
                Heading        = new Quaternion(vendor.HeadingX, vendor.HeadingY, vendor.HeadingZ, vendor.HeadingW),
                Playfield      = playfield
            };
        }
Esempio n. 13
0
        static bool OnvRemoveItem(LoginClient client, string input)
        {
            if (client.Account.AccessLvl < ACCESSLEVEL.GM)
            {
                Chat.System(client, "You do not have access to this command");
                return(true);
            }
            string[] split = input.Split(' ');
            if (split.Length < 2)
            {
                return(false);
            }

            uint targetItem = (uint)int.Parse(split[1]);

            DataObject[] obj = DataServer.Database.SelectObjects(typeof(DBVendor), "GUID='" + client.Character.Selected + "'");
            if (obj == null || obj.Length == 0)
            {
                Chat.System(client, "Vendor not found");
                return(true);
            }
            DBVendor vendor = (DBVendor)obj[0];

            foreach (DBVendorItem item in vendor.VendorItems)
            {
                if (item.TemplateID == targetItem)
                {
                    Chat.System(client, "Removed item " + item.Name + " from vendor " + vendor.Name);
                    DataServer.Database.DeleteObject(item);
                    DataServer.Database.FillObjectRelations(vendor);
                    return(true);
                }
            }
            Chat.System(client, "Item not found on this vendor");
            return(true);
        }
Esempio n. 14
0
        static bool TrainerList(LoginClient client, CMSG msgID, BinReader data)
        {
            ulong trainerGUID = data.ReadUInt64();

            DataObject[] obj = DataServer.Database.SelectObjects(typeof(DBVendor), "GUID = '" + trainerGUID + "'");
            if (obj.Length == 0)
            {
                Chat.System(client, "Vendor not found");
                return(true);
            }
            uint[] PlayerSpellIDs = null;
            if (client.Character.Spells != null)
            {
                PlayerSpellIDs = new uint[client.Character.Spells.Length];
                for (int i = 0; i < client.Character.Spells.Length; i++)
                {
                    PlayerSpellIDs[i] = client.Character.Spells[i].Spell_Id;
                }
            }
            DBVendor tvendor = (DBVendor)obj[0];

            DataServer.Database.FillObjectRelations(tvendor);
            string greets = "Welcome, " + client.Character.Name + "! Choose your skill or spell :";

            BinWriter trainer = LoginClient.NewPacket(SMSG.TRAINER_LIST);

            //Guid of the trainer
            trainer.Write(trainerGUID);
            //Fill the hole
            trainer.Write((UInt32)0);
            if (tvendor.Trainings == null)
            {
                trainer.Write((uint)0);
            }
            else
            {
                //Number of spells to show
                trainer.Write((UInt32)tvendor.Trainings.Length);                  //Set this later too, just a default

                foreach (DBTraining training in tvendor.Trainings)
                {
                    if (training.Spell.PlayerLevel > tvendor.Level)
                    {
                        continue;
                    }
                    //				bool tmp=false;
                    //				if (tmp) continue;
                    else
                    {
                        byte showspell = 0;
                        if (client.Character.Level < training.Spell.PlayerLevel)
                        {
                            showspell = 1;
                        }
                        else
                        if (PlayerSpellIDs != null)
                        {
                            foreach (uint kspellid in PlayerSpellIDs)
                            {
                                if (kspellid == training.SpellID)
                                {
                                    showspell = 2;
                                }
                            }
                        }
                        //Id of the Spell
                        trainer.Write((UInt32)training.SpellID);
                        //Shown or not ? (0 = yes, 1 = no);
                        trainer.Write((Byte)showspell);
                        //Price of the spell
                        trainer.Write((UInt32)training.Price);
                        //Unknow
                        trainer.Write((UInt32)0);
                        //Unknow
                        trainer.Write((UInt32)0);
                        //Required Level
                        trainer.Write((UInt32)training.Spell.PlayerLevel);
                        //Unknow
                        trainer.Write((UInt32)0);
                        //Unknow
                        trainer.Write((UInt32)0);
                        //Unknow
                        trainer.Write((UInt32)0);
                        //Unknow
                        trainer.Write((UInt32)0);
                        //Unknow
                        trainer.Write((Byte)0);
                    }
                }
            }

/*			//Id of the Spell
 *                      trainer.Write((UInt32)143);
 *                      //Shown or not ? (0 = yes, 1 = no);
 *                      trainer.Write((Byte)0);
 *                      //Price of the spell
 *                      trainer.Write((UInt32)1);
 *                      //Unknow
 *                      trainer.Write((UInt32)0);
 *                      //Unknow
 *                      trainer.Write((UInt32)0);
 *                      //Required Level
 *                      trainer.Write((UInt32)3);
 *                      //Unknow
 *                      trainer.Write((UInt32)0);
 *                      //Unknow
 *                      trainer.Write((UInt32)0);
 *                      //Unknow
 *                      trainer.Write((UInt32)0);
 *                      //Unknow
 *                      trainer.Write((UInt32)0);
 *                      //Unknow
 *                      trainer.Write((Byte)0);
 */         //Greeting Message
            trainer.Write(greets);
            client.Send(trainer);

            Chat.System(client, "Trainer Working : GUID " + trainerGUID);

            return(true);
        }
Esempio n. 15
0
        static bool TrainerBuy(LoginClient client, CMSG msgID, BinReader data)
        {
            ulong     trainerGUID = data.ReadUInt64();
            ulong     spellId     = data.ReadUInt32();
            BinWriter trainer     = LoginClient.NewPacket(SMSG.TRAINER_BUY_SUCCEEDED);

            trainer.Write(trainerGUID);
            trainer.Write(spellId);
            client.Send(trainer);

            DataObject[] obj = DataServer.Database.SelectObjects(typeof(DBVendor), "GUID = '" + trainerGUID + "'");
            if (obj.Length == 0)
            {
                Chat.System(client, "Vendor not found");
                return(true);
            }

            DBVendor   tvendor = (DBVendor)obj[0];
            DBTraining tTrain  = null;

            foreach (DBTraining training in tvendor.Trainings)
            {
                if (training.SpellID == spellId)
                {
                    tTrain = training;
                    break;
                }
            }
            if (tTrain == null)
            {
                Chat.System("This vendor cannot teach you that spell"); return(true);
            }



//			DBSpell targetSpell = (DBSpell)DataServer.Database.FindObjectByKey(typeof(DBSpell), spellId);
            DBSpell targetSpell  = tTrain.Spell;
            uint    teachSpellId = (tTrain.TeachSpellID == 0?0x1ff7:tTrain.TeachSpellID);

            if (targetSpell == null)
            {
                Chat.System(client, "Spell " + spellId + " not found"); return(true);
            }
            DBKnownSpell newSpell = new DBKnownSpell();

            newSpell.Spell_Id = (uint)spellId;
            if (client.Character.Spells == null || client.Character.Spells.Length == 0)
            {
                newSpell.Slot = 1;
            }
            else
            {
                newSpell.Slot = (uint)client.Character.Spells.Length + 1;
            }

            newSpell.CharacterID = client.Character.ObjectId;
            try
            {
                newSpell.SpellLevel = uint.Parse(targetSpell.Rank);
            }
            catch (Exception) {}

            if (newSpell.SpellLevel == 0)
            {
                newSpell.SpellLevel = 1;
            }
            DataServer.Database.AddNewObject(newSpell);
            DataServer.Database.FillObjectRelations(client.Character);
            DataServer.Database.FillObjectRelations(client.Character.Spells[newSpell.Slot - 1]);
            try
            {
                Chat.System(client, "Spell " + client.Character.Spells[newSpell.Slot - 1].Spell.Name + " added.");
            }
            catch (Exception) {}


            BinWriter trainer2 = LoginClient.NewPacket(SMSG.SPELL_START);

            trainer2.Write((ulong)trainerGUID);
            trainer2.Write((ulong)trainerGUID);            //trainerGUID);
            trainer2.Write((uint)teachSpellId);            //0x1ff7);
//			trainer2.Write((UInt16)0);
            trainer2.Write((ushort)0);
            trainer2.Write((UInt32)0);
            trainer2.Write((short)2);
            trainer2.Write((ulong)client.Character.ObjectId);
            client.Send(trainer2);

            BinWriter trainer3 = LoginClient.NewPacket(SMSG.LEARNED_SPELL);

            trainer3.Write((short)spellId);
            trainer3.Write((UInt16)0x00);
            client.Send(trainer3);

            BinWriter trainer4 = LoginClient.NewPacket(SMSG.SPELL_GO);

            trainer4.Write((ulong)trainerGUID);
            trainer4.Write((ulong)client.Character.ObjectId); //trainerGUID);
            trainer4.Write((uint)teachSpellId);               //0x1ff7);
            //trainer4.Write((UInt32)0);
//			trainer4.Write((UInt16)0);
            trainer4.Write((byte)0);
            trainer4.Write((byte)0x01);
            trainer4.Write((byte)0x01);
            trainer4.Write((ulong)client.Character.ObjectId);
            trainer4.Write((byte)0x00);
            trainer4.Write((short)2);
            trainer4.Write((ulong)client.Character.ObjectId);
            client.Send(trainer4);

            BinWriter trainer5 = LoginClient.NewPacket(SMSG.SPELLLOGEXECUTE);

            trainer5.Write((ulong)trainerGUID);
            trainer5.Write((short)spellId);
            trainer5.Write((UInt16)0);
            trainer5.Write((UInt32)0x1);
            trainer5.Write((UInt32)0x24);
            trainer5.Write((UInt32)0x1);
            trainer5.Write((ulong)client.Character.ObjectId);
            client.Send(trainer5);


            Chat.System(client, "Debug : successfully bought spell!");
            return(true);
        }
Esempio n. 16
0
        internal static void NewConnection(Enum connectionName, string connectionString, DBVendor dbVendor, string usedDBParameterPrefix)
        {
            DB.throwIfNullOrEmpty <MappingException>(connectionName, "Connection name");
            DB.throwIfNullOrEmpty <MappingException>(connectionString, "Connection string");
            DB.throwIfKeyAlreadyExists <string, ConnectionMapping, MappingException>(Map.connectionMappingDictionaryAtMapper, connectionName.ToString());
            DB.throwIfNullOrEmpty <MappingException>(dbVendor, "DB vendor");

            Map.connectionMappingDictionaryAtMapper.Add(connectionName.ToString(), new ConnectionMapping(connectionName.ToString(), connectionString, dbVendor, usedDBParameterPrefix));
        }
Esempio n. 17
0
 public static IDbConnection ConnectionFactory(string connStr, DBVendor vendor)
 {
     return(ConnectionFactory(new ConnectionSpec(connStr, vendor)));
 }
Esempio n. 18
0
 public ConnectionSpec(string ConnStr, DBVendor Vendor)
 {
     connStr = ConnStr;
     vendor  = Vendor;
 }
Esempio n. 19
0
        static bool OnvAddTrain(LoginClient client, string input)
        {
            if (client.Account.AccessLvl < ACCESSLEVEL.GM)
            {
                Chat.System(client, "You do not have access to this command");
                return(true);
            }

            string[] split = input.Split(' ');
            if (split.Length < 4)
            {
                return(false);
            }
            DBTraining item = new DBTraining();

            DataObject[] obj = DataServer.Database.SelectObjects(typeof(DBVendor), "GUID='" + client.Character.Selected + "'");
            if (obj == null || obj.Length == 0)
            {
                Chat.System(client, "Vendor not found");
                return(true);
            }
            DBVendor vendor = (DBVendor)obj[0];

            item.VendorID = vendor.ObjectId;
            CLASS tmpClass = CLASS.MAGE;

            try
            {
                tmpClass = (CLASS)Enum.Parse(typeof(CLASS), split[1], true);
            }
            catch (Exception) { Chat.System(client, "Invalid class"); return(false); }
            item.Class   = (int)tmpClass;
            item.SpellID = (uint)int.Parse(split[2]);
            DBSpell spell = (DBSpell)DataServer.Database.FindObjectByKey(typeof(DBSpell), item.SpellID);

            if (spell == null)
            {
                Chat.System(client, "Spell not found for ID " + item.SpellID);
                item = null;
                return(false);
            }
            item.TeachSpellID = uint.Parse(split[3]);

            DBSpell trainspell = (DBSpell)DataServer.Database.FindObjectByKey(typeof(DBSpell), item.TeachSpellID);

            if (trainspell == null)
            {
                Chat.System(client, "Spell not found for ID " + item.TeachSpellID);
                item = null;
                return(false);
            }
//			if (split.Length>3)
            item.Price = int.Parse(split[4]);
//			else if (template.BuyPrice>0)
//				item.Price=template.BuyPrice;
//			else
//				item.Price=(int)10;
            DataServer.Database.AddNewObject(item);
            DataServer.Database.SaveObject(item);
            DataServer.Database.FillObjectRelations(vendor);
            DataServer.Database.FillObjectRelations(item);
            Chat.System(client, "Added item " + item.Spell.Name + " to vendor " + vendor.Name);

            return(true);
        }
Esempio n. 20
0
 public CoPConnection(string connectionString, DBVendor vendor)
 {
     Connection = Utilities.ConnectionFactory(connectionString, vendor);
 }