public static void CreateAccount(string[] args) { string Name = ReadN<string>(args, 0); string Password = ReadP<string>(args, 1); if (Name == null || Password == null) return; byte[] hash = new SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(Password)); string hashString = BitConverter.ToString(hash).Replace("-", ""); Account acc = new Account(); acc.Name = Name.ToUpper(); acc.Password = hashString; acc.Language = "enUS"; acc.GMLevel = 3; var result = DB.Realms.Select<Account>(); acc.Id = (uint)DB.Realms.RowCount + 1; if (DB.Realms.RowCount == 0) DB.Realms.Save(acc); foreach (Account a in result) { if (a.Name != Name) { DB.Realms.Save(acc); break; } } }
public static Character GetOnlineCharacter(Account acc) { Character chara = null; var conn = DB.Characters.Connection; var character = from Character c in conn where c.AccountId == acc.Id && c.IsOnline == true select c; foreach (Character cc in character) chara = cc; return chara; }
public static Character[] GetCharactersByAccount(Account acc) { var conn = DB.Characters.Connection; var character = from Character c in conn where c.AccountId == acc.Id select c; List<Character> chars = new List<Character>(); foreach (Character cc in character) chars.Add(cc); return chars.ToArray(); }