db.Database.GetCharData C# (CSharp) Method

GetCharData() public method

public GetCharData ( Account acc, Chars chrs ) : void
acc Account
chrs Chars
return void
        public void GetCharData(Account acc, Chars chrs)
        {
            MySqlCommand cmd = CreateQuery();
            cmd.CommandText = "SELECT IFNULL(MAX(id), 0) + 1 FROM characters WHERE accId=@accId;";
            cmd.Parameters.AddWithValue("@accId", acc.AccountId);
            chrs.NextCharId = (int)(long)cmd.ExecuteScalar();

            cmd = CreateQuery();
            cmd.CommandText = "SELECT maxCharSlot FROM accounts WHERE id=@accId;";
            cmd.Parameters.AddWithValue("@accId", acc.AccountId);
            chrs.MaxNumChars = (int)cmd.ExecuteScalar();
        }

Usage Example

Exemplo n.º 1
0
        public Chars GetChars(string guid, string password, XmlData data)
        {
            using (var db = new Database())
            {
                Account a = db.Verify(guid, password, data);
                if (a != null)
                {
                    if (a.Banned)
                        return null;
                }

                Chars chrs = new Chars
                {
                    Characters = new List<Char>(),
                    NextCharId = 2,
                    MaxNumChars = 1,
                    Account = a,
                };
                db.GetCharData(chrs.Account, chrs);
                db.LoadCharacters(chrs.Account, chrs);
                chrs.News = db.GetNews(Program.GameData, chrs.Account);
                chrs.OwnedSkins = Utils.GetCommaSepString(chrs.Account.OwnedSkins.ToArray());
                return chrs;
            }
        }
All Usage Examples Of db.Database::GetCharData