Ejemplo n.º 1
0
        public static void InitItems()
        {
            Furnis = new List<FurniTure>();
            RegisteredFurnis = new Dictionary<int, FurniTure>();

            MySQL Query = new MySQL(Init.ServerMySQL);
            Query.Query("SELECT * FROM furniture");

            foreach (DataRow Row in Query.Fetch_Array())
            {
                FurniTure I = new FurniTure();
                I.Id = Convert.ToInt32(Row["id"]);
                I.Type = Row["type"].ToString();
                I.SpriteId = Convert.ToInt32(Row["sprite_id"]);
                I.Width = Convert.ToInt32(Row["width"]);
                I.Length = Convert.ToInt32(Row["length"]);
                I.Name = Row["name"].ToString();
                I.Type = Convert.ToString(Row["type"]);
                I.FurniInteractor = Convert.ToString(Row["furni_type"]);
                I.CanGift = Decoders.ConvertEnumToBool(Row["can_gift"].ToString());
                I.CanRecycle = Decoders.ConvertEnumToBool(Row["can_recycle"].ToString());
                I.CanTrade = Decoders.ConvertEnumToBool(Row["can_trade"].ToString());
                I.CanStack = Decoders.ConvertEnumToBool(Row["can_stack"].ToString());
                I.CanSell = Decoders.ConvertEnumToBool(Row["can_sell"].ToString());
                I.CanWalk = Decoders.ConvertEnumToBool(Row["can_walk"].ToString());
                I.CanSit = Decoders.ConvertEnumToBool(Row["can_sit"].ToString());
                I.Height = Convert.ToDouble(Row["height"]);
                Furnis.Add(I);
                RegisteredFurnis.Add(I.Id, I);
            }
        }
Ejemplo n.º 2
0
        internal void ChangeMotto()
        {
            #region Packet
            this.UserRow["motto"] = User.ActualClientMessage.GetNextString();

            MySQL Lol = new MySQL(Init.ServerMySQL);
            Lol.Query("UPDATE users_characters SET motto = '" + UserRow["motto"] + "' WHERE id = '" + this.UserRow["id"] + "'");

            ServerMessage SUpdateInRoom = new ServerMessage(1567);
            SUpdateInRoom.AppendInt32(-1);
            SUpdateInRoom.AppendString(UserRow["figure"]);
            SUpdateInRoom.AppendString(UserRow["gender"].ToString().ToLower());
            SUpdateInRoom.AppendString(UserRow["motto"]);
            SUpdateInRoom.AppendInt32(485);
            User.sendPacket(SUpdateInRoom);

            ServerMessage SUpdateInRoom2 = new ServerMessage(1567);
            SUpdateInRoom.AppendInt32(0);
            SUpdateInRoom.AppendString(UserRow["figure"]);
            SUpdateInRoom.AppendString(UserRow["gender"].ToString().ToLower());
            SUpdateInRoom2.AppendString(this.UserRow["motto"]);
            SUpdateInRoom2.AppendInt32(485);
            User.sendPacket(SUpdateInRoom2);

            Console.WriteLine(this.UserRow["motto"]);
            //StaticGame.SendPacketToAllRoom(this, SUpdateInRoom);
            #endregion
        }
Ejemplo n.º 3
0
        public HabboUser(User Info)
        {
            this.User = Info;
            int UserId = 1;

            MySQL Lol = new MySQL(Init.ServerMySQL);
            Lol.Query("SELECT * FROM users_characters WHERE Id = '" + UserId + "'");
            this.UserRow = Lol.Fetch_Assoc();
        }
