public void Handle(GameClient session, ClientMessage message)
        {
            bool hideFull   = message.PopWiredBoolean();
            int  caterogyId = message.PopWiredInt32();

            if (caterogyId == GetRoomsMessageEvent.PRIVATE_ROOMS) //private rooms
            {
                ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                Message.Init(r26Outgoing.SendRooms);
                Message.AppendBoolean(hideFull);
                Message.AppendInt32(caterogyId);
                Message.AppendInt32(GetRoomsMessageEvent.PRIVATE); //type
                Message.AppendString("Guestrooms");                //caption
                Message.AppendInt32(0);                            //unknown
                Message.AppendInt32(10000);                        //unknown
                Message.AppendInt32(GetRoomsMessageEvent.NONE);    //parent id
                Message.AppendInt32(0);                            //rooms count

                foreach (FlatCat flatCat in Skylight.GetGame().GetNavigatorManager().GetFlatCats())
                {
                    int usersNow = 0;
                    int usersMax = 0;
                    foreach (RoomData room in Skylight.GetGame().GetRoomManager().GetLoadedRooms().Where(r => r.RoomData.Type == "private" && r.RoomData.UsersNow > 0 && r.RoomData.Category == flatCat.Id).OrderByDescending(r => r.RoomData.UsersNow).Take(50).Select(r => r.RoomData).ToList())
                    {
                        usersNow += room.UsersNow;
                        usersMax += room.UsersMax;
                    }

                    Message.AppendInt32(Skylight.GetGame().GetNavigatorManager().GetOldSchoolCategoryThingy2()[new KeyValuePair <int, bool>(flatCat.Id, true)]); //id
                    Message.AppendBoolean(false);                                                                                                                //is room
                    Message.AppendString(flatCat.Caption);
                    Message.AppendInt32(usersNow);                                                                                                               //users now
                    Message.AppendInt32(usersMax);                                                                                                               //users max
                    Message.AppendInt32(GetRoomsMessageEvent.PRIVATE_ROOMS);                                                                                     //parent id
                }

                session.SendMessage(Message);
            }
            else if (caterogyId == GetRoomsMessageEvent.PUBLIC_ROOMS) //public rooms
            {
                ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                Message.Init(r26Outgoing.SendRooms);
                Message.AppendBoolean(hideFull);
                Message.AppendInt32(caterogyId);
                Message.AppendInt32(GetRoomsMessageEvent.PUBLIC); //type
                Message.AppendString("Publics");                  //caption
                Message.AppendInt32(0);                           //unknown
                Message.AppendInt32(10000);                       //unknown
                Message.AppendInt32(GetRoomsMessageEvent.NONE);   //parent id

                foreach (PublicItem category in Skylight.GetGame().GetNavigatorManager().GetPublicRoomItems().Where(i => i.Type == PublicItemType.CATEGORY && i.ParentCategoryID == 0))
                {
                    int usersNow = 0;
                    int usersMax = 0;
                    foreach (PublicItem item in Skylight.GetGame().GetNavigatorManager().GetPublicRoomItems().Where(i => i.ParentCategoryID == category.ID))
                    {
                        usersNow += item.RoomData.UsersNow;
                        usersMax += item.RoomData.UsersMax;
                    }

                    Message.AppendInt32(Skylight.GetGame().GetNavigatorManager().GetOldSchoolCategoryThingy2()[new KeyValuePair <int, bool>(category.ID, false)]); //id
                    Message.AppendBoolean(false);                                                                                                                  //is room
                    Message.AppendString(category.Caption);                                                                                                        //name
                    Message.AppendInt32(usersNow);                                                                                                                 //users now
                    Message.AppendInt32(usersMax);                                                                                                                 //users max
                    Message.AppendInt32(GetRoomsMessageEvent.PUBLIC_ROOMS);                                                                                        //parent id
                }

                foreach (PublicItem item in Skylight.GetGame().GetNavigatorManager().GetPublicRoomItems().Where(i => i.Type != PublicItemType.CATEGORY && i.ParentCategoryID == 0))
                {
                    Message.AppendUInt(item.RoomData.ID);            //id
                    Message.AppendBoolean(true);                     //is room
                    Message.AppendString(item.RoomData.Name);        //name
                    Message.AppendInt32(item.RoomData.UsersNow);     //visitors now
                    Message.AppendInt32(item.RoomData.UsersMax);     //visitors max
                    Message.AppendInt32(caterogyId);                 //category inside
                    Message.AppendString(item.RoomData.Description); //desc
                    Message.AppendUInt(item.RoomData.ID);            //id
                    Message.AppendBoolean(false);                    //unknwon
                    Message.AppendString(item.RoomData.PublicCCTs);  //ccts
                    Message.AppendBoolean(false);                    //unknwon
                    Message.AppendBoolean(true);                     //unknwon
                }

                session.SendMessage(Message);
            }
            else //private room category
            {
                object category;
                Skylight.GetGame().GetNavigatorManager().GetOldSchoolCategoryThingy().TryGetValue(caterogyId, out category);

                if (category is FlatCat)
                {
                    FlatCat flatCat = (FlatCat)category;

                    ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                    Message.Init(r26Outgoing.SendRooms);
                    Message.AppendBoolean(hideFull);
                    Message.AppendInt32(caterogyId);
                    Message.AppendInt32(GetRoomsMessageEvent.PRIVATE);       //type
                    Message.AppendString(flatCat.Caption);
                    Message.AppendInt32(0);                                  //unknown
                    Message.AppendInt32(10000);                              //unknown
                    Message.AppendInt32(GetRoomsMessageEvent.PRIVATE_ROOMS); //parent id

                    List <Room> rooms = Skylight.GetGame().GetRoomManager().GetLoadedRooms().Where(r => !r.RoomData.IsPublicRoom && r.RoomData.Category == flatCat.Id).Take(50).ToList();

                    Message.AppendInt32(rooms.Count);
                    foreach (Room room in rooms)
                    {
                        Message.AppendUInt(room.RoomData.ID);                                                                   //id
                        Message.AppendString(room.RoomData.Name);                                                               //name
                        Message.AppendString(Skylight.GetGame().GetGameClientManager().GetUsernameByID(room.RoomData.OwnerID)); //owner
                        Message.AppendString(room.RoomData.State == RoomStateType.OPEN ? "open" : room.RoomData.State == RoomStateType.LOCKED ? "closed" : "password");
                        Message.AppendInt32(room.RoomData.UsersNow);                                                            //visitors now
                        Message.AppendInt32(room.RoomData.UsersMax);                                                            //visitors max
                        Message.AppendString(room.RoomData.Description);                                                        //desc
                    }

                    session.SendMessage(Message);
                }
                else if (category is PublicItem)
                {
                    PublicItem item = (PublicItem)category;

                    if (item.Type == PublicItemType.CATEGORY)
                    {
                        ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                        Message.Init(r26Outgoing.SendRooms);
                        Message.AppendBoolean(hideFull);
                        Message.AppendInt32(caterogyId);
                        Message.AppendInt32(GetRoomsMessageEvent.PUBLIC);       //type
                        Message.AppendString(item.Caption);                     //caption
                        Message.AppendInt32(0);                                 //unknown
                        Message.AppendInt32(10000);                             //unknown
                        Message.AppendInt32(GetRoomsMessageEvent.PUBLIC_ROOMS); //parent id

                        foreach (PublicItem item_ in Skylight.GetGame().GetNavigatorManager().GetPublicRoomItems().Where(i => i.Type != PublicItemType.CATEGORY && i.ParentCategoryID == item.ID))
                        {
                            Message.AppendUInt(item_.RoomData.ID);            //id
                            Message.AppendBoolean(true);                      //is room
                            Message.AppendString(item_.RoomData.Name);        //name
                            Message.AppendInt32(item_.RoomData.UsersNow);     //visitors now
                            Message.AppendInt32(item_.RoomData.UsersMax);     //visitors max
                            Message.AppendInt32(caterogyId);                  //category inside
                            Message.AppendString(item_.RoomData.Description); //desc
                            Message.AppendUInt(item_.RoomData.ID);            //id
                            Message.AppendBoolean(false);                     //unknwon
                            Message.AppendString(item_.RoomData.PublicCCTs);  //ccts
                            Message.AppendBoolean(false);                     //unknwon
                            Message.AppendBoolean(true);                      //unknwon
                        }

                        session.SendMessage(Message);
                    }
                }
            }
        }
Beispiel #2
0
        public ServerMessage GetOffers(int minPrice, int maxPrice, string search, int order)
        {
            this.Reorganize(); //do it before shiet

            IEnumerable <MarketplaceOffer> rawList = null;

            if (minPrice >= 0 && maxPrice >= 0)
            {
                rawList = this.Offers.Values.Where(o => o.Price > minPrice && o.Price < maxPrice && Skylight.GetGame().GetItemManager().TryGetItem(o.ItemID).PublicName.Contains(search));
            }
            else if (minPrice >= 0)
            {
                rawList = this.Offers.Values.Where(o => o.Price > minPrice && Skylight.GetGame().GetItemManager().TryGetItem(o.ItemID).PublicName.Contains(search));
            }
            else if (maxPrice >= 0)
            {
                rawList = this.Offers.Values.Where(o => o.Price < maxPrice && Skylight.GetGame().GetItemManager().TryGetItem(o.ItemID).PublicName.Contains(search));
            }
            else
            {
                rawList = this.Offers.Values.Where(o => Skylight.GetGame().GetItemManager().TryGetItem(o.ItemID).PublicName.Contains(search));
            }

            List <IGrouping <uint, MarketplaceOffer> > offers = null;

            switch (order)
            {
            case 1:     //most expensive first
            {
                offers = rawList.OrderByDescending(o => o.Price).GroupBy(o => o.ItemID).ToList();
                break;
            }

            case 2:     //most cheap first
            {
                offers = rawList.OrderBy(o => o.Price).GroupBy(o => o.ItemID).ToList();
                break;
            }

            case 3:     //most traded today
            {
                offers = new List <IGrouping <uint, MarketplaceOffer> >();

                foreach (IGrouping <uint, MarketplaceOffer> sold in this.Sold.Values.Where(s => DateTime.Today.Date == TimeUtilies.UnixTimestampToDateTime(s.SoldTimestamp).Date).GroupBy(o => o.ItemID).OrderByDescending(g => g.Count()))
                {
                    offers.AddRange(rawList.Where(o => o.ItemID == sold.Key).GroupBy(o => o.ItemID).ToList());
                }
                break;
            }

            case 4:     //lest traded today
            {
                offers = new List <IGrouping <uint, MarketplaceOffer> >();

                foreach (IGrouping <uint, MarketplaceOffer> sold in this.Sold.Values.Where(s => DateTime.Today.Date == TimeUtilies.UnixTimestampToDateTime(s.SoldTimestamp).Date).GroupBy(o => o.ItemID).OrderBy(g => g.Count()))
                {
                    offers.AddRange(rawList.Where(o => o.ItemID == sold.Take(1).ToList()[0].ItemID).GroupBy(o => o.ItemID).ToList());
                }
                break;
            }

            case 5:     //most offers avaible
            {
                offers = rawList.GroupBy(o => o.ItemID).OrderByDescending(g => g.Count()).ToList();
                break;
            }

            case 6:     //leasts offers avaible
            {
                offers = rawList.GroupBy(o => o.ItemID).OrderBy(g => g.Count()).ToList();
                break;
            }

            default:
            {
                offers = new List <IGrouping <uint, MarketplaceOffer> >();
                break;
            }
            }

            ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);

            message.Init(r63aOutgoing.MarketplaceOffers);
            message.AppendInt32(offers.Count > 500 ? 500 : offers.Count); //how many we send
            foreach (IGrouping <uint, MarketplaceOffer> offerGroup in offers.Take(500))
            {
                foreach (MarketplaceOffer offer in offerGroup.OrderBy(o => o.Price).Take(1))
                {
                    Item item = Skylight.GetGame().GetItemManager().TryGetItem(offer.ItemID);

                    message.AppendUInt(offer.ID);
                    message.AppendInt32(1); //state
                    message.AppendInt32(item.IsFloorItem ? 1 : 2);
                    message.AppendInt32(item.SpriteID);
                    message.AppendString("");
                    message.AppendInt32(this.CalcCompremission(offer.Price) + offer.Price); //compremission + original price
                    message.AppendInt32(item.SpriteID);                                     //unknown but phx says this.. so idk :s

                    int arvgPrice = this.Sold.Values.Where(s => s.ItemID == offer.ItemID && TimeUtilies.GetUnixTimestamp() - s.SoldTimestamp <= ServerConfiguration.MarketplaceAvaragePriceDays * 86400.0).Sum(s => this.CalcCompremission(s.Price) + s.Price);
                    int soldCount = this.Sold.Values.Count(s => s.ItemID == offer.ItemID && TimeUtilies.GetUnixTimestamp() - s.SoldTimestamp <= ServerConfiguration.MarketplaceAvaragePriceDays * 86400.0);
                    if (soldCount > 0)
                    {
                        message.AppendInt32(arvgPrice / soldCount); //arvgprice / sold
                    }
                    else
                    {
                        message.AppendInt32(0); //arvgprice / sold
                    }

                    message.AppendInt32(offerGroup.Count(g => g.ItemID == offer.ItemID)); //amount in sale
                }
            }
            message.AppendInt32(offers.Count); //total count

            return(message);
        }
