Ejemplo n.º 1
0
 public static GroupsManager AddGuild(int id, string name, int ownerid, string ownername, string description, int roomid, string image, int customcolor1, int customcolor2, int guildbase, int guildbasecolor, List <int> guildstates, string htmlcolor1, string htmlcolor2, string datecreated, Dictionary <int, string> members, List <int> petitions, int type, int rightstype)
 {
     using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
     {
         try
         {
             try
             {
                 id = dbClient.ReadInt32("SELECT ID FROM groups ORDER BY ID DESC LIMIT 1") + 1;
             }
             catch
             {
                 id = 1;
             }
             string str = "";
             foreach (int num in guildstates)
             {
                 str = str + num + ";";
             }
             str = str.Substring(0, str.Length - 1);
             dbClient.AddParamWithValue("id", id);
             dbClient.AddParamWithValue("name", name);
             dbClient.AddParamWithValue("ownerid", ownerid);
             dbClient.AddParamWithValue("description", description);
             dbClient.AddParamWithValue("roomid", roomid);
             dbClient.AddParamWithValue("image", image);
             dbClient.AddParamWithValue("htmlcolor1", htmlcolor1);
             dbClient.AddParamWithValue("htmlcolor2", htmlcolor2);
             dbClient.AddParamWithValue("datecreated", datecreated);
             dbClient.AddParamWithValue("guildstates", str);
             dbClient.AddParamWithValue("guildbase", guildbase);
             dbClient.AddParamWithValue("guildbasecolor", guildbasecolor);
             dbClient.ExecuteQuery("INSERT INTO groups (`id`,`name`,`ownerid`,`desc`,`roomid`,`badge`,`color_one`,`color_two`,`created`,`GuildStates`,`GuildBase`,`GuildBaseColor`) VALUES (@id, @name, @ownerid, @description, @roomid, @image, @htmlcolor1, @htmlcolor2, @datecreated,@guildstates,@guildbase,@guildbasecolor);");
             dbClient.ExecuteQuery("INSERT INTO group_memberships (groupid, userid) VALUES (" + id + "," + ownerid + ")");
         }catch (Exception ex)
         {
             Console.WriteLine(ex.ToString());
         }
         GroupsManager newGuild = new GroupsManager(id, dbClient.ReadDataRow("SELECT * FROM groups WHERE id=" + id + " LIMIT 1"), dbClient);
         Groups.GroupsManager.Add(id, newGuild);
         return(newGuild);
     }
 }
Ejemplo n.º 2
0
 public static void RemoveGroup(GroupsManager guild)
 {
     using(DatabaseClient dbClient = Essential.GetDatabase().GetClient())
     {
         dbClient.ExecuteQuery("DELETE FROM groups WHERE id=" + guild.Id);
         dbClient.ExecuteQuery("DELETE FROM group_memberships WHERE groupid=" + guild.Id);
         dbClient.ExecuteQuery("DELETE FROM group_requests WHERE groupid=" + guild.Id);
         dbClient.ExecuteQuery("UPDATE user_stats SET groupid=0 WHERE groupid=" + guild.Id);
         //dbClient.ExecuteQuery("UPDATE items SET guild_data='0;0;0' WHERE guild_data LIKE '" + guild.Id + ";%'");
         foreach(GameClient gc in Essential.GetGame().GetClientManager().GetClients())
         {
             if(gc != null && gc.GetHabbo() != null&& gc.GetHabbo().InGuild(guild.Id))
             {
                 if (gc.GetHabbo().FavouriteGroup == guild.Id)
                     gc.GetHabbo().FavouriteGroup = 0;
                 gc.GetHabbo().RefreshGuilds();
             }
         }
         Groups.GroupsManager.Remove(guild.Id);
     }
 }