Ejemplo n.º 4
0
        internal void MyRooms()
        {
            #region Navigator - ME
            ServerMessage MyRooms = new ServerMessage(Headers.MyRoomsInit);
            MySQL MyRoomsSQL = new MySQL(Init.ServerMySQL);
            MyRoomsSQL.Query("SELECT * FROM rooms WHERE ownerid = '" + (int)User.HabboUser.UserRow["Id"] + "'");
            MyRooms.AppendInt32(5);
            MyRooms.AppendString("");
            MyRooms.AppendInt32(MyRoomsSQL.Num_Rows()); // Numero de salas

            foreach (DataRow Data in MyRoomsSQL.Fetch_Array())
            {
                List<string> TagList;
                TagList = new List<string>();
                if (Data["tags"].ToString().Contains(";"))
                {
                    string[] Separe = Data["tags"].ToString().Split(';');
                    foreach (string s in Separe)
                    {
                        TagList.Add(s);
                    }
                }

                MyRooms.AppendInt32((int)Data["id"]);
                MyRooms.AppendBoolean(false); // events
                MyRooms.AppendString((string)Data["name"]);
                MyRooms.AppendInt32((int)Data["ownerid"]);
                MyRooms.AppendString((string)User.HabboUser.UserRow["username"]);
                MyRooms.AppendInt32(0);
                MyRooms.AppendInt32((int)Data["usersnow"]);
                MyRooms.AppendInt32((int)Data["maxusers"]);
                MyRooms.AppendString((string)Data["description"]);
                MyRooms.AppendInt32(0);
                MyRooms.AppendInt32((Convert.ToInt32(Data["category"]) == 3) ? 0 : 2);
                MyRooms.AppendInt32((int)Data["score"]);
                MyRooms.AppendInt32(Convert.ToInt32(Data["category"]));
                MyRooms.AppendString("");
                MyRooms.AppendInt32(0);
                MyRooms.AppendInt32(0);
                MyRooms.AppendInt32(TagList.Count);
                foreach (string D in TagList)
                    MyRooms.AppendString(D);
                MyRooms.AppendInt32(0);
                MyRooms.AppendInt32(0);
                MyRooms.AppendInt32(0);

                // booleans
                MyRooms.AppendBoolean(true);
                MyRooms.AppendBoolean(true);
            }
            MyRooms.AppendBoolean(false);
            User.sendPacket(MyRooms);
            #endregion
        }
Ejemplo n.º 5
0
        public static void InitCatalogPages()
        {
            try
            {
                Categories = new List<Catalog>();
                Pages = new List<Catalog>();
                Page = new Dictionary<int, Catalog>();

                MySQL MySql = new MySQL(Init.ServerMySQL);
                MySql.Query("SELECT * FROM catalog_pages ORDER BY order_num ASC");

                foreach (DataRow Row in MySql.Fetch_Array())
                {
                    Catalog C = new Catalog();
                    C.Id = Convert.ToInt32(Row["id"]);
                    C.CategoryId = Convert.ToInt32(Row["categoryid"]);
                    C.Name = Convert.ToString(Row["name"]);
                    C.OpenPage = Decoders.ConvertEnumToBool(Row["page_open"]);
                    C.EnabledPage = Decoders.ConvertEnumToBool(Row["page_enabled"].ToString());
                    C.ClubPage = Decoders.ConvertEnumToBool(Row["club_page"].ToString());
                    C.MinRank = Convert.ToInt32(Row["min_rank"]);
                    C.IconColor = Convert.ToInt32(Row["icon_color"]);
                    C.IconImage = Convert.ToInt32(Row["icon_image"]);
                    C.Extra = Row["page_extra"].ToString();
                    C.HeadLine = Convert.ToString(Row["page_headline"]);
                    C.PageTeaser = Convert.ToString(Row["page_teaser"]);
                    C.Text = Convert.ToString(Row["page_text"]);
                    C.AnotherText = Convert.ToString(Row["page_othertext"]);
                    C.TextDetails = Convert.ToString(Row["page_text_details"]);
                    C.TextSpecial = Convert.ToString(Row["page_special"]);
                    C.TextTeaser = Convert.ToString(Row["page_text_teaser"]);
                    C.PageQuest = int.Parse(Row["questid"].ToString());
                    if (C.CategoryId > -1)
                        Pages.Add(C);
                    else
                        Categories.Add(C);
                    Page.Add(C.Id, C);
                }

                Out.WritePlain("[Zazlak] > Catalog loaded!", ConsoleColor.Green);
            }
            catch (Exception Error)
            {
                Out.WritePlain("[Zazlak] > " + Error.Message, ConsoleColor.DarkRed);
                Console.ReadKey();
                Environment.Exit(0);
            }
        }