Beispiel #3
0
 public ServerMessage Handle(T handler)
 {
     return(BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486, r63cOutgoing.TradeRequireConfirm));
 }
Beispiel #4
0
        public override bool OnUse(GameClient session, string[] args)
        {
            if (session.GetHabbo().IsJonny)
            {
                try
                {
                    if (args.Length >= 2)
                    {
                        switch (args[1])
                        {
                        case "pickall":
                        {
                            GameClient target = null;
                            if (args.Length >= 3)
                            {
                                target = Skylight.GetGame().GetGameClientManager().GetGameClientByUsername(args[2]);
                            }

                            foreach (RoomItem item in target == null ? session.GetHabbo().GetRoomSession().GetRoom().RoomItemManager.GetFloorItems() : target.GetHabbo().GetRoomSession().GetRoom().RoomItemManager.GetFloorItems())
                            {
                                ServerMessage FloorItemRemoved = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                FloorItemRemoved.Init(r63aOutgoing.RemoveFloorItemFromRoom);
                                FloorItemRemoved.AppendString(item.ID.ToString());
                                FloorItemRemoved.AppendInt32(0);

                                if (target != null)
                                {
                                    target.SendMessage(FloorItemRemoved);
                                }
                                else
                                {
                                    session.GetHabbo().GetRoomSession().GetRoom().SendToAll(FloorItemRemoved);
                                }
                            }

                            foreach (RoomItem item in target == null ? session.GetHabbo().GetRoomSession().GetRoom().RoomItemManager.GetWallItems() : target.GetHabbo().GetRoomSession().GetRoom().RoomItemManager.GetFloorItems())
                            {
                                ServerMessage WallItemRemoved = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                WallItemRemoved.Init(r63aOutgoing.RemoveWallItemFromRoom);
                                WallItemRemoved.AppendString(item.ID.ToString());
                                WallItemRemoved.AppendInt32(0);

                                if (target != null)
                                {
                                    target.SendMessage(WallItemRemoved);
                                }
                                else
                                {
                                    session.GetHabbo().GetRoomSession().GetRoom().SendToAll(WallItemRemoved);
                                }
                            }
                        }
                        break;

                        case "say":
                        {
                            if (args.Length >= 5)
                            {
                                GameClient target = Skylight.GetGame().GetGameClientManager().GetGameClientByUsername(args[3]);
                                if (target != null)
                                {
                                    string        message = TextUtilies.MergeArrayToString(args, 4);
                                    ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                    Message.Init(r63aOutgoing.Say);
                                    Message.AppendInt32(target.GetHabbo().GetRoomSession().GetRoomUser().VirtualID);

                                    Dictionary <int, string> links = new Dictionary <int, string>();
                                    if (message.Contains("http://") || message.Contains("www.") || message.Contains("https://"))
                                    {
                                        string[] words = message.Split(' ');
                                        message = "";

                                        foreach (string word in words)
                                        {
                                            if (TextUtilies.ValidURL(word))
                                            {
                                                int index = links.Count;
                                                links.Add(index, word);

                                                message += " {" + index + "}";
                                            }
                                            else
                                            {
                                                message += " " + word;
                                            }
                                        }
                                    }
                                    Message.AppendString(message);
                                    Message.AppendInt32(RoomUnit.GetGesture(message.ToLower()));
                                    Message.AppendInt32(links.Count);         //links count
                                    foreach (KeyValuePair <int, string> link in links)
                                    {
                                        Message.AppendString("/redirect.php?url=" + link.Value);
                                        Message.AppendString(link.Value);
                                        Message.AppendBoolean(true); //trushed, can link be opened
                                    }
                                    Message.AppendInt32(0);          //unknown

                                    int amount = int.Parse(args[2]);
                                    for (int i = 0; i < amount; i++)
                                    {
                                        target.SendMessage(Message);
                                    }
                                }
                            }
                        }
                        break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    session.SendNotif(ex.ToString());
                }

                return(true);
            }

            return(false);
        }
Beispiel #5
0
        public void Handle(GameClient session, ClientMessage message)
        {
            if (session.FlagmeCommandUsed)
            {
                if (session.GetHabbo().HasPermission("cmd_flagme"))
                {
                    string username = TextUtilies.FilterString(message.PopFixedString());
                    if (username.Length < 3) //to short
                    {
                        ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                        message_.Init(r63aOutgoing.ValidUsername);
                        message_.AppendInt32(2); //result
                        message_.AppendString(username);
                        message_.AppendInt32(0); //suggested names
                        session.SendMessage(message_);
                    }
                    else if (username.Length > 15) // too long
                    {
                        ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                        message_.Init(r63aOutgoing.ValidUsername);
                        message_.AppendInt32(3); //result
                        message_.AppendString(username);
                        message_.AppendInt32(0); //suggested names
                        session.SendMessage(message_);
                    }
                    else if (username.Contains(" ") || !Regex.IsMatch(username, "^[-a-zA-Z0-9._:,]+$") || TextUtilies.HaveBlacklistedWords(username)) //invalid name
                    {
                        ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                        message_.Init(r63aOutgoing.ValidUsername);
                        message_.AppendInt32(4); //result
                        message_.AppendString(username);
                        message_.AppendInt32(0); //suggested names
                        session.SendMessage(message_);
                    }
                    else if (Skylight.GetGame().GetGameClientManager().UsernameExits(username)) //name already exits
                    {
                        ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                        message_.Init(r63aOutgoing.ValidUsername);
                        message_.AppendInt32(5); //result
                        message_.AppendString(username);
                        message_.AppendInt32(0); //suggested names
                        session.SendMessage(message_);
                    }
                    else
                    {
                        //CHANGE THE DAMN NAME
                        session.FlagmeCommandUsed = false;

                        using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                        {
                            dbClient.AddParamWithValue("userId", session.GetHabbo().ID);
                            dbClient.AddParamWithValue("userName", session.GetHabbo().Username);
                            dbClient.AddParamWithValue("command", "flagme");
                            dbClient.AddParamWithValue("extraData", "Old username: "******" | New username: "******"timestamp", TimeUtilies.GetUnixTimestamp());
                            dbClient.AddParamWithValue("userSessionId", session.SessionID);

                            dbClient.ExecuteQuery("INSERT INTO cmdlogs(user_id, user_name, command, extra_data, timestamp, user_session_id) VALUES (@userId, @userName, @command, @extraData, @timestamp, @userSessionId)");

                            dbClient.AddParamWithValue("newUserName", username);
                            dbClient.ExecuteQuery("UPDATE users SET username = @newUserName WHERE id = @userId LIMIT 1");
                        }

                        foreach (Room room in Skylight.GetGame().GetRoomManager().GetLoadedRooms())
                        {
                            if (room.RoomData.OwnerID == session.GetHabbo().ID)
                            {
                                Skylight.GetGame().GetRoomManager().UnloadRoom(room);
                            }
                        }

                        session.GetHabbo().Username = username;
                        Skylight.GetGame().GetAchievementManager().AddAchievement(session, "ChangeName", 1);
                        session.Stop("Name changed");
                    }
                }
            }
            else
            {
            }
        }
Beispiel #6
0
        public void Join(RoomUnitUser user)
        {
            if (this.Players.Count < 2)
            {
                if (this.Players.Count <= 0)
                {
                    this.ID = Interlocked.Increment(ref RoomGameboard.NextID);
                }

                RoomGameboardUser user_ = new RoomGameboardUser(user);
                this.Players.Add(user.VirtualID, user_);

                ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                message.Init(r26Outgoing.OpenGameBoard);
                message.AppendString(this.ID.ToString(), 9);
                message.AppendString(this.Type, 9);
                user.Session.SendMessage(message);

                if (this.Type == "TicTacToe")
                {
                    RoomGameboardUser side = this.Players.Values.FirstOrDefault(u => !string.IsNullOrEmpty(u.Side));
                    if (side != null && !string.IsNullOrEmpty(side.Side))
                    {
                        if (side.Side == "O")
                        {
                            user_.Side = "X";
                        }
                        else
                        {
                            user_.Side = "O";
                        }

                        ServerMessage message2 = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                        message2.Init(r26Outgoing.GameBoardData);
                        message2.AppendString(this.ID.ToString(), 13);
                        message2.AppendString("SELECTTYPE " + user_.Side, 13);
                        user.Session.SendMessage(message2);
                    }

                    ServerMessage message3 = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                    message3.Init(r26Outgoing.GameBoardData);
                    message3.AppendString(this.ID.ToString(), 13);
                    message3.AppendString("OPPONENTS", 13);

                    RoomGameboardUser O = this.Players.Values.FirstOrDefault(u => u.Side == "O");
                    if (O != null)
                    {
                        message3.AppendString("O: " + O.User.Session.GetHabbo().Username, 13);
                    }
                    else
                    {
                        message3.AppendString("", 13);
                    }

                    RoomGameboardUser X = this.Players.Values.FirstOrDefault(u => u.Side == "X");
                    if (X != null)
                    {
                        message3.AppendString("X: " + X.User.Session.GetHabbo().Username, 13);
                    }
                    else
                    {
                        message3.AppendString("", 13);
                    }

                    foreach (RoomGameboardUser player in this.Players.Values)
                    {
                        player.User.Session.SendMessage(message3);
                    }

                    ServerMessage message4 = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                    message4.Init(r26Outgoing.GameBoardData);
                    message4.AppendString(this.ID.ToString(), 13);
                    message4.AppendString("BOARDDATA", 13);

                    if (O != null)
                    {
                        message4.AppendString("O: " + O.User.Session.GetHabbo().Username, 13);
                    }
                    else
                    {
                        message4.AppendString("", 13);
                    }

                    if (X != null)
                    {
                        message4.AppendString("X: " + X.User.Session.GetHabbo().Username, 13);
                    }
                    else
                    {
                        message4.AppendString("", 13);
                    }

                    for (int y_ = 0; y_ < 25; y_++)
                    {
                        for (int x_ = 0; x_ < 25; x_++)
                        {
                            message4.AppendString(this.Gameboard[x_, y_] ?? " ", null);
                        }
                    }
                    message4.AppendString("", 13);
                    user.Session.SendMessage(message4);
                }
            }
        }
Beispiel #7
0
        public void Handle(GameClient session, ClientMessage message)
        {
            string view  = message.PopFixedString();
            string query = message.PopFixedString();

            ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);

            message_.Init(r63cOutgoing.NewNavigatorSearchResults);
            message_.AppendString(view);
            message_.AppendString(query);
            if (view == "official_view")
            {
                IEnumerable <PublicItem> items       = Skylight.GetGame().GetNavigatorManager().GetPublicRoomItems().Where(i => i.Type != PublicItemType.CATEGORY && this.doFilter(query, i));
                IEnumerable <PublicItem> categorys   = Skylight.GetGame().GetNavigatorManager().GetPublicRoomItems().Where(i => i.Type == PublicItemType.CATEGORY && items.Any(p => p.ParentCategoryID == i.ID));
                IEnumerable <PublicItem> publicRooms = items.Where(i => i.ParentCategoryID == 0);

                if (publicRooms.Count() > 0)
                {
                    message_.AppendInt32(categorys.Count() + 1); //count
                    message_.AppendString("official-root");
                    message_.AppendString("");                   //text
                    message_.AppendInt32(0);                     //action allowed
                    message_.AppendBoolean(false);               //closed
                    message_.AppendInt32(0);                     //display mode

                    message_.AppendInt32(publicRooms.Count());
                    foreach (PublicItem item in publicRooms)
                    {
                        item.RoomData.Serialize(message_, false);
                    }
                }
                else
                {
                    message_.AppendInt32(categorys.Count());
                }

                foreach (PublicItem item in categorys)
                {
                    message_.AppendString("");
                    message_.AppendString(item.Caption);
                    message_.AppendInt32(0);
                    message_.AppendBoolean(string.IsNullOrEmpty(query));
                    message_.AppendInt32(0);

                    IEnumerable <PublicItem> rooms = items.Where(i => i.ParentCategoryID == item.ID);
                    message_.AppendInt32(rooms.Count()); //count
                    foreach (PublicItem room in rooms)
                    {
                        room.RoomData.Serialize(message_, false);
                    }
                }
            }
            else if (view == "hotel_view")
            {
                IEnumerable <Room> rooms        = Skylight.GetGame().GetRoomManager().LoadedRooms.Values.Where(i => this.doFilter(query, i.RoomData));
                IEnumerable <Room> popularRooms = rooms.OrderByDescending(r => r.RoomData.UsersNow).Take(50);

                HashSet <int> categorys = new HashSet <int>();
                foreach (int c in rooms.Select(r => r.RoomData.Category))
                {
                    categorys.Add(c);
                }

                if (!string.IsNullOrEmpty(query))
                {
                    DataTable results = null;
                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.AddParamWithValue("query", "%" + query.Replace("%", "\\%") + "%");
                        results = dbClient.ReadDataTable("SELECT r.* FROM rooms r LEFT JOIN users u ON r.ownerid = u.id WHERE r.type = 'private' AND (r.name LIKE @query OR u.username LIKE @query) ORDER BY r.users_now LIMIT 50");
                    }

                    if (results != null && results.Rows.Count > 0)
                    {
                        message_.AppendInt32(categorys.Count + (popularRooms.Count() > 0 ? 2 : 1));
                        message_.AppendString("");
                        message_.AppendString("Text Search"); //text
                        message_.AppendInt32(0);              //action allowed
                        message_.AppendBoolean(false);        //closed
                        message_.AppendInt32(0);              //display mode

                        message_.AppendInt32(results.Rows.Count);
                        foreach (DataRow dataRow in results.Rows)
                        {
                            Skylight.GetGame().GetRoomManager().TryGetAndLoadRoomData((uint)dataRow["id"], dataRow).Serialize(message_, false);
                        }
                    }
                    else
                    {
                        message_.AppendInt32(categorys.Count + (popularRooms.Count() > 0 ? 1 : 0));
                    }
                }
                else
                {
                    message_.AppendInt32(categorys.Count + (popularRooms.Count() > 0 ? 1 : 0));
                }

                if (popularRooms.Count() > 0)
                {
                    message_.AppendString("popular");
                    message_.AppendString("");     //text
                    message_.AppendInt32(0);       //action allowed
                    message_.AppendBoolean(false); //closed
                    message_.AppendInt32(0);       //display mode

                    message_.AppendInt32(popularRooms.Count());
                    foreach (Room room in popularRooms)
                    {
                        room.RoomData.Serialize(message_, false);
                    }
                }

                foreach (int c in categorys)
                {
                    FlatCat flatCat = Skylight.GetGame().GetNavigatorManager().GetFlatCat(c);

                    message_.AppendString("");
                    message_.AppendString(flatCat.Caption);
                    message_.AppendInt32(0);
                    message_.AppendBoolean(string.IsNullOrEmpty(query));
                    message_.AppendInt32(0);

                    IEnumerable <Room> categoryRooms = rooms.Where(r => r.RoomData.Category == c).OrderByDescending(r => r.RoomData.UsersNow).Take(50);
                    message_.AppendInt32(categoryRooms.Count());
                    foreach (Room room in categoryRooms)
                    {
                        room.RoomData.Serialize(message_, false);
                    }
                }
            }
            else if (view == "myworld_view")
            {
                IEnumerable <RoomData> rooms = session.GetHabbo().UserRooms.Select(i => Skylight.GetGame().GetRoomManager().TryGetAndLoadRoomData(i)).Where(r => this.doFilter(query, r));

                message_.AppendInt32(1);       //count
                message_.AppendString("my");
                message_.AppendString("");     //text
                message_.AppendInt32(0);       //action allowed
                message_.AppendBoolean(false); //closed
                message_.AppendInt32(0);       //display mode

                message_.AppendInt32(rooms.Count());
                foreach (RoomData room in rooms)
                {
                    room.Serialize(message_, false);
                }
            }
            else
            {
                message_.AppendInt32(0); //count
            }
            session.SendMessage(message_);
        }
