Exemplo n.º 1
0
        public static void Load()
        {
            var reader = DatabaseManager.Provider.ExecuteReader("SELECT * FROM characters_guild");
            int br     = 0;

            while (reader.Read())
            {
                var guild = GuildTable.GetGuild(reader.GetInt32("guild"));
                if (guild != null)
                {
                    var member = new Models.CharacterGuild()
                    {
                        ID                = reader.GetInt64("guid"),
                        Name              = reader.GetString("name"),
                        Guild             = reader.GetInt32("guild"),
                        Level             = reader.GetInt32("level"),
                        Gfx               = reader.GetInt32("look"),
                        Grade             = reader.GetInt32("rank"),
                        ExperiencePercent = reader.GetInt32("xpdone"),
                        Experience        = reader.GetInt64("xpdone"),
                        Restriction       = reader.GetInt32("rights"),
                        Alignement        = reader.GetInt32("align"),
                        lastConnection    = CDateTimeUtil.MySqlToNet(reader.GetMySqlDateTime("lastConnection")),
                    };
                    guild.CharactersGuildCache.Add(member);
                    br++;
                }
            }
            reader.Close();

            Logger.Info("Loaded @'" + br + "'@ Characters Guild");
        }
Exemplo n.º 2
0
        public static Dictionary <long, Player> FindAll(int owner)
        {
            Dictionary <long, Player> CharacterList = new Dictionary <long, Player>();

            try
            {
                MySqlCommand Command = new MySqlCommand()
                {
                    Connection  = DatabaseManager.RealmProvider.getConnection(),
                    CommandText = "SELECT " + Collums + ",canaux from characters WHERE owner=@owner AND server_id=@s",
                };

                Command.Prepare();
                Command.Parameters.AddWithValue("@owner", owner);
                Command.Parameters.AddWithValue("@s", Settings.Server);

                var reader = DatabaseManager.RealmProvider.ExecuteCommand(Command);

                while (reader.Read())
                {
                    var character = new Models.Player()
                    {
                        ID              = reader.GetInt64("guid"),
                        Owner           = reader.GetInt32("owner"),
                        Name            = reader.GetString("name"),
                        Level           = reader.GetInt32("level"),
                        Color1          = reader.GetInt32("color1"),
                        Color2          = reader.GetInt32("color2"),
                        Color3          = reader.GetInt32("color3"),
                        Look            = reader.GetInt32("look"),
                        Sexe            = reader.GetInt32("sexe"),
                        Classe          = reader.GetInt32("classe"),
                        EnabledChannels = reader.GetString("canaux"),
                        Map             = reader.GetInt16("map"),
                        CellId          = reader.GetInt32("cell"),
                        Restriction     = reader.GetInt32("restriction"),
                        Experience      = reader.GetInt64("experience"),
                        Kamas           = reader.GetInt64("kamas"),
                        CaractPoint     = reader.GetInt32("capital"),
                        SpellPoint      = reader.GetInt32("spellboost"),
                        LifePer         = reader.GetInt32("lifeper"),
                        Energy          = reader.GetInt32("energy"),
                        AP              = reader.GetInt32("ap"),
                        MP              = reader.GetInt32("mp"),
                        Vitality        = reader.GetInt32("vitality"),
                        Wisdom          = reader.GetInt32("wisdom"),
                        Strength        = reader.GetInt32("strength"),
                        Intell          = reader.GetInt32("intell"),
                        Agility         = reader.GetInt32("agility"),
                        Chance          = reader.GetInt32("chance"),
                        Alignement      = reader.GetInt32("alignement"),
                        Honor           = reader.GetInt32("honor"),
                        Deshonor        = reader.GetInt32("deshonor"),
                        Stuff           = reader.GetString("stuff"),
                        SpellString     = reader.GetString("spells"),
                        SavePos         = reader.GetString("savepos"),
                        ZaapString      = reader.GetString("zaaps"),
                        MountID         = reader.GetInt32("mount"),
                        MountXPGive     = reader.GetInt32("mountxpgive"),
                        WornItem        = reader.GetString("wornitem"),
                        Title           = reader.GetInt16("title"),
                        Cote            = reader.GetInt32("cote"),
                        showWings       = reader.GetInt32("seeAlign") == 1 ? true : false
                    };
                    CharacterList.Add(character.ID, character);
                    int guildId = CharactersGuildTable.playerIsOnGuild(character.ID);
                    if (guildId >= 0)
                    {
                        character.setCharacterGuild(GuildTable.GetGuild(guildId).GetMember(character.ID));
                    }
                    AddCharacter(character);
                }
                reader.Close();
            }
            catch (System.InvalidOperationException e1)
            {
                DatabaseManager.RealmProvider.Restart();
                return(FindAll(owner));
            }
            return(CharacterList);
        }