Ejemplo n.º 6
0
        public static void addUser(int userID, User User)
        {
            if (_Users.ContainsKey(userID))
            {
                User oldUser = ((User)_Users[userID]);
                oldUser.Disconnect();
                if (_Users.ContainsKey(userID))
                    _Users.Remove(userID);
            }

            MySQL dbClient = new MySQL(Zazlak.Init.ServerMySQL);
            dbClient.Query("SELECT IP FROM users_characters WHERE username = '******' LIMIT 1");
            if (User.IP == (string)dbClient.Fetch_Assoc()["ip"])
            {
                _Users.Add(userID, User);
                //dbClient.runQuery("UPDATE users SET ticket_sso = NULL WHERE id = '" + userID + "' LIMIT 1");
                //dbClient.runQuery("UPDATE users SET logins = logins + 1 WHERE id = '" + userID + "'");
                dbClient.Query("UPDATE users_characters SET lastaccess = '" + (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds + "' WHERE id = '1'");
                dbClient.Query("UPDATE users_characters SET lastaccess = '" + (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds + "' WHERE id = '2'");
                dbClient.Query("UPDATE users_characters SET connected = 1 WHERE id = '" + userID + "'");
                Out.WriteLine(User.HabboUser.UserRow["username"] + " has connected", ConsoleColor.DarkMagenta);
            }
        }
Ejemplo n.º 7
0
 public DataRow GetRoom(int RoomId)
 {
     MySQL RoomsRow = new MySQL(Init.ServerMySQL);
     RoomsRow.Query("SELECT * FROM rooms WHERE id = '" + RoomId + "' LIMIT 1");
     return RoomsRow.Fetch_Assoc();
 }
Ejemplo n.º 8
0
        internal void LoadRoom()
        {
            int RoomId = User.ActualClientMessage.GetNextInt();

            MySQL RoomsRow = new MySQL(Init.ServerMySQL);
            RoomsRow.Query("SELECT * FROM rooms WHERE id = '" + RoomId + "' LIMIT 1");
            Out.WriteLine(RoomsRow.Num_Rows());
            if (RoomsRow.Num_Rows() == 1)
            {
                DataRow RD = RoomsRow.Fetch_Assoc();

                User.HabboUser.CurrentRoomId = RoomId;
                //Habbo.VisitedRooms += RoomId + ";";
                //Habbo.IsOnRoom = true;

                BuildMessage Load = new BuildMessage();
                ServerMessage LoadRooms = new ServerMessage(Headers.LOADROOMS);
                Load.AppendPacket(LoadRooms);

                ServerMessage LoadRooms2 = new ServerMessage(1059);
                LoadRooms2.AppendInt32(77824);
                LoadRooms2.AppendInt32(513);
                Load.AppendPacket(LoadRooms2);

                ServerMessage Model = new ServerMessage(Headers.LOADMODEL);
                Model.AppendString(RD["model"].ToString());
                Model.AppendInt32(RoomId);
                Load.AppendPacket(Model);

                if (RD["wall"].ToString() != "0")
                {
                    ServerMessage SendWallpaper = new ServerMessage(Headers.LOADWALLSFLOORSLANDS);
                    SendWallpaper.AppendString("wallpaper");
                    SendWallpaper.AppendString(RD["wall"]);
                    Load.AppendPacket(SendWallpaper);
                }

                if (RD["floor"].ToString() != "0")
                {
                    ServerMessage SendFloor = new ServerMessage(Headers.LOADWALLSFLOORSLANDS);
                    SendFloor.AppendString("floor");
                    SendFloor.AppendString(RD["floor"]);
                    Load.AppendPacket(SendFloor);
                }

                ServerMessage SendLandscape = new ServerMessage(Headers.LOADWALLSFLOORSLANDS);
                SendLandscape.AppendString("landscape");
                SendLandscape.AppendString(RD["landscape"] + ".0");
                Load.AppendPacket(SendLandscape);

                ServerMessage Unk = new ServerMessage(Headers.UNK);
                Unk.AppendInt32(4);
                Load.AppendPacket(Unk);

                if (RD["OwnerId"] == User.HabboUser.UserRow["id"])
                {
                    ServerMessage LoadPows = new ServerMessage(Headers.LOADPOWS);
                    Load.AppendPacket(LoadPows);
                }

                ServerMessage LoadScore = new ServerMessage(Headers.LOADSCORE);
                LoadScore.AppendInt32((int)RD["score"]);
                LoadScore.AppendBoolean(false);
                Load.AppendPacket(LoadScore);

                ServerMessage LoadEvent = new ServerMessage(Headers.LOADEVENTS);
                LoadEvent.AppendString("-1");
                Load.AppendPacket(LoadEvent);

                //Habbo.Cache.Rooms;
                User.sendPacket(Load);
            }
        }
Ejemplo n.º 9
0
        public static void InitCatalogItems()
        {
            CatalogItems = new List<Items>();
            CatalogItemsForId = new Dictionary<int, Items>();

            MySQL RowItems = new MySQL(Init.ServerMySQL);
            RowItems.Query("SELECT * FROM catalog_items ORDER BY id ASC");

            foreach (DataRow Row in RowItems.Fetch_Array())
            {
                Items I = new Items();
                I.Id = Convert.ToInt32(Row["id"]);
                I.PageId = Convert.ToInt32(Row["pageid"]);
                I.Name = Convert.ToString(Row["name"]);
                I.Cost_Credits = Convert.ToInt32(Row["cost_credits"]);
                I.Cost_Pixels = Convert.ToInt32(Row["cost_pixels"]);
                I.Cost_AnythingQuestPoint = Convert.ToInt32(Row["cost_quest"]);
                if (Convert.ToInt32(Row["cost_quest"]) > 0)
                {
                    I.FinalPixels_orQuest = Convert.ToInt32(Row["cost_quest"]);
                }
                else
                {
                    I.FinalPixels_orQuest = Convert.ToInt32(Row["cost_pixels"]);
                }
                I.Amount = Convert.ToInt32(Row["amount"]);
                I.extraAm = Convert.ToString(Row["extraamounts"]);
                I.ExtraAmounts = new Dictionary<int, int>();
                if (I.extraAm.Contains(";"))
                {
                    string[] separe = I.extraAm.Split(';');
                    foreach (string s in separe)
                    {
                        if (s == "")
                            continue;

                        string[] s2 = s.Split(',');

                        if (I.ExtraAmounts.ContainsKey(int.Parse(s2[0])))
                            continue;

                        I.ExtraAmounts.Add(int.Parse(s2[0]), int.Parse(s2[1]));
                    }
                }
                I.FurniId = Convert.ToString(Row["furni_id"]);
                I.ItemIds = new List<int>();
                if (I.FurniId.Contains(";"))
                {
                    string[] separe = I.FurniId.Split(';');
                    foreach (string s in separe)
                    {
                        if (I.ItemIds.Contains(int.Parse(s)))
                            continue;

                        if (s == "")
                            continue;

                        I.ItemIds.Add(int.Parse(s));
                    }
                }
                else
                    I.ItemIds.Add(int.Parse(I.FurniId));
                I.IsClub = int.Parse(Row["is_club"].ToString());
                I.ExtraInformation = Convert.ToString(Row["extrainformation"]);
                CatalogItems.Add(I);
                CatalogItemsForId.Add(I.Id, I);
            }

            Out.WritePlain("[Zazlak] > Catalog Items loaded!", ConsoleColor.Green);
        }
Ejemplo n.º 10
0
 public static string getUserName(int userID)
 {
     MySQL dbClient = new MySQL(Zazlak.Init.ServerMySQL);
     dbClient.Query("SELECT name FROM users WHERE id = '" + userID + "' LIMIT 1");
     return Convert.ToString(dbClient.Fetch_Assoc()["username"]);
 }
Ejemplo n.º 11
0
 public static int getUserID(string userName)
 {
     MySQL dbClient = new MySQL(Zazlak.Init.ServerMySQL);
     dbClient.Query("SELECT id FROM users WHERE name = " + userName + "' LIMIT 1");
     return Convert.ToInt32(dbClient.Fetch_Assoc()["id"]);
 }
Ejemplo n.º 12
0
 public static bool userExists(int userID)
 {
     MySQL dbClient = new MySQL(Zazlak.Init.ServerMySQL);
     dbClient.Query("SELECT id FROM users WHERE id = '" + userID + "'");
     return Convert.ToBoolean(dbClient.Num_Rows());
 }
Ejemplo n.º 13
0
        internal void UserProfile()
        {
            int UserId = User.ActualClientMessage.GetNextInt();
            MySQL Lol = new MySQL(Init.ServerMySQL);
            Lol.Query("SELECT * FROM users_characters WHERE Id = '" + UserId + "'");
            this.UserRow = Lol.Fetch_Assoc();

            if (UserRow["connected"].ToString() == "1")
            {
                Connected = true;
            }
            else
            {
                Connected = false;
            }

            ServerMessage Profile = new ServerMessage(Headers.SendProfile);
            Profile.AppendInt32(UserRow["id"]);
            Profile.AppendString(UserRow["username"]);
            Profile.AppendString(UserRow["figure"]);
            Profile.AppendString(UserRow["motto"]);
            Profile.AppendString(UserRow["createdon"]);
            Profile.AppendInt32(1337);
            Profile.AppendInt32(2);
            Profile.AppendBoolean(false);
            Profile.AppendBoolean(false);
            Profile.AppendBoolean(Connected);
            Profile.AppendInt32(0);
            Profile.AppendInt32(((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds - (int)User.HabboUser.UserRow["lastaccess"]));
            Profile.AppendBoolean(true);
            this.User.sendPacket(Profile);

            ServerMessage SendCredits = new ServerMessage(Headers.SendCredits);
            SendCredits.AppendString("1000.0");
            this.User.sendPacket(SendCredits);
        }
Ejemplo n.º 14
0
        internal void UpdateLook()
        {
            #region Packet
            string Gender = "M";

            if (User.ActualClientMessage.GetNextString() == "F")
                Gender = "F";

            string NewLook = User.ActualClientMessage.GetNextString();

            MySQL Lol = new MySQL(Init.ServerMySQL);
            Lol.Query("UPDATE users_characters SET figure = '" + NewLook + "', gender = '" + Gender + "' WHERE id = '" + this.UserRow["id"] + "'");

            this.UserRow["figure"] = NewLook;
            this.UserRow["gender"] = Gender;

            ServerMessage SUpdateInRoom = new ServerMessage(1567);
            SUpdateInRoom.AppendBreak();
            SUpdateInRoom.AppendString(NewLook);
            SUpdateInRoom.AppendString(Gender.ToLower());
            SUpdateInRoom.AppendString(this.UserRow["motto"]);
            SUpdateInRoom.AppendInt32(0);
            User.sendPacket(SUpdateInRoom);

            /*
            ServerMessage SUpdateInRoom2 = new ServerMessage(1567);
            SUpdateInRoom.AppendInt32(User.connectionID);
            SUpdateInRoom.AppendString(UserRow["figure"]);
            SUpdateInRoom.AppendString(UserRow["gender"].ToString().ToLower());
            SUpdateInRoom2.AppendString(this.UserRow["motto"]);
            SUpdateInRoom2.AppendInt32(0);
            //StaticGame.SendPacketToAllRoom(this, SUpdateInRoom);
            User.sendPacket(SUpdateInRoom2);
            */
            #endregion
        }
Ejemplo n.º 15
0
        internal void sendPacket()
        {
            #region Packet
            ServerMessage SendCredits = new ServerMessage(Headers.SendCredits);
            SendCredits.AppendString(Convert.ToInt32(UserRow["credits"]) + ".0");
            this.User.sendPacket(SendCredits);

            ServerMessage SendUser = new ServerMessage(Headers.SendUserData);
            SendUser.AppendInt32(Convert.ToInt32(UserRow["id"]));
            SendUser.AppendString(Convert.ToString(UserRow["username"]));
            SendUser.AppendString("hr-155-32.hd-185-2.ch-3030-62.lg-275-62.sh-290-62,s-0.g-1.d-3.h-3.a-0");
            SendUser.AppendString(Convert.ToString(UserRow["gender"]).ToLower());
            SendUser.AppendString(Convert.ToString(UserRow["motto"]));
            SendUser.AppendString("habbowall");
            SendUser.AppendInt32(0);
            SendUser.AppendBoolean(false);
            SendUser.AppendInt32(0); // Friends
            SendUser.AppendInt32(3);
            SendUser.AppendInt32(3);
            SendUser.AppendBoolean(true);
            SendUser.AppendString("02-05-2012 08:05:10");
            this.User.sendPacket(SendUser);

            ServerMessage Friends = new ServerMessage(Headers.FriendsBarInit);
            Friends.AppendInt32(100); // amount friends normal
            Friends.AppendInt32(100); // amount max friends normal
            Friends.AppendInt32(200); // amount max friends HC?
            Friends.AppendInt32(300); // amount max friends VIP?

            Friends.AppendInt32(0); // amount categorie

            MySQL FriendSQL = new MySQL(Init.ServerMySQL);
            FriendSQL.Query("SELECT user_two_id FROM users_friends WHERE user_one_id = '"+UserRow["id"]+"'");

            Friends.AppendInt32(FriendSQL.Num_Rows()); // amount friends

            foreach (DataRow TheRow in FriendSQL.Fetch_Array())
            {
                MySQL TheFriend = new MySQL(Init.ServerMySQL);
                TheFriend.Query("SELECT * FROM users_characters WHERE id = '"+TheRow["user_two_id"]+"'");
                this.Row = TheFriend.Fetch_Assoc();

                if (Row["connected"].ToString() == "1")
                {
                    Connected = true;
                }
                else
                {
                    Connected = false;
                }

                Friends.AppendInt32(Row["id"]); // id
                Friends.AppendString(Row["username"]); // name
                Friends.AppendInt32(1); // ?
                Friends.AppendBoolean(Connected); // isonline
                Friends.AppendBoolean(false); // isinroom
                Friends.AppendString(Row["figure"]); // figure
                Friends.AppendInt32(0); // ?
                Friends.AppendString(Row["motto"]); // motto
                Friends.AppendString("Mikkel"); // facebook name
                Friends.AppendString(Row["createdon"]);
                Friends.AppendBoolean(false);
            }

            Friends.AppendInt32(100); // ?
            Friends.AppendInt32(0); // ?
            this.User.sendPacket(Friends);

            ServerMessage Club = new ServerMessage(Headers.VipInit);
            Club.AppendString("club_habbo");
            Club.AppendInt32(10); // Dias
            Club.AppendInt32(0);
            Club.AppendInt32(0);
            Club.AppendInt32(1);
            Club.AppendBoolean(false);
            Club.AppendBoolean(true);
            Club.AppendInt32(0);
            Club.AppendInt32(0);
            Club.AppendInt32(0);
            this.User.sendPacket(Club);

            ServerMessage SendPacket = new ServerMessage(2994);
            SendPacket.AppendString("Hola");
            SendPacket.AppendBoolean(false);
            SendPacket.AppendBoolean(false);
            this.User.sendPacket(SendPacket);

            ServerMessage SendPixels = new ServerMessage(Headers.SendPixels);
            SendPixels.AppendInt32(1);
            SendPixels.AppendInt32(0);
            SendPixels.AppendInt32(UserRow["pixels"]);
            this.User.sendPacket(SendPixels);
            #endregion
        }