Beispiel #8
0
        public override bool OnUse(GameClient session, string[] args)
        {
            if (session.GetHabbo().GetHAInterval() > 0)
            {
                if (session.GetHabbo().LastHASended <= 0)
                {
                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        session.GetHabbo().LastHASended = dbClient.ReadDouble("SELECT LastHASended FROM users WHERE Id = " + session.GetHabbo().ID + " LIMIT 1");
                    }
                }

                if (TimeUtilies.GetUnixTimestamp() - session.GetHabbo().LastHASended >= session.GetHabbo().GetHAInterval())
                {
                    session.GetHabbo().LastHASended = TimeUtilies.GetUnixTimestamp();

                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.AddParamWithValue("sessionid", session.GetHabbo().ID);
                        dbClient.ExecuteQuery("UPDATE users SET LastHASended = UNIX_TIMESTAMP() WHERE id = @sessionid");
                    }
                }
                else
                {
                    TimeSpan timeLeft = new TimeSpan(0, 0, 0, (int)(session.GetHabbo().LastHASended - TimeUtilies.GetUnixTimestamp() + session.GetHabbo().GetHAInterval()));
                    string   alert    = "You need to wait " + timeLeft.Seconds + " seconds";

                    if (timeLeft.TotalMinutes >= 1)
                    {
                        alert += ", " + timeLeft.Minutes + " minutes";
                    }

                    if (timeLeft.TotalHours >= 1)
                    {
                        alert += ", " + timeLeft.Hours + " hours";
                    }

                    if (timeLeft.TotalDays >= 1)
                    {
                        alert += ", " + timeLeft.Days + " days";
                    }

                    alert += " before you can use this command again!";
                    session.SendNotif(alert);
                    return(true);
                }
            }

            if (args.Length >= 2)
            {
                if (session.GetHabbo().HasPermission("cmd_ha"))
                {
                    ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                    message.Init(r63aOutgoing.SendHotelAlert);
                    message.AppendString("Important Notice from Hotel Management");                                       //title
                    message.AppendString(TextUtilies.MergeArrayToString(args, 1) + "\n\n" + session.GetHabbo().Username); //message
                    message.AppendInt32(0);                                                                               //parementers count
                    byte[] data = message.GetBytes();

                    foreach (GameClient session_ in Skylight.GetGame().GetGameClientManager().GetClients())
                    {
                        try
                        {
                            session_.SendData(data);
                        }
                        catch
                        {
                        }
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        public void OnCycle()
        {
            if (this.Status == WSStatus.Countdown)
            {
                if (this.GameTimer.Elapsed.TotalSeconds >= 3)
                {
                    this.GameTimer.Restart();
                    this.Status = WSStatus.Running;

                    ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                    message.Init(r26Outgoing.StartWobbleGame);
                    message.AppendString("0:" + this.LeftUser.VirtualID, 13);
                    message.AppendString("1:" + this.RightUser.VirtualID, 13);
                    this.Room.SendToAll(message);
                }
            }
            else if (this.Status == WSStatus.Running)
            {
                if (this.GameTimer.Elapsed.TotalSeconds <= 90)
                {
                    if (this.LeftUser.WSPlayer.NeedUpdate || this.RightUser.WSPlayer.NeedUpdate)
                    {
                        this.LeftUser.WSPlayer.NeedUpdate  = false;
                        this.RightUser.WSPlayer.NeedUpdate = false;

                        ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                        message.Init(r26Outgoing.WobbleUpdate);
                        message.AppendString(this.LeftUser.WSPlayer.Location.ToString(), 9);
                        message.AppendString(this.LeftUser.WSPlayer.Lean.ToString(), 9);
                        message.AppendString(this.LeftUser.WSPlayer.Action, 9);
                        message.AppendString(this.LeftUser.WSPlayer.BeenHit ? "h" : "", 13);

                        message.AppendString(this.RightUser.WSPlayer.Location.ToString(), 9);
                        message.AppendString(this.RightUser.WSPlayer.Lean.ToString(), 9);
                        message.AppendString(this.RightUser.WSPlayer.Action, 9);
                        message.AppendString(this.RightUser.WSPlayer.BeenHit ? "h" : "", 9);
                        this.Room.SendToAll(message);

                        this.LeftUser.WSPlayer.Action  = "-";
                        this.RightUser.WSPlayer.Action = "-";

                        this.LeftUser.WSPlayer.BeenHit  = false;
                        this.RightUser.WSPlayer.BeenHit = false;
                    }

                    if (Math.Abs(this.LeftUser.WSPlayer.Lean) >= 100 && Math.Abs(this.RightUser.WSPlayer.Lean) >= 100)
                    {
                        this.Done(true, true);
                    }
                    else if (Math.Abs(this.LeftUser.WSPlayer.Lean) >= 100)
                    {
                        this.Done(true, false);
                    }
                    else if (Math.Abs(this.RightUser.WSPlayer.Lean) >= 100)
                    {
                        this.Done(false, true);
                    }
                }
                else
                {
                    ServerMessage messageTimeout = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                    messageTimeout.Init(r26Outgoing.WobbleTimeout);
                    this.Room.SendToAll(messageTimeout);

                    if (this.RightUser.WSPlayer.HitsTakenTotal == this.LeftUser.WSPlayer.HitsTakenTotal)
                    {
                        this.Done(true, true); //Tie I guess
                    }
                    else
                    {
                        if (this.RightUser.WSPlayer.HitsTakenTotal > this.LeftUser.WSPlayer.HitsTakenTotal)
                        {
                            this.Done(false, true);
                        }
                        else
                        {
                            this.Done(true, false);
                        }
                    }
                }
            }
            else if (this.Status == WSStatus.Ending)
            {
                if (this.GameTimer.Elapsed.TotalSeconds >= 1.5)
                {
                    this.Status = WSStatus.NotRunning;

                    ServerMessage messageEnd = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                    messageEnd.Init(r26Outgoing.WobbleEnd);
                    this.Room.SendToAll(messageEnd);
                }
            }
        }
Beispiel #10
0
        public void UpdateEmulatorStatus()
        {
            try
            {
                if (this.LastUpdateEmulatorStatus.Elapsed.TotalSeconds > 5)
                {
                    this.LastUpdateEmulatorStatus.Restart();

                    TimeSpan uptime      = Skylight.Uptime;
                    int      usersOnline = Skylight.GetGame().GetGameClientManager().OnlineCount;
                    int      loadedRooms = Skylight.GetGame().GetRoomManager().LoadedRoomsCount;

                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.AddParamWithValue("usersOnline", usersOnline);
                        dbClient.AddParamWithValue("loadedRooms", loadedRooms);

                        dbClient.ExecuteQuery("UPDATE server_status SET users_online = @usersOnline, rooms_loaded = @loadedRooms LIMIT 1; UPDATE server_status SET users_online_peak = @usersOnline WHERE users_online_peak < @usersOnline LIMIT 1; UPDATE server_status SET rooms_loaded_peak = @loadedRooms WHERE rooms_loaded_peak < @loadedRooms LIMIT 1;");
                    }

                    Skylight.GetGame().GetChatlogManager().PushRoomChatlogToDB();
                    Skylight.GetGame().GetChatlogManager().PushPrivateChatlogToDB();
                    Skylight.GetGame().GetRoomvisitManager().PushRoomvisitsToDB();

                    if (this.CurrentDay != DateTime.Today)
                    {
                        this.CurrentDay = DateTime.Today;
                        foreach (GameClient session in this.GetGameClientManager().GetClients())
                        {
                            if (session != null && session.GetHabbo() != null)
                            {
                                try
                                {
                                    session.GetHabbo().CheckDailyStuff(true);

                                    ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                    Message.Init(r63aOutgoing.SendUserInfo);
                                    Message.AppendString(session.GetHabbo().ID.ToString());
                                    Message.AppendString(session.GetHabbo().Username);
                                    Message.AppendString(session.GetHabbo().Look);
                                    Message.AppendString(session.GetHabbo().Gender.ToUpper());
                                    Message.AppendString(session.GetHabbo().Motto);
                                    Message.AppendString(session.GetHabbo().RealName);
                                    Message.AppendInt32(0); //unknown
                                    Message.AppendInt32(session.GetHabbo().GetUserStats().RespectReceived);
                                    Message.AppendInt32(session.GetHabbo().GetUserStats().DailyRespectPoints);
                                    Message.AppendInt32(session.GetHabbo().GetUserStats().DailyPetRespectPoints);
                                    Message.AppendBoolean(false); //friend stream enabled
                                    session.SendMessage(Message);
                                }
                                catch
                                {
                                }
                            }
                        }
                    }

                    Console.Title = "Skylight | Users online: " + usersOnline + " | Rooms loaded: " + loadedRooms + " | Uptime: " + uptime.Days + " days, " + uptime.Hours + " hours, " + uptime.Minutes + " minutes | Memory: " + GC.GetTotalMemory(false) / 1024 + " KB";
                }
            }

            catch (Exception ex)
            {
                Logging.LogException("Error in update emulator status task! " + ex.ToString());
            }
        }
Beispiel #11
0
        public void Handle(GameClient session, ClientMessage message)
        {
            if (session != null && session.GetHabbo() != null && session.GetHabbo().GetRoomSession().RequestedRoomID > 0 && session.GetHabbo().GetRoomSession().LoadingRoom)
            {
                Room room = Skylight.GetGame().GetRoomManager().TryGetRoom(session.GetHabbo().GetRoomSession().RequestedRoomID);
                session.GetHabbo().GetRoomSession().ResetRequestedRoom();
                if (room != null)
                {
                    if (room.RoomGamemapManager.Model != null)
                    {
                        session.SendData(room.RoomGamemapManager.Model.GetRelativeHeightmap(session.Revision));
                        session.SendData(room.RoomGamemapManager.Model.GetHeightmap(session.Revision, room.RoomGamemapManager.Tiles));

                        /*//TODO: Fix public items
                         * ServerMessage publicItems = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                         * publicItems.Init(r63cOutgoing.PublicItems);
                         * publicItems.AppendInt32(0);
                         * session.SendMessage(publicItems);*/

                        if (room.RoomData.Type == "private")
                        {
                            Dictionary <uint, string> floorItemOwners = new Dictionary <uint, string>();
                            List <byte> tempHolder = new List <byte>();
                            foreach (RoomItem item in room.RoomItemManager.FloorItems.Values)
                            {
                                if (!floorItemOwners.ContainsKey(item.UserID))
                                {
                                    floorItemOwners.Add(item.UserID, Skylight.GetGame().GetGameClientManager().GetUsernameByID(item.UserID));
                                }

                                ServerMessage temp = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                                temp.Init();
                                item.Serialize(temp);
                                tempHolder.AddRange(temp.GetBytes());
                            }

                            ServerMessage floorItems = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                            floorItems.Init(r63cOutgoing.FloorItems);
                            floorItems.AppendInt32(floorItemOwners.Count);
                            foreach (KeyValuePair <uint, string> floorItemOwner in floorItemOwners)
                            {
                                floorItems.AppendUInt(floorItemOwner.Key);
                                floorItems.AppendString(floorItemOwner.Value);
                            }
                            floorItems.AppendInt32(room.RoomItemManager.FloorItems.Values.Count);
                            floorItems.AppendBytes(tempHolder);
                            session.SendMessage(floorItems);

                            tempHolder = new List <byte>();
                            Dictionary <uint, string> wallItemOwners = new Dictionary <uint, string>();
                            foreach (RoomItem item in room.RoomItemManager.WallItems.Values)
                            {
                                if (!wallItemOwners.ContainsKey(item.UserID))
                                {
                                    wallItemOwners.Add(item.UserID, Skylight.GetGame().GetGameClientManager().GetUsernameByID(item.UserID));
                                }

                                ServerMessage temp = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                                temp.Init();
                                item.Serialize(temp);
                                tempHolder.AddRange(temp.GetBytes());
                            }

                            ServerMessage wallItems = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                            wallItems.Init(r63cOutgoing.WallItems);
                            wallItems.AppendInt32(wallItemOwners.Count);
                            foreach (KeyValuePair <uint, string> wallItemOwner in wallItemOwners)
                            {
                                wallItems.AppendUInt(wallItemOwner.Key);
                                wallItems.AppendString(wallItemOwner.Value);
                            }
                            wallItems.AppendInt32(room.RoomItemManager.WallItems.Values.Count);
                            wallItems.AppendBytes(tempHolder);
                            session.SendMessage(wallItems);
                        }

                        room.RoomUserManager.EnterRoom(session);

                        ICollection <RoomUnit> users        = room.RoomUserManager.GetRoomUsers();
                        ServerMessage          setRoomUsers = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                        setRoomUsers.Init(r63cOutgoing.SetRoomUser);
                        setRoomUsers.AppendInt32(users.Count);
                        foreach (RoomUnit user in users)
                        {
                            user.Serialize(setRoomUsers);
                        }
                        session.SendMessage(setRoomUsers);

                        ServerMessage roomVIPsetting = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                        roomVIPsetting.Init(r63cOutgoing.RoomVIPSettings);
                        roomVIPsetting.AppendBoolean(room.RoomData.Hidewalls);
                        roomVIPsetting.AppendInt32(room.RoomData.Wallthick);
                        roomVIPsetting.AppendInt32(room.RoomData.Floorthick);
                        session.SendMessage(roomVIPsetting);

                        if (room.RoomData.Type == "private")
                        {
                            ServerMessage roomOwner = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                            roomOwner.Init(r63cOutgoing.RoomOwner);
                            roomOwner.AppendUInt(room.ID);
                            roomOwner.AppendBoolean(room.HaveOwnerRights(session)); //is roomowner
                            session.SendMessage(roomOwner);

                            ServerMessage roomData = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                            roomData.Init(r63cOutgoing.RoomData);
                            room.RoomData.SerializeRoomEntry(roomData, false, false);
                            session.SendMessage(roomData);
                        }
                        else
                        {
                            ServerMessage roomOwner = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                            roomOwner.Init(r63cOutgoing.RoomOwner);
                            roomOwner.AppendBoolean(false); //is private room
                            roomOwner.AppendString(room.RoomGamemapManager.Model.ID);
                            roomOwner.AppendInt32(0);       //unknwown
                            session.SendMessage(roomOwner);
                        }

                        MultiRevisionServerMessage usersStatuses = room.RoomUserManager.GetUserStatus(true);
                        if (usersStatuses != null)
                        {
                            session.SendData(usersStatuses.GetBytes(session.Revision));
                        }

                        foreach (RoomUnitUser user in room.RoomUserManager.GetRealUsers())
                        {
                            if (user.Dancing)
                            {
                                ServerMessage danceMessage = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                                danceMessage.Init(r63cOutgoing.Dance);
                                danceMessage.AppendInt32(user.VirtualID);
                                danceMessage.AppendInt32(user.DanceID);
                                session.SendMessage(danceMessage);
                            }

                            if (user.Sleeps)
                            {
                                ServerMessage sleeps = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                                sleeps.Init(r63cOutgoing.Sleeps);
                                sleeps.AppendInt32(user.VirtualID);
                                sleeps.AppendBoolean(true);
                                session.SendMessage(sleeps);
                            }

                            if (user.Handitem > 0 && user.HanditemTimer > 0)
                            {
                                ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                                message_.Init(r63cOutgoing.Handitem);
                                message_.AppendInt32(user.VirtualID);
                                message_.AppendInt32(user.Handitem);
                                session.SendMessage(message_);
                            }

                            if (user.ActiveEffect > 0)
                            {
                                ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                                Message.Init(r63cOutgoing.Effect);
                                Message.AppendInt32(user.VirtualID);
                                Message.AppendInt32(user.ActiveEffect);
                                session.SendMessage(Message);
                            }
                        }

                        room.RoomWiredManager.UserEnterRoom(session.GetHabbo().GetRoomSession().GetRoomUser());

                        if (session.GetHabbo().IsMuted())
                        {
                            ServerMessage flood = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);
                            flood.Init(r63cOutgoing.Flood);
                            flood.AppendInt32(session.GetHabbo().MuteTimeLeft());
                            session.SendMessage(flood);
                        }
                    }
                    else
                    {
                        session.SendNotif("Failed load room model!");
                    }
                }
                else
                {
                    session.SendNotif("Room not found!");
                }
            }
        }
Beispiel #12
0
        public void GameCycle(object sender, ElapsedEventArgs e)
        {
            if (!Skylight.ServerShutdown)
            {
                try
                {
                    if (this.RoomManager.RoomCycleTask?.IsCompleted ?? true)
                    {
                        (this.RoomManager.RoomCycleTask = new Task(new Action(this.RoomManager.OnCycle))).Start();
                    }

                    if (this.UpdateEmulatorStatusTask?.IsCompleted ?? true)
                    {
                        (this.UpdateEmulatorStatusTask = new Task(new Action(this.UpdateEmulatorStatus))).Start();
                    }

                    if (this.CheckActivityBonusesTask?.IsCompleted ?? true)
                    {
                        (this.CheckActivityBonusesTask = new Task(new Action(this.CheckActivityBonuses))).Start();
                    }

                    if (this.GuideManager.CycleTask?.IsCompleted ?? true)
                    {
                        (this.GuideManager.CycleTask = new Task(new Action(this.GuideManager.OnCycle))).Start();
                    }

                    if (this.ClientPingEnabled)
                    {
                        if (this.TimeoutTask?.IsCompleted ?? true)
                        {
                            (this.TimeoutTask = new Task(new Action(this.CheckTimeout))).Start();
                        }
                    }

                    try
                    {
                        if (this.AutoRestartEnabled)
                        {
                            if (Skylight.Uptime.TotalMinutes >= 2) //restart
                            {
                                if (!this.AutoRestartWarningSend)
                                {
                                    if (DateTime.Now.ToString("HH:mm") == this.AutoRestartTime.AddMinutes(-1).ToString("HH:mm"))
                                    {
                                        this.AutoRestartWarningSend = true;

                                        ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                        message.Init(r63aOutgoing.SendNotifFromAdmin);
                                        message.AppendString(Skylight.GetConfig()["auto.restart.warning.message"]);
                                        byte[] data = message.GetBytes();

                                        foreach (GameClient client in Skylight.GetGame().GetGameClientManager().GetClients())
                                        {
                                            try //try send
                                            {
                                                if (client != null)
                                                {
                                                    client.SendData(data);
                                                }
                                            }
                                            catch //ignore error
                                            {
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    if (DateTime.Now.ToString("HH:mm") == this.AutoRestartTime.ToString("HH:mm"))
                                    {
                                        Program.Destroy(true, this.AutoRestartBackup, this.AutoRestartBackupCompress, true);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logging.LogException("Error in auto restart check! " + ex.ToString());
                    }
                }
                catch (Exception ex)
                {
                    Logging.LogException("Error in game cycle! " + ex.ToString());
                }
            }
        }
Beispiel #13
0
        public override void Speak(string message, bool shout, int bubble = 0)
        {
            string originalMessage = message;

            if (!this.Room.RoomMute || this.Session.GetHabbo().HasPermission("acc_ignore_roommute"))
            {
                if (!this.Session.GetHabbo().IsMuted())
                {
                    this.Unidle();

                    if (!message.StartsWith(":") || !this.HandleCommand(message.Substring(1))) //not a command
                    {
                        if (!this.Room.RoomWiredManager.UserSpeak(this, message))
                        {
                            if (this.CheckForFloor()) //flooded
                            {
                                this.FloodUser();
                            }
                            else
                            {
                                this.Session.GetHabbo().LastRoomMessage = DateTime.Now;
                                this.Session.GetHabbo().FloodCounter++;

                                if (!this.Session.GetHabbo().HasPermission("acc_nochatlog_say"))
                                {
                                    Skylight.GetGame().GetChatlogManager().LogRoomMessage(this.Session, originalMessage); //log it first bcs there can be some troubles to send it to everyone
                                }

                                message = TextUtilies.CheckBlacklistedWords(message);
                                if (shout)
                                {
                                    this.Room.SendToAllRespectIgnores(new MultiRevisionServerMessage(OutgoingPacketsEnum.Shout, new ValueHolder("VirtualID", this.VirtualID, "Message", message, "Bubble", bubble)), this.Session.GetHabbo().ID);
                                }
                                else
                                {
                                    this.Room.SendToAllRespectIgnores(new MultiRevisionServerMessage(OutgoingPacketsEnum.Chat, new ValueHolder("VirtualID", this.VirtualID, "Message", message, "Bubble", bubble)), this.Session.GetHabbo().ID);
                                }

                                foreach (BotAI bot in this.Room.RoomUserManager.GetBots())
                                {
                                    bot.OnUserSpeak(this, message, shout);
                                }
                            }
                        }
                        else
                        {
                            ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                            message_.Init(r63aOutgoing.Whisper);
                            message_.AppendInt32(this.VirtualID);
                            message_.AppendString(message);
                            message_.AppendInt32(0); //gesture
                            message_.AppendInt32(0); //links count
                            this.Session.SendMessage(message_);
                        }
                    }
                }
                else
                {
                    this.Session.SendNotif("You are muted!");
                }
            }
        }
Beispiel #14
0
        public void HandleBotAction(BotAction action)
        {
            this.Unidle();

            if (action.Action == "setname")
            {
                this.Data.Name = action.Value;

                if (action.Tick != -1)
                {
                    this.Room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.SetRoomUser, new ValueHolder("RoomUser", new List <RoomUnit>()
                    {
                        this
                    })));
                }
            }
            else if (action.Action == "setlook")
            {
                this.Data.Look = action.Value;

                if (action.Tick != -1)
                {
                    this.Update();
                }
            }
            else if (action.Action == "setmotto")
            {
                this.Data.Motto = action.Value;

                if (action.Tick != -1)
                {
                    this.Update();
                }
            }
            else if (action.Action == "setlocation")
            {
                string[] data = action.Value.Split(',');

                if (data.Length == 2)
                {
                    RoomTile tile = this.Room.RoomGamemapManager.GetTile(int.Parse(data[0]), int.Parse(data[1]));
                    if (tile != null)
                    {
                        this.SetLocation(int.Parse(data[0]), int.Parse(data[1]), tile.GetZ(true));
                    }
                    else
                    {
                        this.SetLocation(int.Parse(data[0]), int.Parse(data[1]), 0);
                    }
                }
                else
                {
                    this.SetLocation(int.Parse(data[0]), int.Parse(data[1]), double.Parse(data[2]));
                }
            }
            else if (action.Action == "setrotation")
            {
                this.SetRotation(int.Parse(action.Value), true);
            }
            else if (action.Action == "move")
            {
                string[] data = action.Value.Split(',');
                this.MoveTo(int.Parse(data[0]), int.Parse(data[1]));
            }
            else if (action.Action == "say")
            {
                this.Speak(TextUtilies.FormatString(action.Value, Skylight.GetGame().GetGameClientManager().GetGameClientById(this.Room.RoomData.OwnerID)), false);
            }
            else if (action.Action == "whisper")
            {
                ServerMessage whisper = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                whisper.Init(r63aOutgoing.Whisper);
                whisper.AppendInt32(this.VirtualID);
                whisper.AppendString(TextUtilies.FormatString(action.Value, Skylight.GetGame().GetGameClientManager().GetGameClientById(this.Room.RoomData.OwnerID)));
                whisper.AppendInt32(0); //gesture
                whisper.AppendInt32(0); //links count
                this.Room.SendToAll(whisper);
            }
            else if (action.Action == "shout")
            {
                this.Speak(TextUtilies.FormatString(action.Value, Skylight.GetGame().GetGameClientManager().GetGameClientById(this.Room.RoomData.OwnerID)), true);
            }
            else if (action.Action == "wave")
            {
                this.Room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.Wave, new ValueHolder("VirtualID", this.VirtualID)));
            }
            else if (action.Action == "effect")
            {
                this.ApplyEffect(int.Parse(action.Value));
            }
            else if (action.Action == "handitem")
            {
                this.SetHanditem(int.Parse(action.Value));
            }
            else if (action.Action == "leave")
            {
                GameClient roomOwner = Skylight.GetGame().GetGameClientManager().GetGameClientById(this.Room.RoomData.OwnerID);
                if (roomOwner != null)
                {
                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.AddParamWithValue("userId", roomOwner.GetHabbo().ID);
                        dbClient.ExecuteQuery("UPDATE users SET newbie_status = '2' WHERE id = @userId");
                    }
                    roomOwner.GetHabbo().NewbieStatus = 2;

                    Skylight.GetGame().GetAchievementManager().AddAchievement(roomOwner, "Graduate", 1);

                    this.Room.RoomUserManager.LeaveRoom(this);
                }
            }
        }
Beispiel #15
0
 public ServerMessage Handle(T handler)
 {
     return(BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486, r63cOutgoing.GuideSessionDetached));
 }
Beispiel #16
0
        public ServerMessage OldSchoolGetHand(string mode)
        {
            switch (mode)
            {
            case "next":
            {
                this.OldSchoolHandPage = Math.Min((this.TotalSize - 1) / 9, this.OldSchoolHandPage + 1);
            }
            break;

            case "prev":
            {
                this.OldSchoolHandPage = Math.Max(0, this.OldSchoolHandPage - 1);
            }
            break;

            case "last":
            {
                this.OldSchoolHandPage = (this.TotalSize - 1) / 9;
            }
            break;

            case "update":
            {
                this.OldSchoolHandPage = Math.Min((this.TotalSize - 1) / 9, this.OldSchoolHandPage);
            }
            break;

            case "new":
            {
                this.OldSchoolHandPage = 0;
            }
            break;
            }

            int           loller   = this.OldSchoolHandPage * 9;
            ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);

            message_.Init(r26Outgoing.CurrenttHand);
            foreach (InventoryItem item in this.OldSchoolGetCurrentHand())
            {
                message_.AppendString("SI", 30);
                message_.AppendString(item.ID.ToString(), 30);
                message_.AppendString(loller++.ToString(), 30);
                message_.AppendString(item.GetItem().IsFloorItem ? "S" : "I", 30);
                message_.AppendString(item.ID.ToString(), 30);
                message_.AppendString(item.GetItem().ItemName, 30);

                if (item.GetItem().IsFloorItem)
                {
                    message_.AppendString(item.GetItem().Lenght.ToString(), 30);
                    message_.AppendString(item.GetItem().Width.ToString(), 30);
                    message_.AppendString("", 30);
                    message_.AppendString("0,0,0", 30);
                    message_.AppendString(item.GetItem().ItemName, 30);
                }
                else
                {
                    message_.AppendString("0,0,0", 30);
                    message_.AppendString(item.GetItem().AllowRecycle ? "1" : "0", 30);
                }

                message_.AppendString("/", null);
            }
            message_.AppendString(Convert.ToChar(13) + this.TotalSize.ToString(), null);
            return(message_);
        }
Beispiel #17
0
        public void DoAction(RoomUnitUser user, string[] data)
        {
            if (this.Type == "TicTacToe")
            {
                RoomGameboardUser user_ = this.Players[user.VirtualID];

                switch (data[0])
                {
                case "CHOOSETYPE":
                {
                    if (string.IsNullOrEmpty(user_.Side))
                    {
                        if (data[1] == "O" || data[1] == "X")
                        {
                            this.Turn  = data[1];
                            user_.Side = data[1];

                            ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                            message.Init(r26Outgoing.GameBoardData);
                            message.AppendString(this.ID.ToString(), 13);
                            message.AppendString("SELECTTYPE " + data[1], 13);
                            user.Session.SendMessage(message);

                            RoomGameboardUser side = this.Players.Values.FirstOrDefault(u => string.IsNullOrEmpty(u.Side));
                            if (side != null && string.IsNullOrEmpty(side.Side))
                            {
                                if (user_.Side == "O")
                                {
                                    side.Side = "X";
                                }
                                else
                                {
                                    side.Side = "O";
                                }

                                ServerMessage message2 = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                                message2.Init(r26Outgoing.GameBoardData);
                                message2.AppendString(this.ID.ToString(), 13);
                                message2.AppendString("SELECTTYPE " + side.Side, 13);
                                side.User.Session.SendMessage(message2);
                            }

                            ServerMessage message3 = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                            message3.Init(r26Outgoing.GameBoardData);
                            message3.AppendString(this.ID.ToString(), 13);
                            message3.AppendString("OPPONENTS", 13);

                            RoomGameboardUser O = this.Players.Values.FirstOrDefault(u => u.Side == "O");
                            if (O != null)
                            {
                                message3.AppendString("O: " + O.User.Session.GetHabbo().Username, 13);
                            }
                            else
                            {
                                message3.AppendString("", 13);
                            }

                            RoomGameboardUser X = this.Players.Values.FirstOrDefault(u => u.Side == "X");
                            if (X != null)
                            {
                                message3.AppendString("X: " + X.User.Session.GetHabbo().Username, 13);
                            }
                            else
                            {
                                message3.AppendString("", 13);
                            }

                            foreach (RoomGameboardUser player in this.Players.Values)
                            {
                                player.User.Session.SendMessage(message3);
                            }
                        }
                    }
                }
                break;

                case "CLOSE":
                {
                    this.Leave(user);
                }
                break;

                case "SETSECTOR":
                {
                    if (!this.Ended && this.Turn == user_.Side)
                    {
                        int x = int.Parse(data[2]);
                        int y = int.Parse(data[3]);

                        if (x >= 0 && y >= 0 && x <= 23 && y <= 22 && this.Gameboard[x, y] == null)
                        {
                            this.Gameboard[x, y] = user_.Side;

                            if (!(this.Ended = this.CheckIfWin(1, 0, user_.Side)))
                            {
                                if (!(this.Ended = this.CheckIfWin(0, 1, user_.Side)))
                                {
                                    if (!(this.Ended = this.CheckIfWin(1, 1, user_.Side)))
                                    {
                                        this.Ended = this.CheckIfWin(1, -1, user_.Side);
                                    }
                                }
                            }

                            ServerMessage message2 = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                            message2.Init(r26Outgoing.GameBoardData);
                            message2.AppendString(this.ID.ToString(), 13);
                            message2.AppendString("BOARDDATA", 13);

                            RoomGameboardUser O = this.Players.Values.FirstOrDefault(u => u.Side == "O");
                            if (O != null)
                            {
                                message2.AppendString("O: " + O.User.Session.GetHabbo().Username, 13);
                            }
                            else
                            {
                                message2.AppendString("", 13);
                            }

                            RoomGameboardUser X = this.Players.Values.FirstOrDefault(u => u.Side == "X");
                            if (X != null)
                            {
                                message2.AppendString("X: " + X.User.Session.GetHabbo().Username, 13);
                            }
                            else
                            {
                                message2.AppendString("", 13);
                            }

                            for (int y_ = 0; y_ < 25; y_++)
                            {
                                for (int x_ = 0; x_ < 25; x_++)
                                {
                                    message2.AppendString(this.Gameboard[x_, y_] ?? " ", null);
                                }
                            }
                            message2.AppendString("", 13);

                            foreach (RoomGameboardUser player in this.Players.Values)
                            {
                                player.User.Session.SendMessage(message2);
                            }

                            if (user_.Side == "X")
                            {
                                this.Turn = "O";
                            }
                            else
                            {
                                this.Turn = "X";
                            }
                        }
                    }
                }
                break;

                case "RESTART":
                {
                    this.Ended     = false;
                    this.Gameboard = new string[25, 25];
                    this.Turn      = user_.Side;

                    ServerMessage message2 = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                    message2.Init(r26Outgoing.GameBoardData);
                    message2.AppendString(this.ID.ToString(), 13);
                    message2.AppendString("BOARDDATA", 13);

                    RoomGameboardUser O = this.Players.Values.FirstOrDefault(u => u.Side == "O");
                    if (O != null)
                    {
                        message2.AppendString("O: " + O.User.Session.GetHabbo().Username, 13);
                    }
                    else
                    {
                        message2.AppendString("", 13);
                    }

                    RoomGameboardUser X = this.Players.Values.FirstOrDefault(u => u.Side == "X");
                    if (X != null)
                    {
                        message2.AppendString("X: " + X.User.Session.GetHabbo().Username, 13);
                    }
                    else
                    {
                        message2.AppendString("", 13);
                    }

                    for (int y_ = 0; y_ < 25; y_++)
                    {
                        for (int x_ = 0; x_ < 25; x_++)
                        {
                            message2.AppendString(this.Gameboard[x_, y_] ?? " ", null);
                        }
                    }
                    message2.AppendString("", 13);

                    foreach (RoomGameboardUser player in this.Players.Values)
                    {
                        player.User.Session.SendMessage(message2);
                    }
                }
                break;
                }
            }
        }
Beispiel #18
0
        public void LogIn(string sso, bool loginWithUsernameAndPassword = false)
        {
            uint id = 0;

            //DUE TO R26 TESTING
            if (sso == "fcc08e21-8a14-41e4-22f4-1a258f9db47f")
            {
                using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                {
                    dbClient.ExecuteQuery("UPDATE users SET auth_ticket = 'fcc08e21-8a14-41e4-22f4-1a258f9db47f' WHERE id = 3132 LIMIT 1");
                }
            }
            else if (sso == "ESANPIKKUPIKAPANO")
            {
                using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                {
                    dbClient.ExecuteQuery("UPDATE users SET auth_ticket = 'ESANPIKKUPIKAPANO' WHERE id = 3133 LIMIT 1");
                }
            }

            try
            {
                if (string.IsNullOrEmpty(sso) || string.IsNullOrWhiteSpace(sso))
                {
                    this.SendNotif("Empty SSO ticket!");
                }
                else
                {
                    UserDataFactory userData = new UserDataFactory(this.connection.GetIP(), this.MachineID, sso, true, out this.SessionID);
                    if (userData.IsUserLoaded)
                    {
                        id = (uint)userData.GetUserData()["id"];
                        string username = (string)userData.GetUserData()["username"];
                        Skylight.GetGame().GetGameClientManager().UpdateCachedUsername(id, username); //we loaded the user data.. why not update this too
                        Skylight.GetGame().GetGameClientManager().UpdateCachedID(id, username);

                        bool requireLogin = ServerConfiguration.MinRankRequireLogin == 0 ? false : (int)userData.GetUserData()["rank"] >= ServerConfiguration.MinRankRequireLogin;
                        if ((!loginWithUsernameAndPassword && !requireLogin) || (loginWithUsernameAndPassword && requireLogin))
                        {
                            Ban ban = Skylight.GetGame().GetBanManager().TryGetBan(id, this.GetIP(), this.MachineID);
                            if (ban == null || Licence.CheckIfMatches(id, username, this.GetIP(), this.MachineID)) //don't load ANY shit before we are sure he can come on
                            {
                                Skylight.GetGame().GetGameClientManager().DisconnectDoubleSession(id);

                                this.Habbo = Authenicator.LoadHabbo(userData, this);
                                this.Habbo.LoadMore();
                                if (this.Habbo.IsTwoFactorAuthenticationEnabled())
                                {
                                    int failures = 0;
                                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                                    {
                                        failures = dbClient.ReadInt32("SELECT COUNT(id) FROM user_2fa_failures WHERE timestamp >= UNIX_TIMESTAMP() - 60 * 15");
                                    }

                                    if (failures < 3)
                                    {
                                        this.AddMessageHandlerToFrist(new TwoFactorAuthenticationHandler(failures));

                                        if (this.Revision == Revision.RELEASE63_35255_34886_201108111108)
                                        {
                                            ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                            message.Init(r63aOutgoing.ChangeNameWindow);
                                            this.SendMessage(message);
                                        }
                                        else
                                        {
                                            this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.AuthOk).Handle());

                                            ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486, r63cOutgoing.VerifyMobilePhoneWindow);
                                            message_.AppendInt32(9);
                                            message_.AppendInt32(3);
                                            message_.AppendInt32(1);
                                            this.SendMessage(message_);
                                        }

                                        this.SendNotif("Looks like you have enable two factor authenication on your account! Please enter the code to log in!" + ((Skylight.GetConfig()["client.ping.enabled"] == "1") ? " You have one minute!" : "") + "\n\n!!CLOSE THIS!!", 2);
                                    }
                                    else
                                    {
                                        this.SendNotif("You have too many login fails inside 15 minutes! Please try again later!", 2);
                                    }
                                }
                                else
                                {
                                    this.LetUserIn();
                                }
                            }
                            else
                            {
                                string banLenght = "";
                                if (ban.Permament)
                                {
                                    banLenght = "PERMAMENT";
                                }
                                else
                                {
                                    TimeSpan lenght = new TimeSpan(0, 0, 0, (int)(ban.Expires - ban.AddedOn));

                                    banLenght = lenght.Seconds + " seconds";

                                    if (lenght.TotalMinutes >= 1)
                                    {
                                        banLenght += ", " + lenght.Minutes + " minutes";
                                    }

                                    if (lenght.TotalHours >= 1)
                                    {
                                        banLenght += ", " + lenght.Hours + " hours";
                                    }

                                    if (lenght.TotalDays >= 1)
                                    {
                                        banLenght += ", " + lenght.Days + " days";
                                    }
                                }

                                this.SendNotif("You have been banned!\nReason: " + ban.Reason + "\nLength: " + banLenght + "\nExpires: " + (ban.Permament ? "NEVER" : TimeUtilies.UnixTimestampToDateTime(ban.Expires).ToString()) + "\nBanned by: " + Skylight.GetGame().GetGameClientManager().GetUsernameByID(ban.AddedByID), 2);
                                //this.Stop("Banned!");
                            }
                        }
                        else
                        {
                            this.SendNotif("Sorry but, you cant use this login method!", 2);
                        }
                    }
                    else
                    {
                        this.SendNotif("Invalid SSO ticket!", 2);
                    }
                }
            }
            finally                              //fixes issue where valid sso ticket sets online to = '1' but dosent turn it back to = '0' after disconnection bcs users data isint loaded for few reasons example exeption or user is banned
            {
                if (id > 0)                      //only positive numbers are valid user ids
                {
                    if (this.GetHabbo() == null) //only if habbo is null or this is already done by habbo class itself
                    {
                        using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                        {
                            dbClient.AddParamWithValue("userId", id);
                            dbClient.ExecuteQuery("UPDATE users SET online = '0' WHERE id = @userId LIMIT 1");
                        }
                    }
                }
            }
        }
        public void Handle(GameClient session, ClientMessage message)
        {
            if (ServerConfiguration.EnableMarketplace)
            {
                if (session != null && session.GetHabbo() != null)
                {
                    if (session.GetHabbo().MarketplaceTokens > 0)
                    {
                        int price = message.PopWiredInt32();
                        if (price >= ServerConfiguration.MarketplaceMinPrice && price <= ServerConfiguration.MarketplaceMaxPrice)
                        {
                            int  itemType = message.PopWiredInt32(); //1 = floor, 2 = wall
                            uint itemId   = message.PopWiredUInt();

                            InventoryItem item = null;
                            if (itemType == 1)
                            {
                                item = session.GetHabbo().GetInventoryManager().TryGetFloorItem(itemId);
                            }
                            else if (itemType == 2)
                            {
                                item = session.GetHabbo().GetInventoryManager().TryGetWallItem(itemId);
                            }

                            if (item != null && item.GetItem() != null && item.GetItem().AllowTrade&& item.GetItem().AllowMarketplaceSell)
                            {
                                Skylight.GetGame().GetCatalogManager().GetMarketplaceManager().MakeOffer(session, item, price);

                                session.GetHabbo().MarketplaceTokens--;
                                using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                                {
                                    dbClient.AddParamWithValue("userId", session.GetHabbo().ID);
                                    dbClient.AddParamWithValue("tokens", session.GetHabbo().MarketplaceTokens);
                                    dbClient.ExecuteQuery("UPDATE users SET marketplace_tokens = @tokens WHERE id = @userId LIMIT 1");
                                }

                                ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                message_.Init(r63aOutgoing.MakeOfferResult);
                                message_.AppendInt32(1); //result, 1 = success, 2 = technical error, 3 = marketplace disabled, 4 = item was just added to shop
                                session.SendMessage(message_);
                            }
                            else
                            {
                                ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                message_.Init(r63aOutgoing.MakeOfferResult);
                                message_.AppendInt32(2); //result, 1 = success, 2 = technical error, 3 = marketplace disabled, 4 = item was just added to shop
                                session.SendMessage(message_);
                            }
                        }
                        else
                        {
                            ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                            message_.Init(r63aOutgoing.MakeOfferResult);
                            message_.AppendInt32(2); //result, 1 = success, 2 = technical error, 3 = marketplace disabled, 4 = item was just added to shop
                            session.SendMessage(message_);
                        }
                    }
                    else
                    {
                        ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                        message_.Init(r63aOutgoing.MakeOfferResult);
                        message_.AppendInt32(2); //result, 1 = success, 2 = technical error, 3 = marketplace disabled, 4 = item was just added to shop
                        session.SendMessage(message_);
                    }
                }
            }
            else
            {
                ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                message_.Init(r63aOutgoing.MakeOfferResult);
                message_.AppendInt32(3); //result, 1 = success, 2 = technical error, 3 = marketplace disabled, 4 = item was just added to shop
                session.SendMessage(message_);
            }
        }
        public ServerMessage Handle(ValueHolder valueHolder = null)
        {
            CatalogPage page = valueHolder.GetValue <CatalogPage>("CatalogPage");

            ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);

            message.Init(r63cOutgoing.CatalogPage);
            message.AppendInt32(page.PageID);
            message.AppendString("NORMAL");

            switch (page.PageLayout)
            {
            case "frontpage":
            {
                message.AppendString("frontpage4");
                message.AppendInt32(2);
                message.AppendString(page.PageHeadline);
                message.AppendString(page.PageTeaser);
                message.AppendInt32(3);
                message.AppendString(page.PageText1);
                message.AppendString(page.PageText2);
                message.AppendString(page.PageTeaser);
            }
            break;

            case "club_buy":
            {
                message.AppendString("vip_buy");
                message.AppendInt32(2);
                message.AppendString(page.PageHeadline);
                message.AppendString(page.PageTeaser);
                message.AppendInt32(0);
            }
            break;

            case "pets":
            {
                message.AppendString("pets");
                message.AppendInt32(2);
                message.AppendString(page.PageHeadline);
                message.AppendString(page.PageTeaser);
                message.AppendInt32(4);
                message.AppendString(page.PageText1);
                message.AppendString("");
                message.AppendString("Pick a color:");
                message.AppendString("Pick a race:");
            }
            break;

            case "spaces":
            {
                message.AppendString("spaces_new");
                message.AppendInt32(1);
                message.AppendString(page.PageHeadline);
                message.AppendInt32(1);
                message.AppendString(page.PageText1);
            }
            break;

            default:
            {
                message.AppendString(page.PageLayout);
                message.AppendInt32(3);
                message.AppendString(page.PageHeadline);
                message.AppendString(page.PageTeaser);
                message.AppendString(page.PageSpecial);
                message.AppendInt32(3);
                message.AppendString(page.PageText1);
                message.AppendString(page.PageTextDetails);
                message.AppendString(page.PageTextTeaser);
            }
            break;
            }

            message.AppendInt32(page.Items.Count); //items count
            foreach (CatalogItem item in page.Items.Values)
            {
                item.Serialize(message);
            }
            message.AppendInt32(0);
            message.AppendBoolean(false); //acceptSeasonCurrencyAsCredits
            return(message);
        }
 public ServerMessage Handle(T handler)
 {
     return(BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486, r63cOutgoing.InventoryRefresh));
 }
        public void Handle(GameClient session, ClientMessage message)
        {
            int gameId = message.PopWiredInt32();

            if (Skylight.GetGame().GetFastFoodManager().GetAPIConnection() != null)
            {
                FastFoodUser user;
                Skylight.GetGame().GetFastFoodManager().GetAPIConnection().AuthenicateUserAsync(user = Skylight.GetGame().GetFastFoodManager().GetOrCreate(session), (result) =>
                {
                    if (result)
                    {
                        ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_201211141113_913728051);
                        message_.Init(r63bOutgoing.LoadGame);
                        message_.AppendInt32(gameId);
                        message_.AppendString(Interlocked.Increment(ref StartGameMessageEvent.GameClientID).ToString());
                        message_.AppendString(Skylight.GetGame().GetFastFoodManager().GameLoadSettings.GameSWFUrl);       //Game SWF url
                        message_.AppendString(Skylight.GetGame().GetFastFoodManager().GameLoadSettings.Quality);          //quality
                        message_.AppendString(Skylight.GetGame().GetFastFoodManager().GameLoadSettings.Scale);            //scale mode
                        message_.AppendInt32(Skylight.GetGame().GetFastFoodManager().GameLoadSettings.FPS);               //FPS
                        message_.AppendInt32(Skylight.GetGame().GetFastFoodManager().GameLoadSettings.FlashMajorVersion); //flash major version min
                        message_.AppendInt32(Skylight.GetGame().GetFastFoodManager().GameLoadSettings.FlashMinorVersion); //flash minor version min

                        message_.AppendInt32(6);                                                                          //params count
                        message_.AppendString("habboHost");
                        message_.AppendString("http://habbobeta.pw");
                        message_.AppendString("accessToken");
                        message_.AppendString(user.SessionToken);

                        message_.AppendString("assetUrl");
                        message_.AppendString(Skylight.GetGame().GetFastFoodManager().GameLoadSettings.Params["assetUrl"]);
                        message_.AppendString("gameServerHost");
                        message_.AppendString(Skylight.GetGame().GetFastFoodManager().GameLoadSettings.Params["gameServerHost"]);
                        message_.AppendString("gameServerPort");
                        message_.AppendString(Skylight.GetGame().GetFastFoodManager().GameLoadSettings.Params["gameServerPort"]);
                        message_.AppendString("socketPolicyPort");
                        message_.AppendString(Skylight.GetGame().GetFastFoodManager().GameLoadSettings.Params["socketPolicyPort"]);

                        session.SendMessage(message_);
                    }
                    else
                    {
                        ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_201211141113_913728051);
                        message_.Init(r63bOutgoing.LeaveGameQueue);
                        message_.AppendInt32(gameId);
                        session.SendMessage(message_);

                        ServerMessage message_2 = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_201211141113_913728051);
                        message_2.Init(r63bOutgoing.GameButtonStatus);
                        message_2.AppendInt32(gameId);
                        message_2.AppendInt32(0);
                        session.SendMessage(message_2);

                        session.SendNotif("Error! Try again");
                    }
                });
            }
            else
            {
                ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_201211141113_913728051);
                message_.Init(r63bOutgoing.LeaveGameQueue);
                message_.AppendInt32(gameId);
                session.SendMessage(message_);

                ServerMessage message_2 = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_201211141113_913728051);
                message_2.Init(r63bOutgoing.GameButtonStatus);
                message_2.AppendInt32(gameId);
                message_2.AppendInt32(0);
                session.SendMessage(message_2);

                session.SendNotif("Error! Try again");
            }
        }