Ejemplo n.º 3
0
        public static void UpdateGroup(DatabaseClient class6_0, int int_0)
        {
            GroupsManager @class = Groups.GetGroupById(int_0);

            if (@class != null)
            {
                DataRow Row = class6_0.ReadDataRow("SELECT * FROM groups WHERE Id = " + int_0 + " LIMIT 1");
                @class.Name        = (string)Row["name"];
                @class.Badge       = (string)Row["badge"];
                @class.RoomId      = (uint)Row["roomid"];
                @class.Description = (string)Row["desc"];
                @class.Locked      = (string)Row["locked"];
                @class.ColorOne    = (string)Row["color_one"];
                @class.ColorTwo    = (string)Row["color_two"];
                @class.Created     = Essential.TimestampToDate(double.Parse((string)Row["created"])).ToShortDateString();
                @class.Members.Clear();
                DataTable dataTable = class6_0.ReadDataTable("SELECT userid FROM group_memberships WHERE groupid = " + int_0 + ";");
                foreach (DataRow dataRow2 in dataTable.Rows)
                {
                    @class.JoinGroup((int)dataRow2["userid"]);
                }
            }
        }
Ejemplo n.º 4
0
 public static void RemoveGroup(GroupsManager guild)
 {
     using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
     {
         dbClient.ExecuteQuery("DELETE FROM groups WHERE id=" + guild.Id);
         dbClient.ExecuteQuery("DELETE FROM group_memberships WHERE groupid=" + guild.Id);
         dbClient.ExecuteQuery("DELETE FROM group_requests WHERE groupid=" + guild.Id);
         dbClient.ExecuteQuery("UPDATE user_stats SET groupid=0 WHERE groupid=" + guild.Id);
         //dbClient.ExecuteQuery("UPDATE items SET guild_data='0;0;0' WHERE guild_data LIKE '" + guild.Id + ";%'");
         foreach (GameClient gc in Essential.GetGame().GetClientManager().GetClients())
         {
             if (gc != null && gc.GetHabbo() != null && gc.GetHabbo().InGuild(guild.Id))
             {
                 if (gc.GetHabbo().FavouriteGroup == guild.Id)
                 {
                     gc.GetHabbo().FavouriteGroup = 0;
                 }
                 gc.GetHabbo().RefreshGuilds();
             }
         }
         Groups.GroupsManager.Remove(guild.Id);
     }
 }
Ejemplo n.º 5
0
 public static GroupsManager AddGuild(int id, string name, int ownerid, string ownername, string description, int roomid, string image, int customcolor1, int customcolor2, int guildbase, int guildbasecolor, List<int> guildstates, string htmlcolor1, string htmlcolor2, string datecreated, Dictionary<int, string> members, List<int> petitions, int type, int rightstype)
 {
     using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
     {
         try
         {
             try
             {
                 id = dbClient.ReadInt32("SELECT ID FROM groups ORDER BY ID DESC LIMIT 1") + 1;
             }
             catch
             {
                 id = 1;
             }
             string str = "";
             foreach (int num in guildstates)
             {
                 str = str + num + ";";
             }
             str = str.Substring(0, str.Length - 1);
             dbClient.AddParamWithValue("id", id);
             dbClient.AddParamWithValue("name", name);
             dbClient.AddParamWithValue("ownerid", ownerid);
             dbClient.AddParamWithValue("description", description);
             dbClient.AddParamWithValue("roomid", roomid);
             dbClient.AddParamWithValue("image", image);
             dbClient.AddParamWithValue("htmlcolor1", htmlcolor1);
             dbClient.AddParamWithValue("htmlcolor2", htmlcolor2);
             dbClient.AddParamWithValue("datecreated", datecreated);
             dbClient.AddParamWithValue("guildstates", str);
             dbClient.AddParamWithValue("guildbase", guildbase);
             dbClient.AddParamWithValue("guildbasecolor", guildbasecolor);
             dbClient.ExecuteQuery("INSERT INTO groups (`id`,`name`,`ownerid`,`desc`,`roomid`,`badge`,`color_one`,`color_two`,`created`,`GuildStates`,`GuildBase`,`GuildBaseColor`) VALUES (@id, @name, @ownerid, @description, @roomid, @image, @htmlcolor1, @htmlcolor2, @datecreated,@guildstates,@guildbase,@guildbasecolor);");
             dbClient.ExecuteQuery("INSERT INTO group_memberships (groupid, userid) VALUES (" + id + "," + ownerid + ")");
         }catch(Exception ex)
         {
             Console.WriteLine(ex.ToString());
         }
             GroupsManager newGuild = new GroupsManager(id, dbClient.ReadDataRow("SELECT * FROM groups WHERE id=" + id + " LIMIT 1"), dbClient);
         Groups.GroupsManager.Add(id, newGuild);
         return newGuild;
     }
 }