public void ReloadRights() { mRights.Clear(); using (DatabaseClient dbClient = IonEnvironment.GetDatabase().GetClient()) { // Search for all roles for (byte role = 0; role <= mMaxRoles; role++) { // Get rights for roles (and roles inherited) DataTable result = dbClient.ReadDataTable("SELECT userright FROM access_userrights WHERE role <= " + role.ToString() + ";"); if (result.Rows.Count > 0) { // Shove rights to a string array string[] rights = new string[result.Rows.Count]; for (int position = 0; position < result.Rows.Count; position++) { rights[position] = (string)result.Rows[position]["userright"]; } // Add rights for this role to the dictionary mRights.Add(role, rights); } } } }
public bool HasAchievement(uint userID, string sAchievement) { using (DatabaseClient dbClient = IonEnvironment.GetDatabase().GetClient()) { dbClient.AddParamWithValue("@userid", userID); dbClient.AddParamWithValue("@achievement", sAchievement); return(dbClient.ReadInt32("SELECT COUNT(userID) FROM users_achievements WHERE userid = @userid AND achievement = @achievement LIMIT 1;") > 0); } }
public void RemoveAchievement(uint userID, string sAchievement) { using (DatabaseClient dbClient = IonEnvironment.GetDatabase().GetClient()) { dbClient.AddParamWithValue("@userid", userID); dbClient.AddParamWithValue("@achievement", sAchievement); dbClient.ExecuteQuery("DELETE FROM users_achievements WHERE userid = @userid AND achievement = @achievement;"); } }
public void AddAchievement(uint userID, string sAchievement) { using (DatabaseClient dbClient = IonEnvironment.GetDatabase().GetClient()) { dbClient.AddParamWithValue("@userid", userID); dbClient.AddParamWithValue("@achievement", sAchievement); dbClient.ExecuteQuery("INSERT INTO users_achievements(userid,achievement) VALUES (@userid,@achievement);"); } }
public Habbo GetHabbo(string sUsername) { // TODO: some sort of cache? Habbo habbo = new Habbo(); if (habbo.LoadByUsername(IonEnvironment.GetDatabase(), sUsername)) { return(habbo); } return(null); }
public List <string> GetAchievements(uint userID) { List <string> achievements = new List <string>(); using (DatabaseClient dbClient = IonEnvironment.GetDatabase().GetClient()) { dbClient.AddParamWithValue("@userid", userID); foreach (DataRow row in dbClient.ReadDataTable("SELECT achievement FROM users_achievements WHERE userid = @userid;").Rows) { achievements.Add((string)row["achievement"]); } } return(achievements); }
public void ReloadBuddies() { mBuddies.Clear(); using (DatabaseClient dbClient = IonEnvironment.GetDatabase().GetClient()) { dbClient.AddParamWithValue("@userid", mClient.GetHabbo().ID); foreach (DataRow row in dbClient.ReadDataTable("SELECT id,username,figure,motto FROM users WHERE id IN(SELECT buddyid FROM messenger_buddylist WHERE userid = @userid AND accepted = 0x01) OR id IN(SELECT userid FROM messenger_buddylist WHERE buddyid = @userid AND accepted = 0x01);").Rows) { MessengerBuddy buddy = MessengerBuddy.Parse(row); if (buddy != null) { mBuddies.Add(buddy); } } } }
public void Reload() { this.Clear(); using (DatabaseClient dbClient = IonEnvironment.GetDatabase().GetClient()) { foreach (DataRow row in dbClient.ReadDataTable("SELECT " + mKeyName + ", " + mValueName + " FROM " + mTableName + ";").Rows) { string key = (string)row[0]; string value = (string)row[1]; if (!mDictionary.ContainsKey(key)) { mDictionary.Add(key, value); } } } }
public Habbo Login(string sTicket) { // Do not use HabboManager.GetHabbo(string) here, as caching is planned to be implemented there Habbo habbo = new Habbo(); if (!habbo.LoadBySsoTicket(IonEnvironment.GetDatabase(), sTicket)) { throw new IncorrectLoginException("login incorrect: Wrong ticket"); } else { // Drop old client (if logged in via other connection) IonEnvironment.GetHabboHotel().GetClients().KillClientOfHabbo(habbo.ID); return(habbo); } }
public List <MessengerBuddy> SearchHabbos(string criteria) { List <MessengerBuddy> matches = new List <MessengerBuddy>(); using (DatabaseClient dbClient = IonEnvironment.GetDatabase().GetClient()) { dbClient.AddParamWithValue("@criteria", criteria + "%"); foreach (DataRow row in dbClient.ReadDataTable("SELECT id,username,figure,motto FROM users WHERE username LIKE @criteria;").Rows) { MessengerBuddy match = MessengerBuddy.Parse(row); if (match != null) { matches.Add(match); } } } return(matches); }
public void ReloadPages() { lock (this) { mPages.Clear(); using (DatabaseClient dbClient = IonEnvironment.GetDatabase().GetClient()) { CatalogPage index = CatalogPage.Parse(dbClient.ReadDataRow("SELECT * FROM catalog_pages WHERE parentid = 0 LIMIT 1;")); if (index != null) { // Index = first page! mPages.Add(index); // Fetchs trees and inner pages on index foreach (DataRow childRow in dbClient.ReadDataTable("SELECT * FROM catalog_pages WHERE parentid = " + index.TreeID.ToString() + " ORDER BY orderid ASC;").Rows) { CatalogPage child = CatalogPage.Parse(childRow); if (child != null) { // Add child to index mPages.Add(child); // Is this child a parent? if (child.TreeID > 0) { // Add children to this parent foreach (DataRow pageRow in dbClient.ReadDataTable("SELECT * FROM catalog_pages WHERE parentid = " + child.TreeID.ToString() + " AND treeid = 0 ORDER BY orderid ASC;").Rows) { CatalogPage page = CatalogPage.Parse(pageRow); if (page != null) { mPages.Add(page); } } } } } } } } }
public Habbo GetHabbo(uint ID) { // Prefer active client over Database GameClient client = IonEnvironment.GetHabboHotel().GetClients().GetClientOfHabbo(ID); if (client != null) { return(client.GetHabbo()); } else { Habbo habbo = new Habbo(); if (habbo.LoadByID(IonEnvironment.GetDatabase(), ID)) { return(habbo); } } return(null); }
public Habbo Login(string sUsername, string sPassword) { // Do not use HabboManager.GetHabbo(string) here, as caching is planned to be implemented there Habbo habbo = new Habbo(); if (habbo.LoadByUsername(IonEnvironment.GetDatabase(), sUsername) == false) { throw new IncorrectLoginException("login incorrect: Wrong username"); } if (habbo.Password != sPassword) { throw new IncorrectLoginException("login incorrect: Wrong password"); } // Drop old client (if logged in via other connection) IonEnvironment.GetHabboHotel().GetClients().KillClientOfHabbo(habbo.ID); return(habbo); }
public bool UpdateHabbo(Habbo habbo) { return(IonEnvironment.GetDatabase().UPDATE(habbo)); }