Beispiel #23
0
        public void BuyItem(GameClient session, int pageId, uint itemId, string extraData, int amountMultiplayer, bool asGift, string receiverUsername = "", string giftMessage = "", int giftSpriteId = 0, int giftBoxId = 0, int giftRibbonId = 0)
        {
            CatalogPage page = this.GetCatalogPage(pageId);

            if (page != null && page.Visible & page.Enabled && page.MinRank <= session.GetHabbo().Rank)
            {
                CatalogItem item = page.GetItem(itemId);
                if (item != null)
                {
                    if (item.IsDeal)
                    {
                        if (amountMultiplayer > 1)
                        {
                            session.SendNotif("You can't buy multiple deals at once!");
                            return;
                        }
                    }

                    Tuple <Item, int>[] products = item.GetItems();
                    uint giftReceiverId          = 0;
                    if (asGift)
                    {
                        foreach (Tuple <Item, int> data in products)
                        {
                            if (!data.Item1.AllowGift)
                            {
                                return;
                            }
                        }

                        giftReceiverId = Skylight.GetGame().GetGameClientManager().GetIDByUsername(receiverUsername);
                        if (giftReceiverId == 0) //not valid user
                        {
                            ServerMessage receiverNotFound = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                            receiverNotFound.Init(r63aOutgoing.GiftReceiverNotFound);
                            session.SendMessage(receiverNotFound);
                            return;
                        }
                    }

                    if (amountMultiplayer > 1 && products[0].Item2 * amountMultiplayer > 100)
                    {
                        session.SendNotif("You can't buy more then 100 at once with the buy command");
                        return;
                    }

                    int finalCredits = item.CostCredits * amountMultiplayer;
                    int finalPixels  = item.CostActivityPoints * amountMultiplayer;

                    if (asGift && giftSpriteId > 0) //special gifts costs one credit more
                    {
                        finalCredits++;
                    }

                    bool noCredits        = false;
                    bool noActivityPoints = false;

                    if (session.GetHabbo().Credits < finalCredits)
                    {
                        noCredits = true;
                    }

                    if (session.GetHabbo().TryGetActivityPoints(item.ActivityPointsType) < finalPixels)
                    {
                        noActivityPoints = true;
                    }

                    if (noCredits || noActivityPoints)
                    {
                        ServerMessage noEnoughtCash = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                        noEnoughtCash.Init(r63aOutgoing.NoEnoughtCash);
                        noEnoughtCash.AppendBoolean(noCredits);
                        noEnoughtCash.AppendBoolean(noActivityPoints);
                        session.SendMessage(noEnoughtCash);
                    }
                    else
                    {
                        if (asGift)
                        {
                            foreach (Tuple <Item, int> data in products)
                            {
                                if (data.Item1.Type == "e")
                                {
                                    session.SendNotif("You can not send this item as a gift.");
                                    return;
                                }
                            }
                        }

                        if (!item.IsDeal)
                        {
                            switch (products[0].Item1.InteractionType.ToLower())
                            {
                            case "pet":
                            {
                                string[] data    = extraData.Split('\n');
                                string   petName = data[0];
                                int      petRace = int.Parse(data[1]);
                                string   color   = data[2];

                                Regex regex = new Regex(@"^[A-Z0-9_-]+$", RegexOptions.IgnoreCase);
                                if (petName.Length >= 2 && petName.Length <= 16 && regex.IsMatch(petName) && !TextUtilies.HaveBlacklistedWords(petName))
                                {
                                    //buy
                                }
                                else
                                {
                                    return;
                                }

                                if (color.Length != 6)
                                {
                                    return;
                                }
                                break;
                            }

                            case "roomeffect":
                            {
                                extraData = TextUtilies.DoubleWithDotDecimal(double.Parse(extraData));
                            }
                            break;

                            case "postit":
                            {
                                extraData = "FFFF33";         //if you leave extra data empty same result, but for sure
                            }
                            break;

                            case "dimmer":
                            {
                                extraData = "1,1,1,#000000,255";         //current mode
                            }
                            break;

                            case "trophy":
                            {
                                extraData = session.GetHabbo().ID.ToString() + (char)9 + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + (char)9 + TextUtilies.FilterString(extraData, false, true);
                            }
                            break;

                            default:
                            {
                                extraData = "";
                                break;
                            }
                            }
                        }

                        if (finalCredits > 0)
                        {
                            session.GetHabbo().Credits -= finalCredits;
                            session.GetHabbo().UpdateCredits(true);
                        }

                        if (finalPixels > 0)
                        {
                            session.GetHabbo().RemoveActivityPoints(item.ActivityPointsType, finalPixels);
                            session.GetHabbo().UpdateActivityPoints(item.ActivityPointsType, true);
                        }

                        session.SendMessage(BasicUtilies.GetRevisionPacketManager(session.Revision).GetOutgoing(OutgoingPacketsEnum.BuyInfo).Handle(new ValueHolder("Item", item, "Products", products, "Credits", finalCredits, "Pixels", finalPixels)));

                        if (asGift)
                        {
                            Item gift = this.GetGiftLook(giftSpriteId);

                            using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                            {
                                string giftData = TextUtilies.FilterString(giftMessage, false, true) + (char)9 + session.GetHabbo().ID + (char)9 + giftBoxId + (char)9 + giftRibbonId;
                                dbClient.AddParamWithValue("giftData", giftData);
                                dbClient.AddParamWithValue("receiverId", giftReceiverId);
                                dbClient.AddParamWithValue("giftBaseItem", gift.ID);
                                uint giftItemId = (uint)dbClient.ExecuteQuery("INSERT INTO items(user_id, base_item, extra_data) VALUES(@receiverId, @giftBaseItem, @giftData)");

                                string baseItems = "";
                                string amounts   = "";
                                foreach (Tuple <Item, int> data in products)
                                {
                                    if (baseItems.Length > 0)
                                    {
                                        baseItems += ",";
                                        amounts   += ",";
                                    }

                                    baseItems += data.Item1.ID;
                                    amounts   += data.Item2 * amountMultiplayer;
                                }

                                dbClient.AddParamWithValue("itemId", giftItemId);
                                dbClient.AddParamWithValue("baseItems", baseItems);
                                dbClient.AddParamWithValue("amounts", amounts);
                                dbClient.AddParamWithValue("extraData", extraData);
                                dbClient.ExecuteQuery("INSERT INTO items_presents(item_id, base_ids, amounts, extra_data) VALUES(@itemId, @baseItems, @amounts, @extraData)");

                                GameClient receiver = Skylight.GetGame().GetGameClientManager().GetGameClientById(giftReceiverId);
                                if (receiver != null)
                                {
                                    if (giftReceiverId != session.GetHabbo().ID) //do achievement progress
                                    {
                                        receiver.GetHabbo().GetUserStats().GiftsReceived++;
                                        receiver.GetHabbo().GetUserAchievements().CheckAchievement("GiftReceiver");
                                    }

                                    receiver.GetHabbo().GetInventoryManager().AddItem(giftItemId, gift.ID, giftData, false);                                                                                       //add it to inventory first

                                    session.SendMessage(BasicUtilies.GetRevisionPacketManager(session.Revision).GetOutgoing(OutgoingPacketsEnum.UnseenItem).Handle(new ValueHolder("Type", 1, "ID", giftItemId))); //receiver one item in this case the gift

                                    //receiver.GetHabbo().GetInventoryManager().UpdateInventoryItems(true); //update inv
                                }
                                else
                                {
                                    if (giftReceiverId != session.GetHabbo().ID) //do achievement progress
                                    {
                                        dbClient.ExecuteQuery("UPDATE user_stats SET gifts_received = gifts_received + 1 WHERE user_id = @receiverId LIMIT 1");
                                    }
                                }
                            }

                            if (giftReceiverId != session.GetHabbo().ID) //do achievement progress
                            {
                                session.GetHabbo().GetUserStats().GiftsGived++;
                                session.GetHabbo().GetUserAchievements().CheckAchievement("GiftGiver");
                            }
                        }
                        else
                        {
                            session.GetHabbo().GetInventoryManager().SetQueueBytes(true);
                            foreach (Tuple <Item, int> data in products)
                            {
                                this.AddItem(session, data.Item1, data.Item2 * amountMultiplayer, extraData, true, false);
                            }
                            session.GetHabbo().GetInventoryManager().SetQueueBytes(false);
                        }
                    }
                }
            }
        }
