Exemple #1
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();
        }
Exemple #2
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);
            }
        }
Exemple #3
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();
 }
Exemple #4
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);
            }
        }
Exemple #5
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"]);
 }
Exemple #6
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"]);
 }
Exemple #7
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);
        }
Exemple #8
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
        }