Beispiel #24
0
        public void Handle(GameClient session, ClientMessage message)
        {
            if (session != null && session.GetHabbo() != null && session.GetHabbo().GetMessenger() != null)
            {
                int         count = message.PopWiredInt32();
                List <uint> users = new List <uint>();
                for (int i = 0; i < count; i++)
                {
                    uint userId = message.PopWiredUInt();
                    if (userId > 0)
                    {
                        users.Add(userId);
                    }
                }

                if (users.Count <= 0)
                {
                    return;
                }

                string text            = TextUtilies.FilterString(message.PopFixedString(), false, false);
                string filteredMessage = TextUtilies.CheckBlacklistedWords(text);

                ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                Message.Init(r63aOutgoing.MessengerRoomInvite);
                Message.AppendUInt(session.GetHabbo().ID);
                Message.AppendString(filteredMessage);

                List <string> receiverUsernames  = new List <string>();
                List <int>    receiverSessionIds = new List <int>();
                foreach (uint userId in users)
                {
                    if (session.GetHabbo().GetMessenger().IsFriendWith(userId))
                    {
                        GameClient gameClient = Skylight.GetGame().GetGameClientManager().GetGameClientById(userId);
                        if (gameClient != null)
                        {
                            if (gameClient.GetHabbo() != null)
                            {
                                receiverUsernames.Add(gameClient.GetHabbo().Username);
                                if (gameClient.GetHabbo().GetMessenger() != null && gameClient.GetHabbo().GetMessenger().IsFriendWith(session.GetHabbo().ID))
                                {
                                    gameClient.SendMessage(Message);
                                }
                            }
                            else
                            {
                                receiverUsernames.Add(Skylight.GetGame().GetGameClientManager().GetUsernameByID(userId));
                            }

                            receiverSessionIds.Add(gameClient.SessionID);
                        }
                        else
                        {
                            receiverUsernames.Add(Skylight.GetGame().GetGameClientManager().GetUsernameByID(userId));
                            receiverSessionIds.Add(-1);
                        }
                    }
                    else
                    {
                        receiverUsernames.Add(Skylight.GetGame().GetGameClientManager().GetUsernameByID(userId));
                        receiverSessionIds.Add(-1);
                    }
                }

                Skylight.GetGame().GetChatlogManager().LogRoomInvite(session, users, receiverUsernames, receiverSessionIds, text);
            }
        }
Beispiel #25
0
        public void UserWalkOn(RoomUnit unit)
        {
            if (unit.IsRealUser && unit is RoomUnitUser user)
            {
                if (this.Type == "curtains")
                {
                    user.RestrictMovementType |= RestrictMovementType.Client;
                    user.ChangingSwimsuit      = true;
                    user.StopMoving();

                    ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                    message.Init(r26Outgoing.Swimsuit);
                    user.Session.SendMessage(message);

                    ServerMessage message2 = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                    message2.Init(r26Outgoing.SpecialCast);
                    message2.AppendString(this.Data[0]);
                    message2.AppendString("close");
                    user.Room.SendToAll(message2);
                }
                else if (this.Type == "pool_enter")
                {
                    if (!string.IsNullOrEmpty(user.Swimsuit) && !user.Metadata.Remove("single_pool_enter_ignore"))
                    {
                        user.AddStatus("swim", "");

                        ServerMessage message2 = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                        message2.Init(r26Outgoing.SpecialCast);
                        message2.AppendString(this.Data[0]);
                        message2.AppendString("enter");
                        user.Room.SendToAll(message2);

                        user.MoveTo(int.Parse(this.Data[1]), int.Parse(this.Data[2]));
                        user.Metadata["single_pool_exit_ignore"] = null;
                    }
                }
                else if (this.Type == "pool_exit")
                {
                    if (!user.Metadata.Remove("single_pool_exit_ignore"))
                    {
                        user.RemoveStatus("swim");

                        ServerMessage message2 = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                        message2.Init(r26Outgoing.SpecialCast);
                        message2.AppendString(this.Data[0]);
                        message2.AppendString("exit");
                        user.Room.SendToAll(message2);

                        user.Override = true;
                        user.MoveTo(int.Parse(this.Data[1]), int.Parse(this.Data[2]));
                        user.Metadata["single_pool_enter_ignore"] = null;
                    }
                }
                else if (this.Type == "ws_left")
                {
                    if (this.Data[0] == "join")
                    {
                        user.RemoveStatus("swim");

                        user.RestrictMovementType |= RestrictMovementType.Client;
                        user.Override              = true;
                        user.MoveTo(this.X, this.Y - 1);
                    }
                    else if (this.Data[0] == "queue")
                    {
                        user.RestrictMovementType |= RestrictMovementType.Client;
                        user.Override              = true;
                        user.MoveTo(this.X, this.Y - 1);
                    }
                    else if (this.Data[0] == "play")
                    {
                        user.RestrictMovementType |= RestrictMovementType.Client;
                        user.Room.RoomGameManager.RoomWobbleSquabbleManager.LeftUser = user;
                        user.Room.RoomGameManager.RoomWobbleSquabbleManager.TryStart();
                    }
                }
                else if (this.Type == "ws_right")
                {
                    if (this.Data[0] == "join")
                    {
                        user.RemoveStatus("swim");

                        user.RestrictMovementType |= RestrictMovementType.Client;
                        user.Override              = true;
                        user.MoveTo(this.X, this.Y + 1);
                    }
                    else if (this.Data[0] == "queue")
                    {
                        user.RestrictMovementType |= RestrictMovementType.Client;
                        user.Override              = true;
                        user.MoveTo(this.X, this.Y + 1);
                    }
                    else if (this.Data[0] == "play")
                    {
                        user.RestrictMovementType |= RestrictMovementType.Client;
                        user.Room.RoomGameManager.RoomWobbleSquabbleManager.RightUser = user;
                        user.Room.RoomGameManager.RoomWobbleSquabbleManager.TryStart();
                    }
                }
                else if (this.Type == "open_gameboard")
                {
                    user.Room.RoomGameManager.Gameboards[uint.Parse(this.Data[1])].Join(user);
                }
            }
        }
        public ServerMessage Handle(ValueHolder valueHolder = null)
        {
            CatalogPage page = valueHolder.GetValue <CatalogPage>("CatalogPage");

            ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_201211141113_913728051);

            message.Init(r63bOutgoing.CatalogPage);
            message.AppendInt32(page.PageID);

            switch (page.PageLayout)
            {
            case "frontpage":
            {
                message.AppendString("frontpage3");
                message.AppendInt32(2);
                message.AppendString(page.PageHeadline);
                message.AppendString(page.PageTeaser);
                message.AppendInt32(11);
                message.AppendString(page.PageText1.Split(Convert.ToChar(10))[0]);
                message.AppendString(page.PageText1.Split(Convert.ToChar(10)).Length > 1 ? page.PageText1.Split(Convert.ToChar(10))[1] : "");
                message.AppendString(page.PageLinkDescription);
                message.AppendString(page.PageText2.Split(Convert.ToChar(10))[0]);
                message.AppendString(TextUtilies.MergeArrayToString(page.PageText2.Split(Convert.ToChar(10)), 1, false));
                message.AppendString(page.PageTextDetails);
                message.AppendString(page.PageLinkPagename);
                message.AppendString("#FAF8CC");
                message.AppendString("#FAF8CC");
                message.AppendString("Read More >");
                message.AppendString("magic.credits");
            }
            break;

            case "club_buy":
            {
                message.AppendString("club_buy");
                message.AppendInt32(1);
                message.AppendString("habboclub_1");
                message.AppendInt32(1);
            }
            break;

            case "pets":
            {
                message.AppendString("pets");
                message.AppendInt32(2);
                message.AppendString(page.PageHeadline);
                message.AppendString(page.PageTeaser);
                message.AppendInt32(4);
                message.AppendString(page.PageText1);
                message.AppendString("");
                message.AppendString("Pick a color:");
                message.AppendString("Pick a race:");
            }
            break;

            case "spaces":
            {
                message.AppendString("spaces_new");
                message.AppendInt32(1);
                message.AppendString(page.PageHeadline);
                message.AppendInt32(1);
                message.AppendString(page.PageText1);
            }
            break;

            default:
            {
                message.AppendString(page.PageLayout);
                message.AppendInt32(3);
                message.AppendString(page.PageHeadline);
                message.AppendString(page.PageTeaser);
                message.AppendString(page.PageSpecial);
                message.AppendInt32(3);
                message.AppendString(page.PageText1);
                message.AppendString(page.PageTextDetails);
                message.AppendString(page.PageTextTeaser);
            }
            break;
            }

            message.AppendInt32(page.Items.Count); //items count
            foreach (CatalogItem item in page.Items.Values)
            {
                item.Serialize(message);
            }
            message.AppendInt32(-1);
            message.AppendBoolean(false); //new?
            return(message);
        }
Beispiel #27
0
        public void BuyOffer(GameClient session, uint id)
        {
            MarketplaceOffer offer = this.TryGetOffer(id);

            if (offer != null)
            {
                if (!offer.Expired)
                {
                    if (!offer.Sold && !offer.Cancalled)
                    {
                        offer.Sold          = true;
                        offer.SoldTimestamp = TimeUtilies.GetUnixTimestamp();

                        this.Offers.Remove(id);   //remove it, not anymore active
                        this.Sold.Add(id, offer); //add it to solds :)

                        Item item = Skylight.GetGame().GetItemManager().TryGetItem(offer.ItemID);
                        if (item != null)
                        {
                            int totalPrice = this.CalcCompremission(offer.Price) + offer.Price;
                            if (session.GetHabbo().Credits < totalPrice)
                            {
                                ServerMessage result = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                result.Init(r63aOutgoing.MarketplaceBuyOfferResult);
                                result.AppendInt32(4); //result, 1 = success, 2 = all sold out, 3 = update item and show confirmation, 4 = no credits
                                result.AppendInt32(0);
                                result.AppendInt32(0);
                                result.AppendInt32(0);
                                session.SendMessage(result);
                            }
                            else
                            {
                                session.GetHabbo().Credits -= totalPrice;
                                session.GetHabbo().UpdateCredits(true);
                                session.GetHabbo().GetInventoryManager().AddItem(offer.FurniID, item.ID, offer.FurniExtraData, true);

                                using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                                {
                                    dbClient.AddParamWithValue("offerId", offer.ID);
                                    dbClient.AddParamWithValue("timestamp", offer.SoldTimestamp);

                                    dbClient.ExecuteQuery("UPDATE catalog_marketplace_offers SET sold = '1', sold_timestamp = @timestamp WHERE id = @offerId LIMIT 1");
                                }

                                ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                message.Init(r63aOutgoing.BuyInfo);
                                message.AppendUInt(item.ID);
                                message.AppendString(item.PublicName);
                                message.AppendInt32(totalPrice);
                                message.AppendInt32(0);
                                message.AppendInt32(0);
                                message.AppendInt32(1);
                                message.AppendString(item.Type.ToString());
                                message.AppendInt32(item.SpriteID);
                                message.AppendString("");
                                message.AppendInt32(1);
                                message.AppendInt32(-1);
                                message.AppendString("");
                                session.SendMessage(message);

                                ServerMessage result_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                result_.Init(r63aOutgoing.MarketplaceBuyOfferResult);
                                result_.AppendInt32(1); //result, 1 = success, 2 = all sold out, 3 = update item and show confirmation, 4 = no credits
                                result_.AppendInt32(0);
                                result_.AppendInt32(0);
                                result_.AppendInt32(0);
                                session.SendMessage(result_);
                            }
                        }
                        else
                        {
                            session.SendNotif("Unable to find item base item!");
                        }
                    }
                    else
                    {
                        MarketplaceOffer newOffer = this.TryGetMarketplaceOfferByItemID(offer.ItemID);
                        if (newOffer != null)
                        {
                            if (newOffer.Price != offer.Price)
                            {
                                ServerMessage result = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                result.Init(r63aOutgoing.MarketplaceBuyOfferResult);
                                result.AppendInt32(3);                                                       //result, 1 = success, 2 = all sold out, 3 = update item and show confirmation, 4 = no credits
                                result.AppendUInt(newOffer.ID);                                              //new id
                                result.AppendInt32(this.CalcCompremission(newOffer.Price) + newOffer.Price); //new price
                                result.AppendUInt(offer.ID);                                                 //old id
                                session.SendMessage(result);
                            }
                            else
                            {
                                this.BuyOffer(session, newOffer.ID);
                            }
                        }
                        else
                        {
                            ServerMessage result = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                            result.Init(r63aOutgoing.MarketplaceBuyOfferResult);
                            result.AppendInt32(2); //result, 1 = success, 2 = all sold out, 3 = update item and show confirmation, 4 = no credits
                            result.AppendUInt(0);  //new id
                            result.AppendInt32(0); //price
                            result.AppendUInt(0);  //old id
                            session.SendMessage(result);
                        }
                    }
                }
                else
                {
                    session.SendNotif("Offer have expired! Sorry! :(");
                }
            }
            else
            {
                session.SendNotif("Unable to find offer! Sorry! :(");
            }
        }
Beispiel #28
0
        private void DoWiredAction(RoomUnitUser target, string command, string data)
        {
            if (!string.IsNullOrEmpty(data))
            {
                data = data.Replace("%username%", target.Session.GetHabbo().Username);
                data = data.Replace("%userid%", target.Session.GetHabbo().ID.ToString());
            }

            switch (command)
            {
            case "sql":
            {
                using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                {
                    dbClient.ExecuteQuery(data);
                }
            }
            break;

            case "badge":
            {
                target.Session.GetHabbo().GetBadgeManager().AddBadge(data, 0, true);
            }
            break;

            case "award":
            {
                Skylight.GetGame().GetAchievementManager().AddAchievement(target.Session, data);
            }
            break;

            case "dance":
            {
                target.SetDance(int.Parse(data));
            }
            break;

            case "send":
            {
                Room room = Skylight.GetGame().GetRoomManager().TryGetAndLoadRoom(uint.Parse(data));
                if (room != null)
                {
                    ServerMessage followFriend = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                    followFriend.Init(r63aOutgoing.RoomForward);
                    followFriend.AppendBoolean(room.RoomData.IsPublicRoom);
                    followFriend.AppendUInt(room.ID);
                    target.Session.SendMessage(followFriend);
                }
                else
                {
                    this.Room.RoomUserManager.KickUser(target.Session, false);
                }
            }
            break;

            case "credits":
            {
                target.Session.GetHabbo().Credits += int.Parse(data);
                target.Session.GetHabbo().UpdateCredits(true);
            }
            break;

            case "pixels":
            {
                target.Session.GetHabbo().AddActivityPoints(0, int.Parse(data));
                target.Session.GetHabbo().UpdateActivityPoints(0, true);
            }
            break;

            case "points":
            {
                string[] data_ = data.Split(',');
                target.Session.GetHabbo().AddActivityPoints(int.Parse(data_[0]), int.Parse(data_[1]));
                target.Session.GetHabbo().UpdateActivityPoints(int.Parse(data_[0]), true);
            }
            break;

            case "shells":
            {
                target.Session.GetHabbo().AddActivityPoints(4, int.Parse(data));
                target.Session.GetHabbo().UpdateActivityPoints(4, true);
            }
            break;

            case "snowflakes":
            {
                target.Session.GetHabbo().AddActivityPoints(1, int.Parse(data));
                target.Session.GetHabbo().UpdateActivityPoints(1, true);
            }
            break;

            case "hearts":
            {
                target.Session.GetHabbo().AddActivityPoints(2, int.Parse(data));
                target.Session.GetHabbo().UpdateActivityPoints(2, true);
            }
            break;

            case "giftpoints":
            {
                target.Session.GetHabbo().AddActivityPoints(3, int.Parse(data));
                target.Session.GetHabbo().UpdateActivityPoints(3, true);
            }
            break;

            case "rank":
            {
                //using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                //{
                //    dbClient.AddParamWithValue("rank", int.Parse(data));
                //    dbClient.AddParamWithValue("userId", Session.GetHabbo().ID);
                //    dbClient.ExecuteQuery("UPDATE users SET rank = @rank WHERE id = @userId LIMIT 1");
                //}
                //Session.Stop("Super wired 'rank' used");
            }
            break;

            case "respect":
            {
                target.Session.GetHabbo().GetUserStats().RespectReceived++;
                using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                {
                    dbClient.AddParamWithValue("receiverId", target.Session.GetHabbo().ID);
                    dbClient.AddParamWithValue("receiverRespects", target.Session.GetHabbo().GetUserStats().RespectReceived);
                    dbClient.ExecuteQuery("UPDATE user_stats SET respect_received = @receiverRespects WHERE user_id = @receiverId LIMIT 1");
                }

                this.Room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.GiveRespect, new ValueHolder("UserID", target.Session.GetHabbo().ID, "Total", target.Session.GetHabbo().GetUserStats().RespectReceived)));

                target.Session.GetHabbo().GetUserAchievements().CheckAchievement("RespectReceived");
            }
            break;

            case "handitem":
            {
                target.SetHanditem(int.Parse(data));
            }
            break;

            case "alert":
            {
                target.Session.SendNotif(data);
            }
            break;

            case "motd":
            {
                target.Session.SendNotif(data, 2);
            }
            break;

            default:
            {
            }
            break;
            }
        }
        public void Handle(GameClient session, ClientMessage message)
        {
            Room room = Skylight.GetGame().GetRoomManager().TryGetRoom(session.GetHabbo().GetRoomSession().CurrentRoomID);

            if (room != null)
            {
                if (room.HaveOwnerRights(session))
                {
                    if (room.RoomData.State == RoomStateType.OPEN)
                    {
                        if (ServerConfiguration.EventsEnabled)
                        {
                            if (room.RoomEvent == null)
                            {
                                foreach (uint roomId in session.GetHabbo().UserRooms)
                                {
                                    Room room_ = Skylight.GetGame().GetRoomManager().TryGetRoom(roomId);
                                    if (room_ != null && room_.RoomEvent != null) //if any room events is already going
                                    {
                                        ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                        message_.Init(r63aOutgoing.CanCreateEventResult);
                                        message_.AppendBoolean(false); //can create
                                        message_.AppendInt32(6);       //error code
                                        session.SendMessage(message_);

                                        return;
                                    }
                                }

                                ServerMessage message_2 = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                message_2.Init(r63aOutgoing.CanCreateEventResult);
                                message_2.AppendBoolean(true); //can create
                                message_2.AppendInt32(0);      //error code
                                session.SendMessage(message_2);
                            }
                            else
                            {
                                ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                message_.Init(r63aOutgoing.CanCreateEventResult);
                                message_.AppendBoolean(false); //can create
                                message_.AppendInt32(5);       //error code
                                session.SendMessage(message_);
                            }
                        }
                        else
                        {
                            ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                            message_.Init(r63aOutgoing.CanCreateEventResult);
                            message_.AppendBoolean(false); //can create
                            message_.AppendInt32(4);       //error code
                            session.SendMessage(message_);
                        }
                    }
                    else
                    {
                        ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                        message_.Init(r63aOutgoing.CanCreateEventResult);
                        message_.AppendBoolean(false); //can create
                        message_.AppendInt32(3);       //error code
                        session.SendMessage(message_);
                    }
                }
                else
                {
                    ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                    message_.Init(r63aOutgoing.CanCreateEventResult);
                    message_.AppendBoolean(false); //can create
                    message_.AppendInt32(2);       //error code
                    session.SendMessage(message_);
                }
            }
            else
            {
                ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                message_.Init(r63aOutgoing.CanCreateEventResult);
                message_.AppendBoolean(false); //can create
                message_.AppendInt32(1);       //error code
                session.SendMessage(message_);
            }
        }
Beispiel #30
0
        public void Handle(GameClient session, ClientMessage message)
        {
            int windowId = message.PopWiredInt32();

            List <CatalogItem> items = Skylight.GetGame().GetCatalogManager().GetCatalogPages().Where(p => p.PageLayout == "club_buy").SelectMany(p => p.Items.Values).Where(i => i.Name.StartsWith("DEAL_VIP")).ToList();

            Subscription subscription = session.GetHabbo().GetSubscriptionManager().TryGetSubscription("habbo_vip", true, false);

            if (subscription == null) //user isint vip
            {
                subscription = session.GetHabbo().GetSubscriptionManager().TryGetSubscription("habbo_club", true, false);

                if (subscription == null) //still null
                {
                    subscription = new Subscription(0, "", TimeUtilies.GetUnixTimestamp(), TimeUtilies.GetUnixTimestamp());
                }
            }

            bool isUpgrade = !session.GetHabbo().IsVIP() && session.GetHabbo().IsHC();

            ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486);

            message_.Init(r63cOutgoing.ClubData);
            message_.AppendInt32(items.Count); //count
            foreach (CatalogItem item in items)
            {
                message_.AppendUInt(item.Id);
                message_.AppendString(item.Name);
                message_.AppendBoolean(true); //unused
                message_.AppendInt32(item.CostCredits);
                message_.AppendInt32(item.CostActivityPoints);
                message_.AppendInt32(item.ActivityPointsType);

                double vipUpgradeTime = 0;
                if (item.Name.StartsWith("DEAL_VIP"))
                {
                    message_.AppendBoolean(true);

                    if (isUpgrade)
                    {
                        vipUpgradeTime = subscription.SecoundsLeft() / 1.67;
                    }
                }
                else
                {
                    message_.AppendBoolean(false);
                }

                message_.AppendInt32(item.GetItems()[0].Item2);                                                    //months lenght
                message_.AppendInt32((int)Math.Ceiling(vipUpgradeTime / 86400) + (31 * item.GetItems()[0].Item2)); //days lenght
                message_.AppendBoolean(true);                                                                      //unused
                message_.AppendInt32(0);                                                                           //unused

                DateTime expires = TimeUtilies.UnixTimestampToDateTime(subscription.GetExpires() + (2678400.0 * item.GetItems()[0].Item2) + vipUpgradeTime);
                message_.AppendInt32(expires.Year);  //exprie year
                message_.AppendInt32(expires.Month); //expire month
                message_.AppendInt32(expires.Day);   //expire day
            }

            message_.AppendInt32(windowId);
            session.SendMessage(message_);
        }