Пример #1
0
        /// <summary>
        /// Loads this instance.
        /// </summary>
        public static void Load()
        {
            Cache.Clear();

            var message = new ServerMessage(LibraryParser.OutgoingRequest("SuperNotificationMessageComposer"));

            message.AppendString("furni_placement_error");
            message.AppendInteger(1);
            message.AppendString("message");
            message.AppendString("${room.error.cant_set_item}");
            Cache.Add(StaticMessage.ErrorCantSetItem, message.GetReversedBytes());

            message = new ServerMessage(LibraryParser.OutgoingRequest("SuperNotificationMessageComposer"));
            message.AppendString("furni_placement_error");
            message.AppendInteger(1);
            message.AppendString("message");
            message.AppendString("${room.error.cant_set_not_owner}");
            Cache.Add(StaticMessage.ErrorCantSetNotOwner, message.GetReversedBytes());

            message = new ServerMessage(LibraryParser.OutgoingRequest("SuperNotificationMessageComposer"));
            message.AppendString("game_promo_small");
            message.AppendInteger(4);
            message.AppendString("title");
            message.AppendString("${generic.notice}");
            message.AppendString("message");
            message.AppendString("Now, the commands page opens in a different way");
            message.AppendString("linkUrl");
            message.AppendString("event:habbopages/chat/newway");
            message.AppendString("linkTitle");
            message.AppendString("${mod.alert.link}");
            Cache.Add(StaticMessage.NewWayToOpenCommandsList, message.GetReversedBytes());

            message = new ServerMessage(LibraryParser.OutgoingRequest("SuperNotificationMessageComposer"));
            message.AppendString("");
            message.AppendInteger(4);
            message.AppendString("title");
            message.AppendString("${generic.notice}");
            message.AppendString("message");
            message.AppendString("${catalog.gift_wrapping.receiver_not_found.title}");
            message.AppendString("linkUrl");
            message.AppendString("event:");
            message.AppendString("linkTitle");
            message.AppendString("ok");
            Cache.Add(StaticMessage.UserNotFound, message.GetReversedBytes());

            message = new ServerMessage(LibraryParser.OutgoingRequest("SuperNotificationMessageComposer"));
            message.AppendString("");
            message.AppendInteger(4);
            message.AppendString("title");
            message.AppendString("${generic.notice}");
            message.AppendString("message");
            message.AppendString("You've exceeded the maximum furnis in inventory. Only furnis 2800 will show if you want to see the others, places some Furni in your rooms.");
            message.AppendString("linkUrl");
            message.AppendString("event:");
            message.AppendString("linkTitle");
            message.AppendString("ok");
            Cache.Add(StaticMessage.AdviceMaxItems, message.GetReversedBytes());

            message = new ServerMessage(LibraryParser.OutgoingRequest("SuperNotificationMessageComposer"));
            message.AppendString("");
            message.AppendInteger(4);
            message.AppendString("title");
            message.AppendString("${generic.notice}");
            message.AppendString("message");
            message.AppendString("You've exceeded the maximum furnis in inventory. You can not buy more until you desagas some furnis.");
            message.AppendString("linkUrl");
            message.AppendString("event:");
            message.AppendString("linkTitle");
            message.AppendString("ok");
            Cache.Add(StaticMessage.AdvicePurchaseMaxItems, message.GetReversedBytes());
        }
Пример #2
0
        /// <summary>
        ///     Serializes the navigator.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="mode">The mode.</param>
        /// <returns>ServerMessage.</returns>
        internal ServerMessage SerializeNavigator(GameClient session, int mode)
        {
            if (mode >= 0)
            {
                return(SerializeActiveRooms(mode));
            }

            ServerMessage reply = new ServerMessage(LibraryParser.OutgoingRequest("NavigatorListingsMessageComposer"));

            switch (mode)
            {
            case -6:
            {
                reply.AppendInteger(14);

                List <RoomData> activeGRooms = new List <RoomData>();

                KeyValuePair <RoomData, uint>[] rooms = Yupi.GetGame().GetRoomManager().GetActiveRooms();

                if (rooms != null && rooms.Any())
                {
                    activeGRooms.AddRange(from rd in rooms where rd.Key.GroupId != 0 select rd.Key);
                    activeGRooms = activeGRooms.OrderByDescending(p => p.UsersNow).ToList();
                }

                SerializeNavigatorRooms(ref reply, activeGRooms);

                return(reply);
            }

            case -5:
            case -4:
            {
                reply.AppendInteger(mode * -1);

                List <RoomData> activeFriends =
                    session.GetHabbo()
                    .GetMessenger()
                    .GetActiveFriendsRooms()
                    .OrderByDescending(p => p.UsersNow)
                    .ToList();
                SerializeNavigatorRooms(ref reply, activeFriends);

                return(reply);
            }

            case -3:
            {
                reply.AppendInteger(5);
                SerializeNavigatorRooms(ref reply, session.GetHabbo().UsersRooms);

                return(reply);
            }

            case -2:
            {
                reply.AppendInteger(2);

                try
                {
                    KeyValuePair <RoomData, int>[] rooms = Yupi.GetGame().GetRoomManager().GetVotedRooms();

                    SerializeNavigatorRooms(ref reply, rooms);

                    if (rooms != null)
                    {
                        Array.Clear(rooms, 0, rooms.Length);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    reply.AppendString(string.Empty);
                    reply.AppendInteger(0);
                }

                return(reply);
            }

            case -1:
            {
                reply.AppendInteger(1);
                reply.AppendString("-1");

                try
                {
                    KeyValuePair <RoomData, uint>[] rooms = Yupi.GetGame().GetRoomManager().GetActiveRooms();

                    SerializeNavigatorPopularRooms(ref reply, rooms);

                    if (rooms != null)
                    {
                        Array.Clear(rooms, 0, rooms.Length);
                    }
                }
                catch
                {
                    reply.AppendInteger(0);
                    reply.AppendBool(false);
                }

                return(reply);
            }
            }

            return(reply);
        }
Пример #3
0
        /// <summary>
        ///     Serializes the user chatlog.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns>ServerMessage.</returns>
        internal static ServerMessage SerializeUserChatlog(uint userId)
        {
            ServerMessage result;

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(
                    $"SELECT DISTINCT room_id FROM users_chatlogs WHERE user_id = '{userId}' ORDER BY timestamp DESC LIMIT 4");

                DataTable table = queryReactor.GetTable();

                ServerMessage serverMessage =
                    new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolUserChatlogMessageComposer"));
                serverMessage.AppendInteger(userId);
                serverMessage.AppendString(Yupi.GetGame().GetClientManager().GetNameById(userId));

                if (table != null)
                {
                    serverMessage.AppendInteger(table.Rows.Count);
                    IEnumerator enumerator = table.Rows.GetEnumerator();

                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            DataRow dataRow = (DataRow)enumerator.Current;

                            queryReactor.SetQuery(
                                $"SELECT user_id,timestamp,message FROM users_chatlogs WHERE room_id = {dataRow["room_id"]} AND user_id = {userId} ORDER BY timestamp DESC LIMIT 30");

                            DataTable table2   = queryReactor.GetTable();
                            RoomData  roomData = Yupi.GetGame().GetRoomManager().GenerateRoomData((uint)dataRow["room_id"]);

                            if (table2 != null)
                            {
                                serverMessage.AppendByte(1);
                                serverMessage.AppendShort(2);
                                serverMessage.AppendString("roomName");
                                serverMessage.AppendByte(2);
                                serverMessage.AppendString(roomData == null ? "This room was deleted" : roomData.Name);
                                serverMessage.AppendString("roomId");
                                serverMessage.AppendByte(1);
                                serverMessage.AppendInteger((uint)dataRow["room_id"]);
                                serverMessage.AppendShort(table2.Rows.Count);
                                IEnumerator enumerator2 = table2.Rows.GetEnumerator();
                                try
                                {
                                    while (enumerator2.MoveNext())
                                    {
                                        DataRow dataRow2 = (DataRow)enumerator2.Current;

                                        Habbo habboForId = Yupi.GetHabboById((uint)dataRow2["user_id"]);
                                        Yupi.UnixToDateTime((double)dataRow2["timestamp"]);

                                        if (habboForId == null)
                                        {
                                            return(null);
                                        }

                                        serverMessage.AppendInteger(
                                            (int)(Yupi.GetUnixTimeStamp() - (double)dataRow2["timestamp"]));

                                        serverMessage.AppendInteger(habboForId.Id);
                                        serverMessage.AppendString(habboForId.UserName);
                                        serverMessage.AppendString(dataRow2["message"].ToString());
                                        serverMessage.AppendBool(false);
                                    }
                                    continue;
                                }
                                finally
                                {
                                    IDisposable disposable = enumerator2 as IDisposable;

                                    disposable?.Dispose();
                                }
                            }

                            serverMessage.AppendByte(1);
                            serverMessage.AppendShort(0);
                            serverMessage.AppendShort(0);
                        }

                        result = serverMessage;
                        return(result);
                    }
                    finally
                    {
                        IDisposable disposable2 = enumerator as IDisposable;

                        disposable2?.Dispose();
                    }
                }

                serverMessage.AppendInteger(0);
                result = serverMessage;
            }
            return(result);
        }
Пример #4
0
        /// <summary>
        ///     Invokes the command.
        /// </summary>
        /// <param name="inputData">The input data.</param>
        internal static void InvokeCommand(string inputData)
        {
            if (string.IsNullOrEmpty(inputData) && ServerLogManager.DisabledState)
            {
                return;
            }

            Console.WriteLine();

            try
            {
                if (inputData == null)
                {
                    return;
                }

                string[] strArray = inputData.Split(' ');

                switch (strArray[0])
                {
                case "shutdown":
                case "close":
                    ServerLogManager.DisablePrimaryWriting(true);
                    Writer.WriteLine("Shutdown Initalized", "Yupi.Life", ConsoleColor.DarkYellow);
                    Yupi.PerformShutDown(false);
                    Console.WriteLine();
                    break;

                case "restart":
                    ServerLogManager.LogMessage($"Server Restarting at {DateTime.Now}");
                    ServerLogManager.DisablePrimaryWriting(true);
                    Writer.WriteLine("Restart Initialized", "Yupi.Life", ConsoleColor.DarkYellow);
                    Yupi.PerformShutDown(true);
                    Console.WriteLine();
                    break;

                case "flush":
                case "reload":
                    if (strArray.Length >= 2)
                    {
                        break;
                    }
                    Console.WriteLine("Please specify parameter. Type 'help' to know more about Console Commands");
                    Console.WriteLine();
                    break;

                case "alert":
                {
                    string        str     = inputData.Substring(6);
                    ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("BroadcastNotifMessageComposer"));
                    message.AppendString(str);
                    message.AppendString(string.Empty);
                    GetGame().GetClientManager().QueueBroadcaseMessage(message);
                    Console.WriteLine("[{0}] was sent!", str);
                    return;
                }

                case "clear":
                    Console.Clear();
                    break;

                case "status":
                    TimeSpan uptime = DateTime.Now - Yupi.ServerStarted;

                    Console.WriteLine("Server status:");
                    Console.WriteLine();
                    Console.WriteLine("Uptime:");
                    Console.WriteLine("\tDays:    {0}", uptime.Days);
                    Console.WriteLine("\tHours:   {0}", uptime.Hours);
                    Console.WriteLine("\tMinutes: {0}", uptime.Minutes);
                    Console.WriteLine();
                    Console.WriteLine("Stats:");
                    Console.WriteLine("\tAccepted Connections: {0}",
                                      Yupi.GetConnectionManager().Manager.AcceptedConnections);
                    Console.WriteLine("\tActive Threads: {0}", Process.GetCurrentProcess().Threads.Count);
                    Console.WriteLine();
                    Console.WriteLine();
                    break;

                case "gcinfo":
                {
                    Console.WriteLine("Mode: " + GCSettings.LatencyMode);
                    Console.WriteLine("Is server GC: " + GCSettings.IsServerGC);

                    break;
                }

                case "memstat":
                {
                    Console.WriteLine("GC status:");
                    Console.WriteLine("\tGeneration supported: " + GC.MaxGeneration);
                    Console.WriteLine("\tLatency mode: " + GCSettings.LatencyMode);
                    Console.WriteLine("\tIs server GC: " + GCSettings.IsServerGC);
                    Console.WriteLine();
                    break;
                }

                case "memory":
                {
                    GC.Collect();
                    Console.WriteLine("Memory flushed");

                    break;
                }

                case "help":
                    Console.WriteLine("shutdown/close - for safe shutting down Yupi");
                    Console.WriteLine("clear - Clear all text");
                    Console.WriteLine("memory - Call gargabe collector");
                    Console.WriteLine("alert (msg) - send alert to Every1!");
                    Console.WriteLine("flush/reload");
                    Console.WriteLine("   - catalog");
                    Console.WriteLine("   - modeldata");
                    Console.WriteLine("   - bans");
                    Console.WriteLine("   - packets (reload packets ids)");
                    Console.WriteLine("   - filter");
                    Console.WriteLine();
                    break;

                default:
                    UnknownCommand(inputData);
                    break;
                }

                switch (strArray[1])
                {
                case "database":
                    Console.WriteLine("Database destroyed");
                    Console.WriteLine();
                    break;

                case "packets":
                    LibraryParser.ReloadDictionarys();
                    Console.WriteLine("> Packets Reloaded Suceffuly...");
                    Console.WriteLine();
                    break;

                case "catalog":
                case "shop":
                case "catalogus":
                    FurnitureDataManager.SetCache();
                    using (IQueryAdapter adapter = Yupi.GetDatabaseManager().GetQueryReactor())
                        GetGame().GetCatalog().Initialize(adapter);
                    FurnitureDataManager.Clear();

                    GetGame()
                    .GetClientManager()
                    .QueueBroadcaseMessage(
                        new ServerMessage(LibraryParser.OutgoingRequest("PublishShopMessageComposer")));
                    Console.WriteLine("Catalogue was re-loaded.");
                    Console.WriteLine();
                    break;

                case "modeldata":
                    using (IQueryAdapter adapter2 = Yupi.GetDatabaseManager().GetQueryReactor())
                        GetGame().GetRoomManager().LoadModels(adapter2);
                    Console.WriteLine("Room models were re-loaded.");
                    Console.WriteLine();
                    break;

                case "bans":
                    using (IQueryAdapter adapter3 = Yupi.GetDatabaseManager().GetQueryReactor())
                        GetGame().GetBanManager().LoadBans(adapter3);
                    Console.WriteLine("Bans were re-loaded");
                    Console.WriteLine();
                    break;

                case "filter":
                    UserChatInputFilter.Reload();
                    BlackWordsManager.Reload();
                    break;

                default:
                    UnknownCommand(inputData);
                    Console.WriteLine();
                    break;
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
Пример #5
0
        /// <summary>
        ///     Enables the new navigator.
        /// </summary>
        /// <param name="session">The session.</param>
        internal void EnableNewNavigator(GameClient session)
        {
            ServerMessage navigatorMetaDataParser = new ServerMessage(LibraryParser.OutgoingRequest("NavigatorMetaDataComposer"));

            navigatorMetaDataParser.AppendInteger(4);
            navigatorMetaDataParser.AppendString("official_view");
            navigatorMetaDataParser.AppendInteger(0);
            navigatorMetaDataParser.AppendString("hotel_view");
            navigatorMetaDataParser.AppendInteger(0);
            navigatorMetaDataParser.AppendString("roomads_view");
            navigatorMetaDataParser.AppendInteger(0);
            navigatorMetaDataParser.AppendString("myworld_view");
            navigatorMetaDataParser.AppendInteger(0);
            session.SendMessage(navigatorMetaDataParser);

            ServerMessage navigatorLiftedRoomsParser =
                new ServerMessage(LibraryParser.OutgoingRequest("NavigatorLiftedRoomsComposer"));

            navigatorLiftedRoomsParser.AppendInteger(NavigatorHeaders.Count);

            foreach (NavigatorHeader navHeader in NavigatorHeaders)
            {
                navigatorLiftedRoomsParser.AppendInteger(navHeader.RoomId);
                navigatorLiftedRoomsParser.AppendInteger(0);
                navigatorLiftedRoomsParser.AppendString(navHeader.Image);
                navigatorLiftedRoomsParser.AppendString(navHeader.Caption);
            }

            session.SendMessage(navigatorLiftedRoomsParser);

            ServerMessage collapsedCategoriesMessageParser = new ServerMessage(LibraryParser.OutgoingRequest("NavigatorCategorys"));

            collapsedCategoriesMessageParser.AppendInteger(FlatCatsCount + 4);

            foreach (PublicCategory flat in PrivateCategories.Values)
            {
                collapsedCategoriesMessageParser.AppendString($"category__{flat.Caption}");
            }

            collapsedCategoriesMessageParser.AppendString("recommended");
            collapsedCategoriesMessageParser.AppendString("new_ads");
            collapsedCategoriesMessageParser.AppendString("staffpicks");
            collapsedCategoriesMessageParser.AppendString("official");
            session.SendMessage(collapsedCategoriesMessageParser);

            ServerMessage searches = new ServerMessage(LibraryParser.OutgoingRequest("NavigatorSavedSearchesComposer"));

            searches.AppendInteger(session.GetHabbo().NavigatorLogs.Count);

            foreach (UserSearchLog navi in session.GetHabbo().NavigatorLogs.Values)
            {
                searches.AppendInteger(navi.Id);
                searches.AppendString(navi.Value1);
                searches.AppendString(navi.Value2);
                searches.AppendString("");
            }

            session.SendMessage(searches);

            ServerMessage   packetName = new ServerMessage(LibraryParser.OutgoingRequest("NewNavigatorSizeMessageComposer"));
            UserPreferences pref       = session.GetHabbo().Preferences;

            packetName.AppendInteger(pref.NewnaviX);
            packetName.AppendInteger(pref.NewnaviY);
            packetName.AppendInteger(pref.NewnaviWidth);
            packetName.AppendInteger(pref.NewnaviHeight);
            packetName.AppendBool(false);
            packetName.AppendInteger(1);

            session.SendMessage(packetName);
        }
Пример #6
0
        /// <summary>
        ///     Called when [user say].
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="msg">The MSG.</param>
        internal override void OnUserSay(RoomUser user, string msg)
        {
            RoomUser roomUser = GetRoomUser();

            if (roomUser.PetData.OwnerId != user.GetClient().GetHabbo().Id)
            {
                return;
            }

            if (string.IsNullOrEmpty(msg))
            {
                msg = " ";
            }

            PetCommand command = PetCommandHandler.GetPetCommandByInput(msg.Substring(1).ToLower());

            if (!command.PetTypes.Contains(roomUser.PetData.Type))
            {
                return;
            }

            if (roomUser.PetData.Level < command.MinLevel)
            {
                return;
            }

            RemovePetStatus();

            _actionTimer = 25;
            _energyTimer = 10;

            if (roomUser.PetData.Energy < command.LostEnergy && roomUser.PetData.Nutrition < 25 ||
                roomUser.PetData.Energy < command.LostEnergy)
            {
                roomUser.UpdateNeeded = true;

                string[] valueLazy   = PetLocale.GetValue("pet.lazy");
                string   messageLazy = valueLazy[new Random().Next(0, valueLazy.Length - 1)];

                roomUser.Chat(null, messageLazy, false, 0);

                return;
            }

            roomUser.UpdateNeeded = true;

            roomUser.PetData.AddExperience(command.GainedExperience);

            roomUser.Statusses.Add(command.PetStatus, string.Empty);
            roomUser.Statusses.Add("gst", command.PetGesture);

            roomUser.FollowingOwner = null;

            SubtractAttributes(command.LostEnergy);

            Random random = new Random();

            string[] value   = PetLocale.GetValue(command.PetSpeech);
            string   message = value[random.Next(0, value.Length - 1)];

            roomUser.Statusses.Clear();
            roomUser.Chat(null, message, false, 0);

            /* other gestures that isnt listed */

            // roomUser.Statusses.Add("jmp", "");
            //roomUser.Statusses.Add("gst", "joy");

            //roomUser.AddStatus("lay", "");
            //roomUser.AddStatus("gst", "eyb");

            //roomUser.Statusses.Add("beg", "");
            //roomUser.Statusses.Add("gst", "sml");

            switch (command.CommandAction)
            {
            case "follow":
                roomUser.FollowingOwner = roomUser;

                RemovePetStatus();

                switch (roomUser.RotBody)
                {
                case 0:
                    roomUser.MoveTo(roomUser.X + 2, roomUser.Y);
                    break;

                case 1:
                    roomUser.MoveTo(roomUser.X - 2, roomUser.Y - 2);
                    break;

                case 2:
                    roomUser.MoveTo(roomUser.X, roomUser.Y + 2);
                    break;

                case 3:
                    roomUser.MoveTo(roomUser.X + 2, roomUser.Y - 2);
                    break;

                case 4:
                    roomUser.MoveTo(roomUser.X - 2, roomUser.Y);
                    break;

                case 5:
                    roomUser.MoveTo(roomUser.X + 2, roomUser.Y + 2);
                    break;

                case 6:
                    roomUser.MoveTo(roomUser.X, roomUser.Y - 2);
                    break;

                case 7:
                    roomUser.MoveTo(roomUser.X - 2, roomUser.Y + 2);
                    break;
                }

                break;

            case "breed":
                Point coord = new Point();

                switch (roomUser.PetData.Type)
                {
                case "pet_terrier":
                    coord = GetRoom().GetRoomItemHandler().GetRandomBreedingTerrier(roomUser.PetData);
                    break;

                case "pet_bear":
                    coord = GetRoom().GetRoomItemHandler().GetRandomBreedingBear(roomUser.PetData);
                    break;
                }

                if (coord == new Point())
                {
                    ServerMessage alert = new ServerMessage(LibraryParser.OutgoingRequest("PetBreedErrorMessageComposer"));

                    alert.AppendInteger(0);

                    user.GetClient().SendMessage(alert);
                }

                roomUser.MoveTo(coord, true);

                break;

            case "sleep":
                string[] valueSleep   = PetLocale.GetValue("tired");
                string   messageSleep = valueSleep[new Random().Next(0, valueSleep.Length - 1)];

                roomUser.Chat(null, messageSleep, false, 0);
                break;

            case "unknown":
                string[] valueUnknown   = PetLocale.GetValue("pet.unknowncommand");
                string   messageUnknown = valueUnknown[new Random().Next(0, valueUnknown.Length - 1)];

                roomUser.Chat(null, messageUnknown, false, 0);
                break;

            case "lazy":
                string[] valueLazy   = PetLocale.GetValue("pet.lazy");
                string   messageLazy = valueLazy[new Random().Next(0, valueLazy.Length - 1)];

                roomUser.Chat(null, messageLazy, false, 0);
                break;

            case "nest":
                RemovePetStatus();

                IEnumerable <RoomItem> petNest =
                    GetRoom()
                    .GetRoomItemHandler()
                    .FloorItems.Values.Where(x => x.GetBaseItem().InteractionType == Interaction.PetNest);

                IEnumerable <RoomItem> enumerable = petNest as RoomItem[] ?? petNest.ToArray();

                // @todo rewrite this to redo actionsss
                if (!enumerable.Any())
                {
                    command.CommandAction = "lazy";
                }

                RoomItem roomItems = enumerable.FirstOrDefault();

                if (roomItems != null)
                {
                    roomUser.MoveTo(roomItems.X, roomItems.Y);
                }

                roomUser.PetData.AddExperience(40);

                break;

            case "default":
                break;
            }
        }
Пример #7
0
        internal override void OnTimerTick()
        {
            if (base.GetBotData() != null)
            {
                #region Ammunation
                if (base.GetRoom().RoomData.Description.Contains("AMMUNATION"))
                {
                    if (base.GetRoomUser().RotBody != 2)
                    {
                        base.GetRoomUser().RotBody = 2;
                        base.GetRoomUser().RotHead = 2;
                    }
                }
                #endregion

                #region Hobo

                if (base.GetBotData().InteractingWith != null && base.GetBotData().Name.Contains("HOBO"))
                {
                    HabboHotel.PathFinding.Vector2D Pos1 = new HabboHotel.PathFinding.Vector2D(base.GetRoomUser().X, base.GetRoomUser().Y);

                    HabboHotel.PathFinding.Vector2D Pos2 = new HabboHotel.PathFinding.Vector2D(base.GetBotData().InteractingWith.X, base.GetBotData().InteractingWith.Y);

                    if (LActionTimer <= 5)
                    {
                        List <Point> list = base.GetRoom().GetGameMap().getWalkableList();
                        if (list.Count == 0)
                        {
                            return;
                        }
                        int randomNumber = new Random(DateTime.Now.Millisecond + this._virtualId ^ 2).Next(0, list.Count - 1);
                        base.GetRoomUser().MoveTo(list[randomNumber].X, list[randomNumber].Y, true);

                        LActionTimer++;
                    }
                    else
                    {
                        if (!Robbed)
                        {
                            if (RoleplayManager.Distance(Pos1, Pos2) > 1)
                            {
                                base.GetRoomUser().MoveTo(Pos2.X, Pos2.Y + 1, true);
                            }
                            else
                            {
                                base.GetRoomUser().MoveTo(Pos2.X, Pos2.Y + 1, true);
                                Robbed = true;
                            }
                        }

                        if (!Robbed && !base.GetRoomUser().IsWalking)
                        {
                            base.GetBotData().TimesTried++;
                        }

                        if (base.GetBotData().TimesTried >= 20)
                        {
                            base.GetRoomUser().Chat(null, "Filho da puta!", true, 1);
                            System.Threading.Thread.Sleep(2000);
                            RoleplayManager.KickBotFromRoom(base.GetRoomUser().BotData.Name, base.GetBotData().RoomId);
                        }

                        if (Robbed && !Done)
                        {
                            Random _s   = new Random();
                            int    Amnt = _s.Next(5, 100);

                            if (base.GetBotData().InteractingWith.GetClient() == null)
                            {
                                Done = true;
                            }

                            if (base.GetBotData().InteractingWith.GetClient().GetHabbo() == null)
                            {
                                Done = true;
                            }

                            if (base.GetBotData().InteractingWith.GetClient().GetHabbo().Credits - Amnt <= 0)
                            {
                                base.GetRoomUser().Chat(null, "Droga, você está sem dinheiro, vou deixar você ir desta vez!", true, 1);
                                Done = true;
                                return;
                            }

                            base.GetRoomUser().Chat(null, "*Rouba $" + Amnt + " de " + base.GetBotData().InteractingWith.GetClient().GetHabbo().UserName + " e foge*", true, 1);
                            RoleplayManager.GiveMoney(base.GetBotData().InteractingWith.GetClient(), -Amnt);
                            Done = true;
                        }

                        if (Done)
                        {
                            RoleplayManager.KickBotFromRoom(base.GetRoomUser().BotData.Name, base.GetBotData().RoomId);
                        }
                    }
                }
                else
                {
                    if (base.GetBotData() != null)
                    {
                        if (base.GetBotData().Name.Contains("HOBO"))
                        {
                            if (base.GetBotData().InteractingWith == null && base.GetBotData().Name.Contains("HOBO") || base.GetBotData().InteractingWith.GetClient().GetHabbo().CurrentRoomId != base.GetBotData().RoomId)
                            {
                                RoleplayManager.KickBotFromRoom(base.GetRoomUser().BotData.Name, base.GetBotData().RoomId);
                            }
                        }
                    }
                }

                #endregion

                #region Hobo 2

                if (base.GetBotData().InteractingWith != null && base.GetBotData().Name.Contains("HOBO 2"))
                {
                    HabboHotel.PathFinding.Vector2D Pos1 = new HabboHotel.PathFinding.Vector2D(base.GetRoomUser().X, base.GetRoomUser().Y);

                    HabboHotel.PathFinding.Vector2D Pos2 = new HabboHotel.PathFinding.Vector2D(base.GetBotData().InteractingWith.X, base.GetBotData().InteractingWith.Y);

                    if (LActionTimer <= 5)
                    {
                        List <Point> list = base.GetRoom().GetGameMap().getWalkableList();
                        if (list.Count == 0)
                        {
                            return;
                        }
                        int randomNumber = new Random(DateTime.Now.Millisecond + this._virtualId ^ 2).Next(0, list.Count - 1);
                        base.GetRoomUser().MoveTo(list[randomNumber].X, list[randomNumber].Y, true);

                        LActionTimer++;
                    }
                    else
                    {
                        if (!Robbed)
                        {
                            if (RoleplayManager.Distance(Pos1, Pos2) > 1)
                            {
                                base.GetRoomUser().MoveTo(Pos2.X, Pos2.Y + 1, true);
                            }
                            else
                            {
                                base.GetRoomUser().MoveTo(Pos2.X, Pos2.Y + 1, true);
                                Robbed = true;
                            }
                        }

                        if (!Robbed && !base.GetRoomUser().IsWalking)
                        {
                            base.GetBotData().TimesTried++;
                        }

                        if (base.GetBotData().TimesTried >= 20)
                        {
                            base.GetRoomUser().Chat(null, "Filho da puta!", true, 1);
                            System.Threading.Thread.Sleep(2000);
                            RoleplayManager.KickBotFromRoom(base.GetRoomUser().BotData.Name, base.GetBotData().RoomId);
                        }

                        if (Robbed && !Done)
                        {
                            Random _s       = new Random();
                            int    AmntBank = _s.Next(5, 500);

                            if (base.GetBotData().InteractingWith.GetClient() == null)
                            {
                                Done = true;
                            }

                            if (base.GetBotData().InteractingWith.GetClient().GetHabbo() == null)
                            {
                                Done = true;
                            }

                            if (base.GetBotData().InteractingWith.GetClient().GetRoleplay().Bank - AmntBank <= 0)
                            {
                                base.GetRoomUser().Chat(null, "Droga, você está sem dinheiro, vou deixar você ir desta vez!", true, 1);
                                Done = true;
                                return;
                            }

                            base.GetRoomUser().Chat(null, "*Rouba $" + AmntBank + " de " + base.GetBotData().InteractingWith.GetClient().GetHabbo().UserName + " e foge*", true, 1);
                            base.GetBotData().InteractingWith.GetClient().GetRoleplay().SaveQuickStat("bank", "" + (base.GetBotData().InteractingWith.GetClient().GetRoleplay().Bank - AmntBank));
                            base.GetBotData().InteractingWith.GetClient().GetRoleplay().Bank -= AmntBank;
                            Done = true;
                        }

                        if (Done)
                        {
                            RoleplayManager.KickBotFromRoom(base.GetRoomUser().BotData.Name, base.GetBotData().RoomId);
                        }
                    }
                }
                else
                {
                    if (base.GetBotData() != null)
                    {
                        if (base.GetBotData().Name.Contains("HOBO 2"))
                        {
                            if (base.GetBotData().InteractingWith == null && base.GetBotData().Name.Contains("HOBO 2") || base.GetBotData().InteractingWith.GetClient().GetHabbo().CurrentRoomId != base.GetBotData().RoomId)
                            {
                                RoleplayManager.KickBotFromRoom(base.GetRoomUser().BotData.Name, base.GetBotData().RoomId);
                            }
                        }
                    }
                }

                #endregion

                #region Free Roam Bot



                #endregion

                #region Store Bot

                if (robber != null)
                {
                    if (robber.GetHabbo() == null)
                    {
                        beingRobbed = false;
                        gatherNum   = 0;
                        gatherMsg   = 0;
                        amount      = 0;
                        return;
                    }

                    if (robber.GetHabbo().GetRoomUser() == null)
                    {
                        beingRobbed = false;
                        gatherNum   = 0;
                        gatherMsg   = 0;
                        amount      = 0;
                        return;
                    }


                    if (robber.GetRoleplay() == null)
                    {
                        beingRobbed = false;
                        gatherNum   = 0;
                        gatherMsg   = 0;
                        amount      = 0;
                        return;
                    }

                    if (robber.GetHabbo().GetRoomUser().Frozen || robber.GetRoleplay().Jailed || robber.GetRoleplay().Dead)
                    {
                        amount    = 0;
                        gatherMsg = 0;
                        gatherNum = 0;
                        robber.GetRoleplay().robbingStore = 0;
                        robber = null;
                        base.GetRoomUser().ApplyEffect(13);
                        disableRob  = true;
                        beingRobbed = false;
                        return;
                    }

                    if (gatherMsg <= 0)
                    {
                        base.GetRoomUser().Chat(null, "*Begins taking money from cash register*", true, 1);

                        if (gatherSpeed == 1)
                        {
                            gatherMsg = 10;
                        }

                        if (gatherSpeed == 2)
                        {
                            gatherMsg = 5;
                        }

                        if (gatherSpeed == 0)
                        {
                            gatherMsg = 20;
                        }


                        gatherNum++;
                    }
                    else
                    {
                        gatherMsg--;
                    }


                    if (gatherNum == 5)
                    {
                        int amount = new Random().Next(0, 100);

                        if (attack <= 6)
                        {
                            if (robber == null)
                            {
                                amount    = 0;
                                gatherMsg = 0;
                                gatherNum = 0;
                                robber.GetRoleplay().robbingStore = 0;
                                robber = null;
                                base.GetRoomUser().ApplyEffect(13);
                                disableRob  = true;
                                beingRobbed = false;
                                return;
                            }
                            else
                            {
                                attackCount++;

                                base.GetRoomUser().Chat(null, "*Takes out their pump shotgun*", true, 1);
                                base.GetRoomUser().ApplyEffect(164);

                                base.GetRoomUser().Chat(null, "*Shoots " + robber.GetHabbo().UserName + ", killing them!*", true, 1);

                                robber.GetRoleplay().DeadFigSet  = false;
                                robber.GetRoleplay().DeadSeconds = 60;
                                robber.GetRoleplay().DeadTimer   = 2;
                                robber.GetRoleplay().Dead        = true;
                                robber.GetRoleplay().SaveStatusComponents("dead");
                                RoleplayManager.HandleDeath(robber);
                                robber.SendNotif("You have been killed by a store clerk.");
                                return;
                            }
                        }

                        base.GetRoomUser().Chat(null, "*Drops money* Theres your money, now leave me alone!! [-$" + amount + "]", true, 1);
                        RoleplayManager.GiveMoney(robber, +amount);

                        amount    = 0;
                        gatherMsg = 0;
                        gatherNum = 0;
                        robber.GetRoleplay().robbingStore = 0;
                        robber = null;
                        base.GetRoomUser().ApplyEffect(13);
                        disableRob  = true;
                        beingRobbed = false;
                    }
                }
                else
                {
                    beingRobbed = false;
                    gatherNum   = 0;
                    gatherMsg   = 0;
                    amount      = 0;
                }

                lastRobbed++;
                if (lastRobbed > 5000 && disableRob)
                {
                    disableRob = false;
                    lastRobbed = 0;
                    base.GetRoomUser().ApplyEffect(0);
                }
            }

            #endregion

            #region Eatery Bot
            if (base.GetRoom() == null)
            {
                return;
            }
            if (base.GetRoom().RoomData.Description.Contains("EATERY"))
            {
                if (event_serving && event_serving_orderPlaced && !event_serving_delivered && !GetRoomUser().IsWalking)
                {
                    if (!resetted)
                    {
                        if (order_tick >= 15)
                        {
                            resetted = true;
                            GetRoomUser().Chat(null, "An error occured with pathfinding and I was unable to get to you, sorry about that!", true, 1);
                            serving.SendWhisper("Order has been aborted! Try sitting closer maybe?");
                            ResetVariablesFor("eatery");
                        }
                        else
                        {
                            order_tick++;
                        }
                    }
                }

                if (event_serving)
                {
                    if (event_serving_orderPlaced && !event_serving_delivered)
                    {
                        RoomUser User = serving.GetHabbo().GetRoomUser();


                        #region Delete Serve Session
                        if (serving == null)
                        {
                            event_serving = false;
                            ResetVariablesFor("eatery");
                            return;
                        }
                        if (serving.GetHabbo() == null)
                        {
                            event_serving = false;
                            ResetVariablesFor("eatery");
                            return;
                        }
                        if (serving.GetRoleplay() == null)
                        {
                            event_serving = false;
                            ResetVariablesFor("eatery");
                            return;
                        }
                        if (serving.GetHabbo().CurrentRoom == null)
                        {
                            event_serving = false;
                            ResetVariablesFor("eatery");
                            return;
                        }
                        if (serving.GetHabbo().CurrentRoom != GetRoom())
                        {
                            event_serving = false;
                            ResetVariablesFor("eatery");
                            return;
                        }
                        #endregion
                        if (!event_set_items)
                        {
                            event_serving_plate   = retrieveItem("diner_tray_0", true, User);
                            event_serving_oneway  = retrieveItem("one_way_door*1");
                            event_serving_oneway2 = retrieveItem("one_way_door*4");
                            event_set_items       = true;

                            if (event_serving_plate == null)
                            {
                                GetRoomUser().Chat(null, "Can you sit near an empty plate please?", true, 1);
                                ResetVariablesFor("eatery");
                                return;
                            }
                        }
                        else
                        {
                            /*
                             * Vector2D TargetVector = new Vector2D(event_serving_plate.GetX,event_serving_plate.GetY);
                             * Vector2D CurrentPos = new Vector2D(GetRoomUser().X,GetRoomUser().Y);
                             * if(Plus.Misc.Distance(TargetVector,CurrentPos) > 2)
                             * {
                             *
                             * }*/

                            if (Undefined_Timer_Tick_2 != 2)
                            {
                                passing_cur_gate       = false;
                                Undefined_Timer_Tick_2 = 2;
                            }

                            if (!event_serving_passedGate1)
                            {
                                HandleGatePass(event_serving_oneway);
                            }
                            else
                            {
                                GetRoomUser().AllowOverride = false;
                                if (!event_serving_atTable)
                                {
                                    if (GetRoomUser().X == RoleplayManager.GetPosSquare("behind", User).X&& GetRoomUser().Y == RoleplayManager.GetPosSquare("behind", User).Y)
                                    {
                                        GetRoomUser().RotBody = User.RotBody;
                                        GetRoomUser().RotHead = User.RotBody;
                                        event_serving_atTable = true;
                                    }
                                    else
                                    {
                                        GetRoomUser().MoveTo(RoleplayManager.GetPosSquare("behind", User));
                                    }
                                }
                                else
                                {
                                    if (!event_serving_delivered)
                                    {
                                        Food nFood = Substances.GetFoodByUName(event_serving_fooditem);

                                        RoleplayManager.ReplaceItem(serving, event_serving_plate, nFood.Item_Name);
                                        event_serving_delivered = true;
                                        GetRoomUser().Chat(null, "There you go, enjoy!", true, 1);

                                        ServerMessage action = new ServerMessage(LibraryParser.OutgoingRequest("RoomUserActionMessageComposer"));
                                        action.AppendInteger(GetRoomUser().VirtualId);
                                        action.AppendInteger(2);
                                        GetRoom().SendMessage(action);

                                        passing_cur_gate = false;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (!event_serving_passedGate2)
                        {
                            HandleGatePass(event_serving_oneway2);
                        }
                        else
                        {
                            ResetVariablesFor("eatery");
                        }
                    }
                }
            }
            #endregion
        }
Пример #8
0
        private void FreezeUser(RoomUser user)
        {
            if (user.IsBot || user.ShieldActive || user.Team == Team.None || user.Freezed)
            {
                return;
            }

            user.Freezed       = true;
            user.FreezeCounter = 0;
            --user.FreezeLives;

            if (user.FreezeLives <= 0)
            {
                ServerMessage serverMessage = new ServerMessage();
                serverMessage.Init(LibraryParser.OutgoingRequest("UpdateFreezeLivesMessageComposer"));
                serverMessage.AppendInteger(user.InternalRoomId);
                serverMessage.AppendInteger(user.FreezeLives);
                user.GetClient().SendMessage(serverMessage);
                user.ApplyEffect(-1);
                _room.GetGameManager().AddPointToTeam(user.Team, -10, user);
                TeamManager managerForFreeze = _room.GetTeamManagerForFreeze();
                managerForFreeze.OnUserLeave(user);
                user.Team = Team.None;
                if (ExitTeleport != null)
                {
                    _room.GetGameMap().TeleportToItem(user, ExitTeleport);
                }
                user.Freezed      = false;
                user.SetStep      = false;
                user.IsWalking    = false;
                user.UpdateNeeded = true;
                if (!managerForFreeze.BlueTeam.Any() && !managerForFreeze.RedTeam.Any() &&
                    !managerForFreeze.GreenTeam.Any() && managerForFreeze.YellowTeam.Any())
                {
                    StopGame();
                }
                else if (managerForFreeze.BlueTeam.Any() && !managerForFreeze.RedTeam.Any() &&
                         !managerForFreeze.GreenTeam.Any() && !managerForFreeze.YellowTeam.Any())
                {
                    StopGame();
                }
                else if (!managerForFreeze.BlueTeam.Any() && managerForFreeze.RedTeam.Any() &&
                         !managerForFreeze.GreenTeam.Any() && !managerForFreeze.YellowTeam.Any())
                {
                    StopGame();
                }
                else
                {
                    if (managerForFreeze.BlueTeam.Any() || managerForFreeze.RedTeam.Any() ||
                        !managerForFreeze.GreenTeam.Any() || managerForFreeze.YellowTeam.Any())
                    {
                        return;
                    }
                    StopGame();
                }
            }
            else
            {
                _room.GetGameManager().AddPointToTeam(user.Team, -10, user);
                user.ApplyEffect(12);
                ServerMessage serverMessage = new ServerMessage();
                serverMessage.Init(LibraryParser.OutgoingRequest("UpdateFreezeLivesMessageComposer"));
                serverMessage.AppendInteger(user.InternalRoomId);
                serverMessage.AppendInteger(user.FreezeLives);
                user.GetClient().SendMessage(serverMessage);
            }
        }
Пример #9
0
        /// <summary>
        /// Shutdown the Emulator
        /// </summary>
        /// <param name="restart">if set to <c>true</c> [restart].</param>
        /// Set a Different Message in Hotel
        internal static void PerformShutDown(bool restart)
        {
            var now = DateTime.Now;

            Cache.StopProcess();

            ShutdownStarted = true;

            var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("SuperNotificationMessageComposer"));

            serverMessage.AppendString("disconnection");
            serverMessage.AppendInteger(2);
            serverMessage.AppendString("title");
            serverMessage.AppendString("Emulator Shutting down");
            serverMessage.AppendString("message");
            serverMessage.AppendString("<b>A technician has applied new updates / fixes, so the hotel is shutting down for these changes to take effect! It will automatically come back in a few seconds! So Long!");
            GetGame().GetClientManager().QueueBroadcaseMessage(serverMessage);

            System.Threading.Thread.Sleep(3000);

            _game.StopGameLoop();
            _game.GetRoomManager().RemoveAllRooms();
            GetGame().GetClientManager().CloseAll();

            GetConnectionManager().Destroy();

            foreach (Guild group in _game.GetGroupManager().Groups.Values)
            {
                group.UpdateForum();
            }

            using (var queryReactor = Manager.GetQueryReactor())
            {
                queryReactor.RunFastQuery("UPDATE users SET online = '0'");
                queryReactor.RunFastQuery("UPDATE rooms_data SET users_now = 0");
                queryReactor.RunFastQuery("UPDATE server_settings SET value = '0' WHERE variable = 'status'");
            }

            _connectionManager.Destroy();
            _game.Destroy();

            try
            {
                Manager.Destroy();
                Out.WriteLine("Game Manager destroyed", "", ConsoleColor.Red);
            }
            catch (Exception e)
            {
                Writer.Writer.LogException("Plus.cs PerformShutDown GameManager" + e);
            }

            TimeSpan timeUsedOnShutdown = DateTime.Now - now;

            Console.WriteLine(" >> CityRP Emulator Successfully Shutdown <<");
            IsLive = false;

            if (restart)
            {
                Process.Start(Assembly.GetEntryAssembly().Location);
            }
            else
            {
                System.Threading.Thread.Sleep(2000);
            }

            Environment.Exit(0);
        }
Пример #10
0
        /// <summary>
        ///     Composes the club purchase page.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="windowId">The window identifier.</param>
        /// <returns>ServerMessage.</returns>
        internal static ServerMessage ComposeClubPurchasePage(GameClient session, int windowId)
        {
            ServerMessage      message        = new ServerMessage(LibraryParser.OutgoingRequest("CatalogueClubPageMessageComposer"));
            List <CatalogItem> habboClubItems = Yupi.GetGame().GetCatalog().HabboClubItems;

            message.AppendInteger(habboClubItems.Count);

            foreach (CatalogItem item in habboClubItems)
            {
                message.AppendInteger(item.Id);
                message.AppendString(item.Name);
                message.AppendBool(false);
                message.AppendInteger(item.CreditsCost);

                if (item.DiamondsCost > 0)
                {
                    message.AppendInteger(item.DiamondsCost);
                    message.AppendInteger(105);
                }
                else
                {
                    message.AppendInteger(item.DucketsCost);
                    message.AppendInteger(0);
                }

                message.AppendBool(true);
                string[] fuckingArray = item.Name.Split('_');
                double   dayTime      = 31;

                if (item.Name.Contains("DAY"))
                {
                    dayTime = int.Parse(fuckingArray[3]);
                }
                else if (item.Name.Contains("MONTH"))
                {
                    int monthTime = int.Parse(fuckingArray[3]);
                    dayTime = monthTime * 31;
                }
                else if (item.Name.Contains("YEAR"))
                {
                    int yearTimeOmg = int.Parse(fuckingArray[3]);
                    dayTime = yearTimeOmg * 31 * 12;
                }

                DateTime newExpiryDate = DateTime.Now.AddDays(dayTime);

                if (session.GetHabbo().GetSubscriptionManager().HasSubscription)
                {
                    newExpiryDate =
                        Yupi.UnixToDateTime(session.GetHabbo().GetSubscriptionManager().GetSubscription().ExpireTime)
                        .AddDays(dayTime);
                }

                message.AppendInteger((int)dayTime / 31);
                message.AppendInteger((int)dayTime);
                message.AppendBool(false);
                message.AppendInteger((int)dayTime);
                message.AppendInteger(newExpiryDate.Year);
                message.AppendInteger(newExpiryDate.Month);
                message.AppendInteger(newExpiryDate.Day);
            }

            message.AppendInteger(windowId);
            return(message);
        }
Пример #11
0
        /// <summary>
        ///     Composes the page.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <returns>ServerMessage.</returns>
        internal static ServerMessage ComposePage(CatalogPage page)
        {
            ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("CataloguePageMessageComposer"));

            message.AppendInteger(page.PageId);

            switch (page.Layout)
            {
            case "frontpage":
                message.AppendString("NORMAL");
                message.AppendString("frontpage4");
                message.AppendInteger(2);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendInteger(2);
                message.AppendString(page.Text1);
                message.AppendString(page.Text2);
                message.AppendInteger(0);
                message.AppendInteger(-1);
                message.AppendBool(false);
                break;

            case "roomads":
                message.AppendString("NORMAL");
                message.AppendString("roomads");
                message.AppendInteger(2);
                message.AppendString("events_header");
                message.AppendString("");
                message.AppendInteger(2);
                message.AppendString(page.Text1);
                message.AppendString("");
                break;

            case "builders_club_frontpage_normal":
                message.AppendString("NORMAL");
                message.AppendString("builders_club_frontpage");
                message.AppendInteger(0);
                message.AppendInteger(1);
                message.AppendString(page.LayoutHeadline);
                message.AppendInteger(3);
                message.AppendInteger(8554);
                message.AppendString("builders_club_1_month");
                message.AppendString("");
                message.AppendInteger(2560000);
                message.AppendInteger(2560000);
                message.AppendInteger(1024);
                message.AppendInteger(0);
                message.AppendInteger(0);
                message.AppendBool(false);
                message.AppendInteger(8606);
                message.AppendString("builders_club_14_days");
                message.AppendString("");
                message.AppendInteger(2560000);
                message.AppendInteger(2560000);
                message.AppendInteger(1024);
                message.AppendInteger(0);
                message.AppendInteger(0);
                message.AppendBool(false);
                message.AppendInteger(8710);
                message.AppendString("builders_club_31_days");
                message.AppendString("");
                message.AppendInteger(2560000);
                message.AppendInteger(2560000);
                message.AppendInteger(1024);
                message.AppendInteger(0);
                message.AppendInteger(0);
                message.AppendBool(false);
                break;

            case "bots":
                message.AppendString("NORMAL");
                message.AppendString("bots");
                message.AppendInteger(2);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendInteger(3);
                message.AppendString(page.Text1);
                message.AppendString(page.Text2);
                message.AppendString(page.TextDetails);
                break;

            case "badge_display":
                message.AppendString("NORMAL");
                message.AppendString("badge_display");
                message.AppendInteger(2);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendInteger(3);
                message.AppendString(page.Text1);
                message.AppendString(page.Text2);
                message.AppendString(page.TextDetails);
                break;

            case "info_loyalty":
            case "info_duckets":
                message.AppendString("NORMAL");
                message.AppendString(page.Layout);
                message.AppendInteger(1);
                message.AppendString(page.LayoutHeadline);
                message.AppendInteger(1);
                message.AppendString(page.Text1);
                break;

            case "sold_ltd_items":
                message.AppendString("NORMAL");
                message.AppendString("sold_ltd_items");
                message.AppendInteger(2);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendInteger(3);
                message.AppendString(page.Text1);
                message.AppendString(page.Text2);
                message.AppendString(page.TextDetails);
                break;

            case "recycler_info":
                message.AppendString("NORMAL");
                message.AppendString(page.Layout);
                message.AppendInteger(2);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendInteger(3);
                message.AppendString(page.Text1);
                message.AppendString(page.Text2);
                message.AppendString(page.TextDetails);
                break;

            case "recycler_prizes":
                message.AppendString("NORMAL");
                message.AppendString("recycler_prizes");
                message.AppendInteger(1);
                message.AppendString("catalog_recycler_headline3");
                message.AppendInteger(1);
                message.AppendString(page.Text1);
                break;

            case "spaces_new":
            case "spaces":
                message.AppendString("NORMAL");
                message.AppendString("spaces_new");
                message.AppendInteger(1);
                message.AppendString(page.LayoutHeadline);
                message.AppendInteger(1);
                message.AppendString(page.Text1);
                break;

            case "recycler":
                message.AppendString("NORMAL");
                message.AppendString("recycler");
                message.AppendInteger(2);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendInteger(1);
                message.AppendString(page.Text1);
                break;

            case "trophies":
                message.AppendString("NORMAL");
                message.AppendString("trophies");
                message.AppendInteger(1);
                message.AppendString(page.LayoutHeadline);
                message.AppendInteger(2);
                message.AppendString(page.Text1);
                message.AppendString(page.TextDetails);
                break;

            case "pets":
            case "pets2":
            case "pets3":
                message.AppendString("NORMAL");
                message.AppendString(page.Layout);
                message.AppendInteger(2);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendInteger(4);
                message.AppendString(page.Text1);
                message.AppendString(page.Text2);
                message.AppendString(page.TextDetails);
                message.AppendString(page.TextTeaser);
                break;

            case "soundmachine":
                message.AppendString("NORMAL");
                message.AppendString(page.Layout);
                message.AppendInteger(2);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendInteger(2);
                message.AppendString(page.Text1);
                message.AppendString(page.TextDetails);
                break;

            case "vip_buy":
                message.AppendString("NORMAL");
                message.AppendString(page.Layout);
                message.AppendInteger(2);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendInteger(0);
                break;

            case "guild_custom_furni":
                message.AppendString("NORMAL");
                message.AppendString("guild_custom_furni");
                message.AppendInteger(3);
                message.AppendString(page.LayoutHeadline);
                message.AppendString("");
                message.AppendString("");
                message.AppendInteger(3);
                message.AppendString(page.Text1);
                message.AppendString(page.TextDetails);
                message.AppendString(page.Text2);
                break;

            case "guild_frontpage":
                message.AppendString("NORMAL");
                message.AppendString("guild_frontpage");
                message.AppendInteger(2);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendInteger(3);
                message.AppendString(page.Text1);
                message.AppendString(page.TextDetails);
                message.AppendString(page.Text2);
                break;

            case "guild_forum":
                message.AppendString("NORMAL");
                message.AppendString("guild_forum");
                message.AppendInteger(0);
                message.AppendInteger(2);
                message.AppendString(page.Text1);
                message.AppendString(page.Text2);
                break;

            case "club_gifts":
                message.AppendString("NORMAL");
                message.AppendString("club_gifts");
                message.AppendInteger(1);
                message.AppendString(page.LayoutHeadline);
                message.AppendInteger(1);
                message.AppendString(page.Text1);
                break;

            case "default_3x3":
                message.AppendString("NORMAL");
                message.AppendString(page.Layout);
                message.AppendInteger(3);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendString(page.LayoutSpecial);
                message.AppendInteger(3);
                message.AppendString(page.Text1);
                message.AppendString(page.TextDetails);
                message.AppendString(page.TextTeaser);
                break;

            default:
                message.AppendString("NORMAL");
                message.AppendString(page.Layout);
                message.AppendInteger(3);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendString(page.LayoutSpecial);
                message.AppendInteger(4);
                message.AppendString(page.Text1);
                message.AppendString(page.Text2);
                message.AppendString(page.TextTeaser);
                message.AppendString(page.TextDetails);
                break;

            case "builders_3x3":
                message.AppendString("BUILDERS_CLUB");
                message.AppendString("default_3x3");
                message.AppendInteger(3);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendString(page.LayoutSpecial);
                message.AppendInteger(3);
                message.AppendString(page.Text1);
                message.AppendString(page.TextDetails.Replace("[10]", Convert.ToChar(10).ToString())
                                     .Replace("[13]", Convert.ToChar(13).ToString()));
                message.AppendString(page.TextTeaser.Replace("[10]", Convert.ToChar(10).ToString())
                                     .Replace("[13]", Convert.ToChar(13).ToString()));
                break;

            case "builders_3x3_color":
                message.AppendString("BUILDERS_CLUB");
                message.AppendString("default_3x3_color_grouping");
                message.AppendInteger(3);
                message.AppendString(page.LayoutHeadline);
                message.AppendString(page.LayoutTeaser);
                message.AppendString(page.LayoutSpecial);
                message.AppendInteger(3);
                message.AppendString(page.Text1);
                message.AppendString(page.TextDetails.Replace("[10]", Convert.ToChar(10).ToString())
                                     .Replace("[13]", Convert.ToChar(13).ToString()));
                message.AppendString(page.TextTeaser.Replace("[10]", Convert.ToChar(10).ToString())
                                     .Replace("[13]", Convert.ToChar(13).ToString()));
                break;

            case "builders_club_frontpage":
                message.AppendString("BUILDERS_CLUB");
                message.AppendString("builders_club_frontpage");
                message.AppendInteger(0);
                message.AppendInteger(1);
                message.AppendString(page.LayoutHeadline);
                message.AppendInteger(3);
                message.AppendInteger(8554);
                message.AppendString("builders_club_1_month");
                message.AppendString("");
                message.AppendInteger(2560000);
                message.AppendInteger(2560000);
                message.AppendInteger(1024);
                message.AppendInteger(0);
                message.AppendInteger(0);
                message.AppendBool(false);
                message.AppendInteger(8606);
                message.AppendString("builders_club_14_days");
                message.AppendString("");
                message.AppendInteger(2560000);
                message.AppendInteger(2560000);
                message.AppendInteger(1024);
                message.AppendInteger(0);
                message.AppendInteger(0);
                message.AppendBool(false);
                message.AppendInteger(8710);
                message.AppendString("builders_club_31_days");
                message.AppendString("");
                message.AppendInteger(2560000);
                message.AppendInteger(2560000);
                message.AppendInteger(1024);
                message.AppendInteger(0);
                message.AppendInteger(0);
                message.AppendBool(false);
                break;

            case "builders_club_addons":
                message.AppendString("BUILDERS_CLUB");
                message.AppendString("builders_club_addons");
                message.AppendInteger(0);
                message.AppendInteger(1);
                message.AppendString(page.LayoutHeadline);
                break;

            case "builders_club_addons_normal":
                message.AppendString("NORMAL");
                message.AppendString("builders_club_addons");
                message.AppendInteger(0);
                message.AppendInteger(1);
                message.AppendString(page.LayoutHeadline);
                break;
            }

            if (page.Layout.StartsWith("frontpage") || page.Layout == "vip_buy" || page.Layout == "recycler")
            {
                message.AppendInteger(0);
            }
            else
            {
                message.AppendInteger(page.Items.Count);

                foreach (CatalogItem item in page.Items.Values)
                {
                    ComposeItem(item, message);
                }
            }

            message.AppendInteger(-1);
            message.AppendBool(false);

            return(message);
        }
Пример #12
0
        /// <summary>
        ///     Composes the index.
        /// </summary>
        /// <param name="rank">The rank.</param>
        /// <param name="type">The type.</param>
        /// <returns>ServerMessage.</returns>
        internal static ServerMessage ComposeIndex(uint rank, string type)
        {
            IEnumerable <CatalogPage> pages =
                Yupi.GetGame().GetCatalog().Categories.Values.OfType <CatalogPage>().ToList();

            IOrderedEnumerable <CatalogPage> sortedPages = pages.Where(x => x.ParentId == -2 && x.MinRank <= rank).OrderBy(x => x.OrderNum);

            if (type == "NORMAL")
            {
                sortedPages = pages.Where(x => x.ParentId == -1 && x.MinRank <= rank).OrderBy(x => x.OrderNum);
            }

            ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("CatalogueIndexMessageComposer"));

            message.AppendBool(true);
            message.AppendInteger(0);
            message.AppendInteger(-1);
            message.AppendString("root");
            message.AppendString(string.Empty);
            message.AppendInteger(0);
            message.AppendInteger(sortedPages.Count());

            foreach (CatalogPage cat in sortedPages)
            {
                message.AppendBool(cat.Visible);
                message.AppendInteger(cat.IconImage);
                message.AppendInteger(cat.PageId);
                message.AppendString(cat.CodeName);
                message.AppendString(cat.Caption);
                message.AppendInteger(cat.FlatOffers.Count);

                foreach (uint i in cat.FlatOffers.Keys)
                {
                    message.AppendInteger(i);
                }

                IOrderedEnumerable <CatalogPage> sortedSubPages =
                    pages.Where(x => x.ParentId == cat.PageId && x.MinRank <= rank).OrderBy(x => x.OrderNum);

                message.AppendInteger(sortedSubPages.Count());

                foreach (CatalogPage subCat in sortedSubPages)
                {
                    message.AppendBool(subCat.Visible);
                    message.AppendInteger(subCat.IconImage);
                    message.AppendInteger(subCat.PageId);
                    message.AppendString(subCat.CodeName);
                    message.AppendString(subCat.Caption);
                    message.AppendInteger(subCat.FlatOffers.Count);

                    foreach (uint i2 in subCat.FlatOffers.Keys)
                    {
                        message.AppendInteger(i2);
                    }

                    message.AppendInteger(0);
                }
            }

            message.AppendBool(false);
            message.AppendString(type);

            return(message);
        }
Пример #13
0
        public static bool CanAttack(GameClient User1, GameClient User2, bool Weapon = false)
        {
            #region Fundamental Null Checks
            if (User2 == null)
            {
                User1.SendWhisper("This user was not found in this room!");
                return(false);
            }

            if (User2.GetHabbo() == null)
            {
                User1.SendWhisper("This user was not found in this room!");
                return(false);
            }

            if (User2.GetHabbo().CurrentRoom == null)
            {
                User1.SendWhisper("This user was not found in this room!");
                return(false);
            }

            if (User2.GetHabbo().CurrentRoom != User1.GetHabbo().CurrentRoom)
            {
                User1.SendWhisper("This user was not found in this room!");
                return(false);
            }
            #endregion

            Room     Room      = User1.GetHabbo().CurrentRoom;
            RoomUser RoomUser1 = User1.GetHabbo().GetRoomUser();
            RoomUser RoomUser2 = User2.GetHabbo().GetRoomUser();

            Vector2D Pos1 = new Vector2D(RoomUser1.X, RoomUser1.Y);
            Vector2D Pos2 = new Vector2D(RoomUser2.X, RoomUser2.Y);

            #region Cooldown Checks
            if (!Weapon)
            {
                if (User1.GetRoleplay().CoolDown > 0)
                {
                    User1.SendWhisper("You are cooling down! [" + User1.GetRoleplay().CoolDown + "/3]");
                    return(false);
                }
            }
            #endregion

            #region Game Checks
            if (User2.GetRoleplay().inColourWars&& !User1.GetRoleplay().inColourWars)
            {
                Room mRoom = RoleplayManager.GenerateRoom(ColourManager.MainLobby);
                User1.GetRoleplay().RequestedTaxi_Arrived      = false;
                User1.GetRoleplay().RecentlyCalledTaxi         = true;
                User1.GetRoleplay().RecentlyCalledTaxi_Timeout = 10;
                User1.GetRoleplay().RequestedTaxiDestination   = mRoom;
                User1.GetRoleplay().RequestedTaxi = true;
                User1.GetRoleplay().taxiTimer     = new taxiTimer(User1);
                User1.SendNotif("You cannot attack this person as they are in color wars! Please taxi out of the color wars room.");
                return(false);
            }
            if (User1.GetRoleplay().inColourWars&& !User2.GetRoleplay().inColourWars)
            {
                User1.SendNotif("You cannot attack this person as they are not in color wars!");
                return(false);
            }
            #endregion

            #region Special Checks
            if (User1.GetRoleplay().RayFrozen)
            {
                User1.SendWhisper("You cannot do this as you are frozen!");
                return(false);
            }
            #endregion

            if (!Weapon)
            {
                #region Fundamental Checks
                if (Room.RoomData.Description.Contains("NOHIT") && RoleplayManager.PurgeTime == false)
                {
                    User1.SendWhisper("Sorry, but this is a no hitting zone!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }
                #endregion

                #region Secondary Checks

                if (Room.RoomData.Description.Contains("SAFEZONE"))
                {
                    User1.SendWhisper("Sorry, but this is a safezone!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }
                if (Room.RoomData.Description.Contains("BRAWL") && !User1.GetRoleplay().inBrawl&& !User1.GetRoleplay().Brawl)
                {
                    User1.SendWhisper("You are not in a brawl, so you cannot do this!");
                    return(false);
                }
                if (User2.GetRoleplay().usingPlane)
                {
                    User1.SendWhisper("You cannot hit this user as they are in the sky!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }
                if (User1.GetRoleplay().Energy <= 0 && !User1.GetRoleplay().inColourWars)
                {
                    User1.SendWhisper("You do not have enough energy to do this!");
                    return(false);
                }
                if (User1.GetRoleplay().Dead)
                {
                    User1.SendWhisper("Cannot complete this action while you are dead!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }

                if (User1.GetRoleplay().Jailed)
                {
                    User1.SendWhisper("Cannot complete this action while you are jailed!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }

                if (User2.GetRoleplay().Dead)
                {
                    User1.SendWhisper("Cannot complete this action as this user is dead!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }

                if (User2.GetRoleplay().Jailed)
                {
                    User1.SendWhisper("Cannot complete this action as this user is jailed!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }

                if (RoomUser1.Stunned)
                {
                    User1.SendWhisper("Cannot complete this action while you are stunned!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }
                if (RoomUser2.IsAsleep)
                {
                    User1.SendWhisper("Cannot complete this action as this user is AFK!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }
                if (User1.GetRoleplay().IsNoob&& !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("COLOR") && !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("MAFIA"))
                {
                    if (!User1.GetRoleplay().NoobWarned)
                    {
                        User1.SendNotif("If you choose to do this again your temporary God Protection will be disabled!");
                        User1.GetRoleplay().NoobWarned = true;
                        return(false);
                    }
                    else
                    {
                        using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunFastQuery("UPDATE rp_stats SET is_noob = 0 WHERE id = '" + User1.GetHabbo().Id + "'");
                        }

                        User1.SendWhisper("Your god protection has been disabled!");
                        User1.GetRoleplay().IsNoob = false;
                        User1.GetRoleplay().SaveQuickStat("is_noob", "0");
                    }
                }

                if (User2.GetRoleplay().IsNoob&& !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("COLOR") && !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("MAFIA") && !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("NPA"))
                {
                    User1.SendWhisper("Cannot complete this action as this user is under God Protection!");
                    return(false);
                }
                #endregion

                #region Final Checks
                if (RoleplayManager.WithinAttackDistance(RoomUser1, RoomUser2))
                {
                }
                else if (RoleplayManager.Distance(Pos1, Pos2) > 2 && RoleplayManager.Distance(Pos1, Pos2) <= 4)
                {
                    RoomUser1.LastBubble = 3;

                    User1.Shout("*Swings at " + User2.GetHabbo().UserName + ", but misses*");
                    User1.GetRoleplay().CoolDown = 3;

                    RoomUser1.LastBubble = 0;
                    return(false);
                }
                else if (RoleplayManager.Distance(Pos1, Pos2) >= 5)
                {
                    User1.SendWhisper("You are too far away!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }
                #endregion
            }
            else if (Weapon)
            {
                #region Fundamental Checks
                if (User1.GetRoleplay().Energy < WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Need_Energy)
                {
                    User1.SendWhisper("You do not have enough energy to do this!");
                    return(false);
                }
                if (User1.GetRoleplay().inBrawl == true)
                {
                    User1.SendWhisper("Cannot do this in a Brawl");
                    return(false);
                }

                if (User1.GetRoleplay().Dead)
                {
                    User1.SendWhisper("Cannot complete this action while you are dead!");
                    return(false);
                }

                if (User1.GetRoleplay().Jailed)
                {
                    User1.SendWhisper("Cannot complete this action while you are jailed!");
                    return(false);
                }

                if (User2.GetRoleplay().Dead)
                {
                    User1.SendWhisper("Cannot complete this action as this user is dead!");
                    return(false);
                }

                if (User2.GetRoleplay().Jailed)
                {
                    User1.SendWhisper("Cannot complete this action as this user is jailed!");
                    return(false);
                }

                if (RoomUser1.Stunned)
                {
                    User1.SendWhisper("Cannot complete this action while you are stunned!");
                    return(false);
                }
                if (RoomUser2.IsAsleep)
                {
                    User1.SendWhisper("Cannot complete this action as this user is AFK!");
                    return(false);
                }
                if (RoomUser1.IsAsleep)
                {
                    User1.SendWhisper("Cannot complete this action as this user is AFK!");
                    return(false);
                }
                if (User1.GetRoleplay().IsNoob&& !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("COLOR") && !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("MAFIA"))
                {
                    if (!User1.GetRoleplay().NoobWarned)
                    {
                        User1.SendNotif("If you choose to do this again your temporary God Protection will be disabled!");
                        User1.GetRoleplay().NoobWarned = true;
                        return(false);
                    }
                    else
                    {
                        using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunFastQuery("UPDATE rp_stats SET is_noob = 0 WHERE id = '" + User1.GetHabbo().Id + "'");
                        }

                        User1.SendWhisper("Your god protection has been disabled!");
                        User1.GetRoleplay().IsNoob = false;
                        User1.GetRoleplay().SaveQuickStat("is_noob", "0");
                    }
                }

                if (User2.GetRoleplay().IsNoob&& !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("COLOR") && !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("MAFIA") && !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("NPA"))
                {
                    User1.SendWhisper("Cannot complete this action as this user is under God Protection!");
                    return(false);
                }
                #endregion

                #region Secondary Checks
                if (Room.RoomData.Description.Contains("NOSHOOT") && RoleplayManager.PurgeTime == false)
                {
                    User1.SendWhisper("Sorry, but this is a non shooting zone!");
                    return(false);
                }
                if (Room.RoomData.Description.Contains("SAFEZONE"))
                {
                    User1.SendWhisper("Sorry, but this is a safe zone!");
                    return(false);
                }
                if (User1.GetRoleplay().Equiped == null)
                {
                    User1.SendWhisper("You have not equiped a weapon!");
                    return(false);
                }
                if (!WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Type.ToLower().Contains("gun"))
                {
                    User1.SendWhisper("The weapon you have equiped is not a gun!");
                    return(false);
                }
                if (User2.GetRoleplay().usingPlane&& !WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Name.ToLower().Contains("rpg"))
                {
                    User1.Shout("*Attempts to shoot " + User2.GetHabbo().UserName + ", but misses as they are in a plane*");
                    User1.GetRoleplay().GunShots++;
                    return(false);
                }
                int MyJobId   = User1.GetRoleplay().JobId;
                int MyJobRank = User1.GetRoleplay().JobRank;
                if (User1.GetRoleplay().Bullets <= 0 && (!JobManager.JobRankData[MyJobId, MyJobRank].hasRights("army") && !User1.GetRoleplay().Working))
                {
                    User1.SendWhisper("You do not have any bullets!");
                    return(false);
                }
                if (User1.GetRoleplay().Intelligence < WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Min_Intel)
                {
                    User1.SendWhisper("You must have an intelligence level of at least " + WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Min_Intel + " to use this weapon!");
                    return(false);
                }
                if (User1.GetRoleplay().Strength + User1.GetRoleplay().savedSTR < WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Need_Str)
                {
                    User1.SendWhisper("You must have a strength level of at least " + WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Need_Str + " to use this weapon!");
                    return(false);
                }
                if (User1.GetRoleplay().GunShots >= WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Reload_Time)
                {
                    RoomUser1.LastBubble = 3;

                    User1.Shout("*Reloads their " + WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].DisplayName + ", and loads more bullets*");

                    RoomUser1.LastBubble = 0;
                    ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("FloodFilterMessageComposer"));
                    message.AppendInteger(5);
                    RoomUser1.IsGunReloaded    = true;
                    RoomUser1.ReloadExpiryTime = Plus.GetUnixTimeStamp() + 5;
                    User1.SendMessage(message);

                    User1.GetRoleplay().GunShots = 0;
                    // will re-inplement this later -> HabboHotel.Misc.ChatCommandHandler.Parse(User1, ":shoot " + TargetUser1.GetHabbo().UserName);
                    return(false);
                }
                #endregion

                #region Final Checks
                if (RoleplayManager.Distance(Pos1, Pos2) > WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Range)
                {
                    /*if (Misc.Distance(Pos1, Pos2) > weaponManager.WeaponsData[User1.GetRoleplay().Equiped].Range + 4)
                     * {
                     *  User1.SendWhisper("You must be closer to do this!");
                     *  return false;
                     * }*/

                    RoomUser1.LastBubble = 3;

                    User1.Shout("*Shoots their " + WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Name + " at " + User2.GetHabbo().UserName + ", but misses*");

                    RoomUser1.LastBubble = 0;
                    User1.GetRoleplay().GunShots++;
                    return(false);
                }
                #endregion
            }

            return(true);
        }
Пример #14
0
        public override void OnTrigger(GameClient session, RoomItem item, int request, bool hasRights)
        {
            if (!item.ExtraData.Contains('\u0005'.ToString()))
            {
                return;
            }

            string[] array = item.ExtraData.Split('\u0005');

            session.GetHabbo().Gender = array[0].ToUpper() == "F" ? "F" : "M";

            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary.Clear();

            string[] array2 = array[1].Split('.');

            foreach (string text in array2)
            {
                string[] array3 = session.GetHabbo().Look.Split('.');

                foreach (string text2 in array3)
                {
                    if (text2.Split('-')[0] == text.Split('-')[0])
                    {
                        if (dictionary.ContainsKey(text2.Split('-')[0]) && !dictionary.ContainsValue(text))
                        {
                            dictionary.Remove(text2.Split('-')[0]);
                            dictionary.Add(text2.Split('-')[0], text);
                        }
                        else
                        {
                            if (!dictionary.ContainsKey(text2.Split('-')[0]) && !dictionary.ContainsValue(text))
                            {
                                dictionary.Add(text2.Split('-')[0], text);
                            }
                        }
                    }
                    else
                    {
                        if (!dictionary.ContainsKey(text2.Split('-')[0]))
                        {
                            dictionary.Add(text2.Split('-')[0], text2);
                        }
                    }
                }
            }

            string text3 = dictionary.Values.Aggregate("", (current1, current) => $"{current1}{current}.");

            session.GetHabbo().Look = text3.TrimEnd('.');

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(
                    $"UPDATE users SET look = @look, gender = @gender WHERE id = {session.GetHabbo().Id}");
                queryReactor.AddParameter("look", session.GetHabbo().Look);
                queryReactor.AddParameter("gender", session.GetHabbo().Gender);
                queryReactor.RunQuery();
            }

            session.GetMessageHandler()
            .GetResponse()
            .Init(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));
            session.GetMessageHandler().GetResponse().AppendInteger(-1);
            session.GetMessageHandler().GetResponse().AppendString(session.GetHabbo().Look);
            session.GetMessageHandler().GetResponse().AppendString(session.GetHabbo().Gender.ToLower());
            session.GetMessageHandler().GetResponse().AppendString(session.GetHabbo().Motto);
            session.GetMessageHandler().GetResponse().AppendInteger(session.GetHabbo().AchievementPoints);
            session.GetMessageHandler().SendResponse();

            RoomUser roomUserByHabbo = item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().Id);

            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));

            serverMessage.AppendInteger(roomUserByHabbo.VirtualId);
            serverMessage.AppendString(session.GetHabbo().Look);
            serverMessage.AppendString(session.GetHabbo().Gender.ToLower());
            serverMessage.AppendString(session.GetHabbo().Motto);
            serverMessage.AppendInteger(session.GetHabbo().AchievementPoints);

            session.GetHabbo().CurrentRoom.SendMessage(serverMessage);
        }
Пример #15
0
        /// <summary>
        /// Serializes the popular room tags.
        /// </summary>
        /// <returns>ServerMessage.</returns>
        internal ServerMessage SerializePopularRoomTags()
        {
            var           dictionary = new Dictionary <string, int>();
            ServerMessage result;

            using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
            {
                /*
                 * Old_users_now
                 * queryReactor.SetQuery(
                 *  "SELECT tags, users_now FROM rooms_data WHERE roomtype = 'private' AND users_now > 0 ORDER BY users_now DESC LIMIT 50");
                 * var table = queryReactor.GetTable();
                 * if (table != null)
                 * {
                 *  foreach (DataRow dataRow in table.Rows)
                 *  {
                 *      int usersNow;
                 *      if (!string.IsNullOrEmpty(dataRow["users_now"].ToString())) usersNow = (int)dataRow["users_now"];
                 *      else usersNow = 0;
                 *      var array = dataRow["tags"].ToString().Split(',');
                 *      var list = array.ToList();
                 *      foreach (var current in list)
                 *      {
                 *          if (dictionary.ContainsKey(current)) dictionary[current] += usersNow;
                 *          else dictionary.Add(current, usersNow);
                 *      }
                 *  }
                 * }
                 *
                 * */

                foreach (Room Room in Plus.GetGame().GetRoomManager().LoadedRooms.Values.ToList().OrderByDescending(key => key.UserCount))
                {
                    if (Room == null)
                    {
                        continue;
                    }
                    if (Room.RoomData == null)
                    {
                        continue;
                    }

                    if (dictionary.ContainsKey(Room.RoomData.Name))
                    {
                        dictionary[Room.RoomData.Name] += Convert.ToInt32(Room.RoomData.UsersNow);
                    }
                    else
                    {
                        dictionary.Add(Room.RoomData.Name, Convert.ToInt32(Room.RoomData.UsersNow));
                    }
                }

                var list2 = new List <KeyValuePair <string, int> >(dictionary);
                list2.Sort(
                    (firstPair, nextPair) =>
                    firstPair.Value.CompareTo(nextPair.Value));
                var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("PopularRoomTagsMessageComposer"));
                serverMessage.AppendInteger(list2.Count);
                foreach (var current2 in list2)
                {
                    serverMessage.AppendString(current2.Key);
                    serverMessage.AppendInteger(current2.Value);
                }
                result = serverMessage;
            }
            return(result);
        }
Пример #16
0
        /// <summary>
        /// Completes the user talent.
        /// </summary>
        /// <param name="Session">The session.</param>
        /// <param name="Talent">The talent.</param>
        internal void CompleteUserTalent(GameClient Session, Talent Talent)
        {
            if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().CurrentTalentLevel < Talent.Level || Session.GetHabbo().Talents.ContainsKey(Talent.Id))
            {
                return;
            }
            if (!this.LevelIsCompleted(Session, Talent.Type, Talent.Level))
            {
                return;
            }
            if (!string.IsNullOrEmpty(Talent.Prize) && Talent.PrizeBaseItem > 0u)
            {
                Item item = Plus.GetGame().GetItemManager().GetItem(Talent.PrizeBaseItem);
                Plus.GetGame().GetCatalog().DeliverItems(Session, item, 1, "", 0, 0, "");
            }
            var value = new UserTalent(Talent.Id, 1);

            Session.GetHabbo().Talents.Add(Talent.Id, value);
            using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.RunFastQuery(string.Concat(new object[]
                {
                    "REPLACE INTO users_talents VALUES (",
                    Session.GetHabbo().Id,
                    ", ",
                    Talent.Id,
                    ", ",
                    1,
                    ");"
                }));
            }
            var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("TalentLevelUpMessageComposer"));

            serverMessage.AppendString(Talent.Type);
            serverMessage.AppendInteger(Talent.Level);
            serverMessage.AppendInteger(0);
            if (Talent.Type == "citizenship" && Talent.Level == 4)
            {
                serverMessage.AppendInteger(2);
                serverMessage.AppendString("HABBO_CLUB_VIP_7_DAYS");
                serverMessage.AppendInteger(7);
                serverMessage.AppendString(Talent.Prize);
                serverMessage.AppendInteger(0);
            }
            else
            {
                serverMessage.AppendInteger(1);
                serverMessage.AppendString(Talent.Prize);
                serverMessage.AppendInteger(0);
            }

            Session.SendMessage(serverMessage);

            if (Talent.Type == "citizenship")
            {
                if (Talent.Level == 3)
                {
                    Plus.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_Citizenship", 1);
                }
                else if (Talent.Level == 4)
                {
                    Session.GetHabbo().GetSubscriptionManager().AddSubscription(7);
                    using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
                    {
                        queryReactor.RunFastQuery(string.Concat(new object[]
                        {
                            "UPDATE users SET talent_status = 'helper' WHERE id = ",
                            Session.GetHabbo().Id,
                            ";"
                        }));
                    }
                }
            }
        }
Пример #17
0
        public bool Execute(params object[] stuff)
        {
            if (stuff[0] == null)
            {
                return(false);
            }

            RoomUser user = (RoomUser)stuff[0];

            if (stuff[1] == null)
            {
                return(false);
            }

            Interaction item = (Interaction)stuff[1];

            if (_mBanned.Contains(item))
            {
                return(false);
            }

            if (user == null)
            {
                return(false);
            }

            if (OtherExtraString2 == null)
            {
                return(false);
            }

            int amountLeft = Convert.ToInt32(OtherExtraString2);

            bool unique = OtherBool;

            bool premied = false;

            if (amountLeft == 1)
            {
                ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("WiredRewardAlertMessageComposer"));

                message.AppendInteger(0);
                user.GetClient().SendMessage(message);

                return(true);
            }

            foreach (string dataStr in OtherString.Split(';'))
            {
                string[] dataArray = dataStr.Split(',');

                bool   isbadge    = dataArray[0] == "0";
                string code       = dataArray[1];
                int    percentage = int.Parse(dataArray[2]);

                int random = Yupi.GetRandomNumber(0, 100);

                ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("WiredRewardAlertMessageComposer"));

                if (!unique && percentage < random)
                {
                    continue;
                }

                premied = true;

                if (isbadge)
                {
                    if (user.GetClient().GetHabbo().GetBadgeComponent().HasBadge(code))
                    {
                        message.AppendInteger(1);
                        user.GetClient().SendMessage(message);
                    }
                    else
                    {
                        user.GetClient()
                        .GetHabbo()
                        .GetBadgeComponent()
                        .GiveBadge(code, true, user.GetClient(), true);

                        message.AppendInteger(7);
                        user.GetClient().SendMessage(message);
                    }
                }
                else //item or effect
                {
                    Item roomItem = Yupi.GetGame().GetItemManager().GetItem(uint.Parse(code));

                    if (roomItem == null)
                    {
                        continue;
                    }

                    if (roomItem.Type == 'e') // is effect
                    {
                        user.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().AddNewEffect(roomItem.SpriteId, 3600, 1);
                    }
                    else
                    {
                        user.GetClient().GetHabbo().GetInventoryComponent().AddNewItem(0u, roomItem.Name, "0", 0u, true, false, 0, 0);
                        user.GetClient().SendMessage(new ServerMessage(LibraryParser.OutgoingRequest("UpdateInventoryMessageComposer")));
                    }

                    message.AppendInteger(6);
                    user.GetClient().SendMessage(message);
                }
            }

            if (!premied)
            {
                ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("WiredRewardAlertMessageComposer"));
                message.AppendInteger(4);
                user.GetClient().SendMessage(message);
            }
            else if (amountLeft > 1)
            {
                amountLeft--;
                OtherExtraString2 = amountLeft.ToString();
            }

            return(true);
        }
Пример #18
0
        /// <summary>
        ///     Requests the buddy.
        /// </summary>
        /// <param name="userQuery">The user query.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        internal bool RequestBuddy(string userQuery)
        {
            GameClient clientByUsername = Yupi.GetGame().GetClientManager().GetClientByUserName(userQuery);

            uint userId;
            bool blockForNewFriends;

            if (clientByUsername == null)
            {
                DataRow dataRow;

                using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    commitableQueryReactor.SetQuery("SELECT id, block_newfriends FROM users WHERE username = @query");

                    commitableQueryReactor.AddParameter("query", userQuery.ToLower());
                    dataRow = commitableQueryReactor.GetRow();
                }

                if (dataRow == null)
                {
                    return(false);
                }

                userId = Convert.ToUInt32(dataRow["id"]);

                blockForNewFriends = Yupi.EnumToBool(dataRow["block_newfriends"].ToString());
            }
            else
            {
                Habbo currentUser = clientByUsername.GetHabbo();

                userId = currentUser.Id;

                blockForNewFriends = currentUser.HasFriendRequestsDisabled;
            }

            GameClient client = GetClient();

            if (blockForNewFriends && client.GetHabbo().Rank < 4)
            {
                client.GetMessageHandler()
                .GetResponse()
                .Init(LibraryParser.OutgoingRequest("NotAcceptingRequestsMessageComposer"));

                client.GetMessageHandler().GetResponse().AppendInteger(39);
                client.GetMessageHandler().GetResponse().AppendInteger(3);
                client.GetMessageHandler().SendResponse();

                return(false);
            }

            if (RequestExists(userId))
            {
                client.SendNotif("Você já enviou um pedido de amizade anteriormente.");
                //@todo: Mudar Texto para sistema de langs

                return(true);
            }

            using (IQueryAdapter queryreactor2 = Yupi.GetDatabaseManager().GetQueryReactor())
                queryreactor2.RunFastQuery(string.Concat("REPLACE INTO messenger_requests (from_id,to_id) VALUES (",
                                                         _userId, ",", userId, ")"));

            Habbo fromUser = client.GetHabbo();

            if (clientByUsername?.GetHabbo() != null && fromUser != null)
            {
                MessengerRequest messengerRequest = new MessengerRequest(userId, _userId, fromUser.UserName, fromUser.Look);

                clientByUsername.GetHabbo().GetMessenger().OnNewRequest(_userId, messengerRequest);

                ServerMessage serverMessage =
                    new ServerMessage(LibraryParser.OutgoingRequest("ConsoleSendFriendRequestMessageComposer"));

                messengerRequest.Serialize(serverMessage);
                clientByUsername.SendMessage(serverMessage);
            }

            return(true);
        }
Пример #19
0
        public void ProcessChange()
        {
            string text2 = NewClothing;
            string text  = Gender;

            Plus.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.ProfileChangeLook, 0u);
            Session.GetHabbo().Look   = text2;
            Session.GetHabbo().Gender = text.ToLower();
            using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(string.Format("UPDATE users SET look = @look, gender = @gender WHERE id = {0}",
                                                    Session.GetHabbo().Id));
                queryReactor.AddParameter("look", text2);
                queryReactor.AddParameter("gender", text);
                queryReactor.RunQuery();
            }
            Plus.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_AvatarLooks", 1, false);
            if (Session.GetHabbo().Look.Contains("ha-1006"))
            {
                Plus.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.WearHat, 0u);
            }
            Session.GetMessageHandler()
            .GetResponse()
            .Init(LibraryParser.OutgoingRequest("UpdateAvatarAspectMessageComposer"));
            Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Look);
            Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Gender.ToUpper());
            Session.GetMessageHandler().SendResponse();
            Session.GetMessageHandler()
            .GetResponse()
            .Init(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));
            Session.GetMessageHandler().GetResponse().AppendInteger(-1);
            Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Look);
            Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Gender.ToLower());
            Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Motto);
            Session.GetMessageHandler().GetResponse().AppendInteger(Session.GetHabbo().AchievementPoints);
            Session.GetMessageHandler().SendResponse();
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }
            var currentRoom = Session.GetHabbo().CurrentRoom;

            if (currentRoom == null)
            {
                return;
            }
            var roomUserByHabbo = currentRoom.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (roomUserByHabbo == null)
            {
                return;
            }
            var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));

            serverMessage.AppendInteger(roomUserByHabbo.VirtualId); //BUGG
            //serverMessage.AppendInt32(-1);
            serverMessage.AppendString(Session.GetHabbo().Look);
            serverMessage.AppendString(Session.GetHabbo().Gender.ToLower());
            serverMessage.AppendString(Session.GetHabbo().Motto);
            serverMessage.AppendInteger(Session.GetHabbo().AchievementPoints);
            currentRoom.SendMessage(serverMessage);

            if (Session.GetHabbo().GetMessenger() != null)
            {
                Session.GetHabbo().GetMessenger().OnStatusChanged(true);
            }

            Session.Shout("*Muda de roupa/penteado e paga pelo serviço [-$2]*");
            Roleplay.Misc.RoleplayManager.GiveMoney(Session, -2);
        }
Пример #20
0
        /// <summary>
        ///     Sends the instant message.
        /// </summary>
        /// <param name="toId">To identifier.</param>
        /// <param name="message">The message.</param>
        internal void SendInstantMessage(uint toId, string message)
        {
            BlackWord word;

            if (BlackWordsManager.Check(message, BlackWordType.Hotel, out word))
            {
                BlackWordTypeSettings settings = word.TypeSettings;
                //GetClient().HandlePublicist(word.Word, message, "WHISPER", settings);

                if (settings.ShowMessage)
                {
                    GetClient()
                    .SendModeratorMessage("A mensagem contém a palavra: " + word.Word +
                                          " que não é permitida, você poderá ser banido!");

                    return;
                }
            }

            if (!FriendshipExists(toId))
            {
                DeliverInstantMessageError(6, toId);
                return;
            }

            if (toId == 0) // Staff Chat
            {
                ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ConsoleChatMessageComposer"));

                serverMessage.AppendInteger(0); //userid
                serverMessage.AppendString(GetClient().GetHabbo().UserName + " : " + message);
                serverMessage.AppendInteger(0);

                if (GetClient().GetHabbo().Rank >= Yupi.StaffAlertMinRank)
                {
                    Yupi.GetGame().GetClientManager().StaffAlert(serverMessage, GetClient().GetHabbo().Id);
                }
                else if (GetClient().GetHabbo().Rank >= Convert.ToUInt32(Yupi.GetDbConfig().DbData["ambassador.minrank"]))
                {
                    Yupi.GetGame().GetClientManager().AmbassadorAlert(serverMessage, GetClient().GetHabbo().Id);
                }
            }
            else
            {
                GameClient clientByUserId = Yupi.GetGame().GetClientManager().GetClientByUserId(toId);

                if (clientByUserId?.GetHabbo().GetMessenger() == null)
                {
                    if (!Yupi.OfflineMessages.ContainsKey(toId))
                    {
                        Yupi.OfflineMessages.Add(toId, new List <OfflineMessage>());
                    }

                    Yupi.OfflineMessages[toId].Add(new OfflineMessage(GetClient().GetHabbo().Id, message,
                                                                      Yupi.GetUnixTimeStamp()));

                    OfflineMessage.SaveMessage(Yupi.GetDatabaseManager().GetQueryReactor(), toId,
                                               GetClient().GetHabbo().Id, message);

                    return;
                }

                if (GetClient().GetHabbo().Muted)
                {
                    DeliverInstantMessageError(4, toId);

                    return;
                }

                if (clientByUserId.GetHabbo().Muted)
                {
                    DeliverInstantMessageError(3, toId);
                }

                if (message == string.Empty)
                {
                    return;
                }

                clientByUserId.GetHabbo().GetMessenger().DeliverInstantMessage(message, _userId);
            }
        }
Пример #21
0
        internal void BanzaiEnd()
        {
            IsBanzaiActive = false;
            _room.GetGameManager().StopGame();
            _floorMap = null;
            _room.GetWiredHandler().ExecuteWired(Interaction.TriggerGameEnd);

            Team winningTeam = _room.GetGameManager().GetWinningTeam();

            _room.GetGameManager().UnlockGates();

            foreach (RoomItem roomItem in BanzaiTiles.Values)
            {
                if (roomItem.Team == winningTeam)
                {
                    roomItem.InteractionCount       = 0;
                    roomItem.InteractionCountHelper = 0;
                    roomItem.UpdateNeeded           = true;
                }
                else if (roomItem.Team == Team.None)
                {
                    roomItem.ExtraData = "0";
                    roomItem.UpdateState();
                }
            }

            if (winningTeam == Team.None)
            {
                return;
            }

            foreach (RoomUser avatar in _room.GetRoomUserManager().GetRoomUsers())
            {
                if (avatar.Team != Team.None && Yupi.GetUnixTimeStamp() - _timestarted > 5.0)
                {
                    Yupi.GetGame()
                    .GetAchievementManager()
                    .ProgressUserAchievement(avatar.GetClient(), "ACH_BattleBallTilesLocked",
                                             avatar.LockedTilesCount);
                    Yupi.GetGame()
                    .GetAchievementManager()
                    .ProgressUserAchievement(avatar.GetClient(), "ACH_BattleBallPlayer", 1);
                }

                if ((winningTeam == Team.Red && avatar.CurrentEffect != 33) ||
                    (winningTeam == Team.Green && avatar.CurrentEffect != 34) ||
                    (winningTeam == Team.Blue && avatar.CurrentEffect != 35) ||
                    (winningTeam == Team.Yellow && avatar.CurrentEffect != 36))
                {
                    continue;
                }
                //todo: clean this up not sure yet.

                if (Yupi.GetUnixTimeStamp() - _timestarted > 5.0)
                {
                    Yupi.GetGame()
                    .GetAchievementManager()
                    .ProgressUserAchievement(avatar.GetClient(), "ACH_BattleBallWinner", 1);
                }

                ServerMessage waveAtWin = new ServerMessage(LibraryParser.OutgoingRequest("RoomUserActionMessageComposer"));
                waveAtWin.AppendInteger(avatar.VirtualId);
                waveAtWin.AppendInteger(1);
                _room.SendMessage(waveAtWin);
            }
            _field.Destroy();
        }
Пример #22
0
        /// <summary>
        ///     Handles the purchase.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="pageId">The page identifier.</param>
        /// <param name="itemId">The item identifier.</param>
        /// <param name="extraData">The extra data.</param>
        /// <param name="priceAmount">The price amount.</param>
        /// <param name="isGift">if set to <c>true</c> [is gift].</param>
        /// <param name="giftUser">The gift user.</param>
        /// <param name="giftMessage">The gift message.</param>
        /// <param name="giftSpriteId">The gift sprite identifier.</param>
        /// <param name="giftLazo">The gift lazo.</param>
        /// <param name="giftColor">Color of the gift.</param>
        /// <param name="undef">if set to <c>true</c> [undef].</param>
        /// <param name="theGroup">The theGroup.</param>
        internal void HandlePurchase(GameClient session, uint pageId, uint itemId, string extraData, uint priceAmount,
                                     bool isGift, string giftUser, string giftMessage, int giftSpriteId, int giftLazo, int giftColor, bool undef,
                                     uint theGroup)
        {
            priceAmount = priceAmount < 1 || priceAmount > 100 ? 1 : priceAmount;

            uint totalPrice = priceAmount, limitedId = 0, limtot = 0;

            if (priceAmount >= 6)
            {
                totalPrice -= Convert.ToUInt32(Math.Ceiling(Convert.ToDouble(priceAmount) / 6)) * 2 - 1;
            }

            if (!Categories.Contains(pageId))
            {
                return;
            }

            CatalogPage catalogPage = GetPage(pageId);

            if (catalogPage == null || !catalogPage.Enabled || !catalogPage.Visible || session?.GetHabbo() == null || catalogPage.MinRank > session.GetHabbo().Rank || catalogPage.Layout == "sold_ltd_items")
            {
                return;
            }

            CatalogItem item = catalogPage.GetItem(itemId);

            if (item == null || session.GetHabbo().Credits < item.CreditsCost || session.GetHabbo().Duckets < item.DucketsCost || session.GetHabbo().Diamonds < item.DiamondsCost || item.Name == "room_ad_plus_badge")
            {
                return;
            }

            #region Habbo Club Purchase

            if (catalogPage.Layout == "vip_buy" || catalogPage.Layout == "club_buy" || HabboClubItems.Contains(item))
            {
                string[] array = item.Name.Split('_');

                double dayLength = 31;

                if (item.Name.Contains("DAY"))
                {
                    dayLength = double.Parse(array[3]);
                }
                else if (item.Name.Contains("MONTH"))
                {
                    dayLength = Math.Ceiling(double.Parse(array[3]) * 31 - 0.205);
                }
                else if (item.Name.Contains("YEAR"))
                {
                    dayLength = double.Parse(array[3]) * 31 * 12;
                }

                session.GetHabbo().GetSubscriptionManager().AddSubscription(dayLength);

                if (item.CreditsCost > 0)
                {
                    session.GetHabbo().Credits -= item.CreditsCost * totalPrice;
                    session.GetHabbo().UpdateCreditsBalance();
                }

                if (item.DucketsCost > 0)
                {
                    session.GetHabbo().Duckets -= item.DucketsCost * totalPrice;
                    session.GetHabbo().UpdateActivityPointsBalance();
                }

                if (item.DiamondsCost > 0)
                {
                    session.GetHabbo().Diamonds -= item.DiamondsCost * totalPrice;
                    session.GetHabbo().UpdateSeasonalCurrencyBalance();
                }

                return;
            }

            #endregion

            #region Is Only for Habbo Club users Check

            if (item.ClubOnly && !session.GetHabbo().GetSubscriptionManager().HasSubscription)
            {
                ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("CatalogPurchaseNotAllowedMessageComposer"));
                serverMessage.AppendInteger(1);
                session.SendMessage(serverMessage);
                return;
            }

            #endregion

            #region Limited Items Purchase

            if (item.IsLimited)
            {
                totalPrice  = 1;
                priceAmount = 1;

                if (item.LimitedSelled >= item.LimitedStack)
                {
                    session.SendMessage(new ServerMessage(LibraryParser.OutgoingRequest("CatalogLimitedItemSoldOutMessageComposer")));
                    return;
                }

                item.LimitedSelled++;

                using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    commitableQueryReactor.RunFastQuery(string.Concat("UPDATE catalog_items SET limited_sells = ",
                                                                      item.LimitedSelled, " WHERE id = ", item.Id));

                    limitedId = item.LimitedSelled;
                    limtot    = item.LimitedStack;
                }
            }
            else if (isGift && priceAmount > 1)
            {
                totalPrice  = 1;
                priceAmount = 1;
            }

            #endregion

            uint toUserId = 0u;

            if (session.GetHabbo().Credits < item.CreditsCost * totalPrice || session.GetHabbo().Duckets < item.DucketsCost * totalPrice || session.GetHabbo().Diamonds < item.DiamondsCost * totalPrice)
            {
                return;
            }

            #region Decrease User Balance with Item Cost

            if (!isGift)
            {
                if (item.CreditsCost > 0)
                {
                    session.GetHabbo().Credits -= item.CreditsCost * totalPrice;
                    session.GetHabbo().UpdateCreditsBalance();
                }

                if (item.DucketsCost > 0)
                {
                    session.GetHabbo().Duckets -= item.DucketsCost * totalPrice;
                    session.GetHabbo().UpdateActivityPointsBalance();
                }

                if (item.DiamondsCost > 0)
                {
                    session.GetHabbo().Diamonds -= item.DiamondsCost * totalPrice;
                    session.GetHabbo().UpdateSeasonalCurrencyBalance();
                }
            }

            #endregion

            foreach (Item baseItem in item.Items.Keys)
            {
                #region Stack if Gift

                if (isGift)
                {
                    if ((DateTime.Now - session.GetHabbo().LastGiftPurchaseTime).TotalSeconds <= 15.0)
                    {
                        session.SendNotif(Yupi.GetLanguage().GetVar("user_send_gift"));

                        return;
                    }

                    if (!baseItem.AllowGift)
                    {
                        return;
                    }

                    DataRow row;

                    using (IQueryAdapter queryreactor3 = Yupi.GetDatabaseManager().GetQueryReactor())
                    {
                        queryreactor3.SetQuery("SELECT id FROM users WHERE username = @gift_user");
                        queryreactor3.AddParameter("gift_user", giftUser);
                        row = queryreactor3.GetRow();
                    }

                    if (row == null)
                    {
                        session.GetMessageHandler().GetResponse().Init(LibraryParser.OutgoingRequest("GiftErrorMessageComposer"));
                        session.GetMessageHandler().GetResponse().AppendString(giftUser);
                        session.GetMessageHandler().SendResponse();

                        return;
                    }

                    toUserId = (uint)row["id"];

                    if (toUserId == 0u)
                    {
                        session.GetMessageHandler().GetResponse().Init(LibraryParser.OutgoingRequest("GiftErrorMessageComposer"));
                        session.GetMessageHandler().GetResponse().AppendString(giftUser);
                        session.GetMessageHandler().SendResponse();

                        return;
                    }

                    if (item.CreditsCost > 0)
                    {
                        session.GetHabbo().Credits -= item.CreditsCost * totalPrice;
                        session.GetHabbo().UpdateCreditsBalance();
                    }

                    if (item.DucketsCost > 0)
                    {
                        session.GetHabbo().Duckets -= item.DucketsCost * totalPrice;
                        session.GetHabbo().UpdateActivityPointsBalance();
                    }

                    if (item.DiamondsCost > 0)
                    {
                        session.GetHabbo().Diamonds -= item.DiamondsCost * totalPrice;
                        session.GetHabbo().UpdateSeasonalCurrencyBalance();
                    }

                    if (baseItem.Type == 'e')
                    {
                        session.SendNotif(Yupi.GetLanguage().GetVar("user_send_gift_effect"));

                        return;
                    }
                }

                #endregion

                #region Item is Builders Club Addon

                if (item.Name.StartsWith("builders_club_addon_"))
                {
                    int furniAmount = int.Parse(item.Name.Replace("builders_club_addon_", string.Empty).Replace("furnis", string.Empty));

                    session.GetHabbo().BuildersItemsMax += furniAmount;

                    ServerMessage update = new ServerMessage(LibraryParser.OutgoingRequest("BuildersClubMembershipMessageComposer"));

                    update.AppendInteger(session.GetHabbo().BuildersExpire);
                    update.AppendInteger(session.GetHabbo().BuildersItemsMax);
                    update.AppendInteger(2);
                    session.SendMessage(update);

                    using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                    {
                        commitableQueryReactor.SetQuery("UPDATE users SET builders_items_max = @max WHERE id = @userId");
                        commitableQueryReactor.AddParameter("max", session.GetHabbo().BuildersItemsMax);
                        commitableQueryReactor.AddParameter("userId", session.GetHabbo().Id);
                        commitableQueryReactor.RunQuery();
                    }

                    session.SendMessage(CatalogPageComposer.PurchaseOk(item, item.Items));
                    session.SendNotif("${notification.builders_club.membership_extended.message}", "${notification.builders_club.membership_extended.title}", "builders_club_membership_extended");

                    return;
                }

                #endregion

                #region Item is Builders Club Upgrade

                if (item.Name.StartsWith("builders_club_time_"))
                {
                    int timeAmount = int.Parse(item.Name.Replace("builders_club_time_", string.Empty).Replace("seconds", string.Empty));

                    session.GetHabbo().BuildersExpire += timeAmount;

                    ServerMessage update = new ServerMessage(LibraryParser.OutgoingRequest("BuildersClubMembershipMessageComposer"));

                    update.AppendInteger(session.GetHabbo().BuildersExpire);
                    update.AppendInteger(session.GetHabbo().BuildersItemsMax);
                    update.AppendInteger(2);
                    session.SendMessage(update);

                    using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                    {
                        commitableQueryReactor.SetQuery("UPDATE users SET builders_expire = @max WHERE id = @userId");
                        commitableQueryReactor.AddParameter("max", session.GetHabbo().BuildersExpire);
                        commitableQueryReactor.AddParameter("userId", session.GetHabbo().Id);
                        commitableQueryReactor.RunQuery();
                    }

                    session.SendMessage(CatalogPageComposer.PurchaseOk(item, item.Items));
                    session.SendNotif("${notification.builders_club.membership_extended.message}", "${notification.builders_club.membership_extended.title}", "builders_club_membership_extended");

                    return;
                }

                #endregion

                string text = string.Empty;

                #region Interaction Type Selection

                Interaction interactionType = baseItem.InteractionType;

                switch (interactionType)
                {
                case Interaction.None:
                case Interaction.Gate:
                case Interaction.Bed:
                case Interaction.PressurePadBed:
                case Interaction.Guillotine:
                case Interaction.HcGate:
                case Interaction.ScoreBoard:
                case Interaction.VendingMachine:
                case Interaction.Alert:
                case Interaction.OneWayGate:
                case Interaction.LoveShuffler:
                case Interaction.HabboWheel:
                case Interaction.Dice:
                case Interaction.Bottle:
                case Interaction.Hopper:
                case Interaction.Teleport:
                case Interaction.QuickTeleport:
                case Interaction.Pet:
                case Interaction.Pool:
                case Interaction.Roller:
                    break;

                case Interaction.PostIt:
                    extraData = "FFFF33";
                    break;

                case Interaction.RoomEffect:
                    double number = string.IsNullOrEmpty(extraData) ? 0.0 : double.Parse(extraData, Yupi.CultureInfo);

                    extraData = number.ToString(CultureInfo.InvariantCulture).Replace(',', '.');
                    break;

                case Interaction.Dimmer:
                    extraData = "1,1,1,#000000,255";
                    break;

                case Interaction.Trophy:
                    extraData = string.Concat(session.GetHabbo().UserName, Convert.ToChar(9),
                                              DateTime.Now.Day.ToString("00"), "-", DateTime.Now.Month.ToString("00"), "-",
                                              DateTime.Now.Year, Convert.ToChar(9), extraData);
                    break;

                case Interaction.Rentals:
                    extraData = item.ExtraData;
                    break;

                case Interaction.PetDog:
                case Interaction.PetCat:
                case Interaction.PetCrocodile:
                case Interaction.PetTerrier:
                case Interaction.PetBear:
                case Interaction.PetPig:
                case Interaction.PetLion:
                case Interaction.PetRhino:
                case Interaction.PetSpider:
                case Interaction.PetTurtle:
                case Interaction.PetChick:
                case Interaction.PetFrog:
                case Interaction.PetDragon:
                case Interaction.PetHorse:
                case Interaction.PetMonkey:
                case Interaction.PetGnomo:
                case Interaction.PetMonsterPlant:
                case Interaction.PetWhiteRabbit:
                case Interaction.PetEvilRabbit:
                case Interaction.PetLoveRabbit:
                case Interaction.PetCafeRabbit:
                case Interaction.PetPigeon:
                case Interaction.PetEvilPigeon:
                case Interaction.PetDemonMonkey:
                    string[] data    = extraData.Split('\n');
                    string   petName = data[0];
                    string   race    = data[1];
                    string   color   = data[2];

                    if (!CheckPetName(petName) || (race.Length != 1 && race.Length != 2) || color.Length != 6)
                    {
                        return;
                    }
                    break;

                case Interaction.Mannequin:
                    extraData = string.Concat("m", Convert.ToChar(5), "ch-215-92.lg-3202-1322-73", Convert.ToChar(5), "Mannequin");
                    break;

                case Interaction.VipGate:
                case Interaction.MysteryBox:
                case Interaction.YoutubeTv:
                case Interaction.TileStackMagic:
                case Interaction.Tent:
                case Interaction.BedTent:
                    break;

                case Interaction.BadgeDisplay:
                    if (!session.GetHabbo().GetBadgeComponent().HasBadge(extraData))
                    {
                        extraData = "UMAD";
                    }

                    extraData = $"{extraData}|{session.GetHabbo().UserName}|{DateTime.Now.Day.ToString("00")}-{DateTime.Now.Month.ToString("00")}-{DateTime.Now.Year}";
                    break;

                case Interaction.FootballGate:
                    extraData = "hd-99999-99999.lg-270-62;hd-99999-99999.ch-630-62.lg-695-62";
                    break;

                case Interaction.LoveLock:
                    extraData = "0";
                    break;

                case Interaction.Pinata:
                case Interaction.RunWaySage:
                case Interaction.Shower:
                    extraData = "0";
                    break;

                case Interaction.GroupForumTerminal:
                case Interaction.GuildItem:
                case Interaction.GuildGate:
                case Interaction.GuildForum:
                case Interaction.Poster:
                    break;

                case Interaction.Moplaseed:
                    extraData = new Random().Next(0, 12).ToString();
                    break;

                case Interaction.RareMoplaSeed:
                    extraData = new Random().Next(10, 12).ToString();
                    break;

                case Interaction.MusicDisc:

                    SongData song = SoundMachineSongManager.GetSongById(item.SongId);

                    extraData = string.Empty;

                    if (song == null)
                    {
                        break;
                    }

                    extraData = string.Concat(session.GetHabbo().UserName, '\n', DateTime.Now.Year, '\n',
                                              DateTime.Now.Month, '\n', DateTime.Now.Day, '\n', song.LengthSeconds, '\n', song.Name);

                    text = song.CodeName;

                    break;

                default:
                    extraData = item.ExtraData;
                    break;
                }

                #endregion

                session.GetMessageHandler().GetResponse().Init(LibraryParser.OutgoingRequest("UpdateInventoryMessageComposer"));

                session.GetMessageHandler().SendResponse();

                session.SendMessage(CatalogPageComposer.PurchaseOk(item, item.Items));

                if (isGift)
                {
                    Item itemBySprite = Yupi.GetGame().GetItemManager().GetItemBySpriteId(giftSpriteId);

                    if (itemBySprite == null)
                    {
                        return;
                    }

                    uint insertId;

                    using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                    {
                        commitableQueryReactor.SetQuery("INSERT INTO items_rooms (item_name,user_id) VALUES (" + itemBySprite.Name + ", " + toUserId + ")");

                        insertId = (uint)commitableQueryReactor.InsertQuery();

                        commitableQueryReactor.SetQuery(
                            string.Concat(
                                "INSERT INTO users_gifts (gift_id,item_id,extradata,giver_name,Message,ribbon,color,gift_sprite,show_sender,rare_id) VALUES (",
                                insertId, ", ", baseItem.ItemId, ",@extradata, @name, @Message,", giftLazo, ",",
                                giftColor, ",", giftSpriteId, ",", undef ? 1 : 0, ",", limitedId, ")"));
                        commitableQueryReactor.AddParameter("extradata", extraData);
                        commitableQueryReactor.AddParameter("name", giftUser);
                        commitableQueryReactor.AddParameter("message", giftMessage);
                        commitableQueryReactor.RunQuery();

                        if (session.GetHabbo().Id != toUserId)
                        {
                            Yupi.GetGame()
                            .GetAchievementManager()
                            .ProgressUserAchievement(session, "ACH_GiftGiver", 1, true);

                            commitableQueryReactor.RunFastQuery(
                                "UPDATE users_stats SET gifts_given = gifts_given + 1 WHERE id = " +
                                session.GetHabbo().Id +
                                ";UPDATE users_stats SET gifts_received = gifts_received + 1 WHERE id = " + toUserId);
                        }
                    }

                    GameClient clientByUserId = Yupi.GetGame().GetClientManager().GetClientByUserId(toUserId);

                    if (clientByUserId != null)
                    {
                        clientByUserId.GetHabbo()
                        .GetInventoryComponent()
                        .AddNewItem(insertId, itemBySprite.Name,
                                    string.Concat(session.GetHabbo().Id, (char)9, giftMessage, (char)9, giftLazo, (char)9,
                                                  giftColor, (char)9, undef ? "1" : "0", (char)9, session.GetHabbo().UserName,
                                                  (char)9, session.GetHabbo().Look, (char)9, item.Name), 0u, false, false, 0, 0);

                        if (clientByUserId.GetHabbo().Id != session.GetHabbo().Id)
                        {
                            Yupi.GetGame()
                            .GetAchievementManager()
                            .ProgressUserAchievement(clientByUserId, "ACH_GiftReceiver", 1, true);
                        }
                    }

                    session.GetHabbo().LastGiftPurchaseTime = DateTime.Now;

                    continue;
                }

                session.GetMessageHandler()
                .GetResponse()
                .Init(LibraryParser.OutgoingRequest("NewInventoryObjectMessageComposer"));

                session.GetMessageHandler().GetResponse().AppendInteger(1);

                int i = 1;

                if (baseItem.Type == 's')
                {
                    i = InteractionTypes.AreFamiliar(GlobalInteractions.Pet, baseItem.InteractionType) ? 3 : 1;
                }

                session.GetMessageHandler().GetResponse().AppendInteger(i);

                List <UserItem> list = DeliverItems(session, baseItem, priceAmount * item.Items[baseItem], extraData, limitedId,
                                                    limtot, text);

                session.GetMessageHandler().GetResponse().AppendInteger(list.Count);

                foreach (UserItem current3 in list)
                {
                    session.GetMessageHandler().GetResponse().AppendInteger(current3.Id);
                }

                session.GetMessageHandler().SendResponse();

                session.GetHabbo().GetInventoryComponent().UpdateItems(false);

                if (InteractionTypes.AreFamiliar(GlobalInteractions.Pet, baseItem.InteractionType))
                {
                    session.SendMessage(session.GetHabbo().GetInventoryComponent().SerializePetInventory());
                }
            }

            if (item.Badge.Length >= 1)
            {
                session.GetHabbo().GetBadgeComponent().GiveBadge(item.Badge, true, session);
            }
        }
Пример #23
0
        /// <summary>
        ///     Serializes the search results.
        /// </summary>
        /// <param name="searchQuery">The search query.</param>
        /// <returns>ServerMessage.</returns>
        public static ServerMessage SerializeSearchResults(string searchQuery)
        {
            bool   containsOwner = false;
            bool   containsGroup = false;
            string originalQuery = searchQuery;

            if (searchQuery.StartsWith("owner:"))
            {
                searchQuery   = searchQuery.Replace("owner:", string.Empty);
                containsOwner = true;
            }
            else if (searchQuery.StartsWith("group:"))
            {
                searchQuery   = searchQuery.Replace("group:", string.Empty);
                containsGroup = true;
            }

            List <RoomData> rooms = new List <RoomData>();

            if (!containsOwner)
            {
                bool initForeach = false;

                KeyValuePair <RoomData, uint>[] activeRooms = Yupi.GetGame().GetRoomManager().GetActiveRooms();
                try
                {
                    if (activeRooms != null && activeRooms.Any())
                    {
                        initForeach = true;
                    }
                }
                catch
                {
                    initForeach = false;
                }

                if (initForeach)
                {
                    foreach (KeyValuePair <RoomData, uint> rms in activeRooms)
                    {
                        if (rms.Key.Name.ToLower().Contains(searchQuery.ToLower()) && rooms.Count <= 50)
                        {
                            rooms.Add(rms.Key);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }

            if (rooms.Count < 50 || containsOwner || containsGroup)
            {
                DataTable dTable;

                using (IQueryAdapter dbClient = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    if (containsOwner)
                    {
                        dbClient.SetQuery(
                            "SELECT rooms_data.* FROM rooms_data LEFT OUTER JOIN users ON rooms_data.owner = users.id WHERE users.username = @query AND rooms_data.roomtype = 'private' LIMIT 50");
                        dbClient.AddParameter("query", searchQuery);
                        dTable = dbClient.GetTable();
                    }
                    else if (containsGroup)
                    {
                        dbClient.SetQuery(
                            "SELECT * FROM rooms_data JOIN groups_data ON rooms_data.id = groups_data.room_id WHERE groups_data.group_name LIKE @query AND roomtype = 'private' LIMIT 50");
                        dbClient.AddParameter("query", "%" + searchQuery + "%");
                        dTable = dbClient.GetTable();
                    }
                    else
                    {
                        dbClient.SetQuery(
                            "SELECT * FROM rooms_data WHERE caption = @query AND roomtype = 'private' LIMIT " +
                            (50 - rooms.Count));
                        dbClient.AddParameter("query", searchQuery);
                        dTable = dbClient.GetTable();
                    }
                }

                if (dTable != null)
                {
                    foreach (RoomData rData in dTable.Rows.Cast <DataRow>().Select(row => Yupi.GetGame()
                                                                                   .GetRoomManager()
                                                                                   .FetchRoomData(Convert.ToUInt32(row["id"]), row)).Where(rData => !rooms.Contains(rData)))
                    {
                        rooms.Add(rData);
                    }
                }
            }

            ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("NavigatorListingsMessageComposer"));

            message.AppendInteger(8);
            message.AppendString(originalQuery);
            message.AppendInteger(rooms.Count);

            foreach (RoomData room in rooms)
            {
                room.Serialize(message);
            }

            message.AppendBool(false);

            return(message);
        }
Пример #24
0
        /// <summary>
        /// Adds the experience.
        /// </summary>
        /// <param name="amount">The amount.</param>
        internal void AddExperience(int amount)
        {
            {
                var oldExperienceGoal = ExperienceGoal;
                Experience += amount;
                if (Experience >= 51900)
                {
                    return;
                }
                if (DbState != DatabaseUpdateState.NeedsInsert)
                {
                    DbState = DatabaseUpdateState.NeedsUpdate;
                }
                if (Room == null)
                {
                    return;
                }
                var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("AddPetExperienceMessageComposer"));
                serverMessage.AppendInteger(PetId);
                serverMessage.AppendInteger(VirtualId);
                serverMessage.AppendInteger(amount);
                Room.SendMessage(serverMessage);
                if (Experience < oldExperienceGoal)
                {
                    return;
                }
                var ownerSession = Plus.GetGame().GetClientManager().GetClientByUserId(OwnerId);

                // Reset pet commands
                PetCommands.Clear();
                PetCommands = PetCommandHandler.GetPetCommands(this);

                if (ownerSession == null)
                {
                    return;
                }
                //Console.WriteLine("new level notified##############");
                var levelNotify = new ServerMessage(LibraryParser.OutgoingRequest("NotifyNewPetLevelMessageComposer"));
                SerializeInventory(levelNotify, true);
                ownerSession.SendMessage(levelNotify);

                var tp = new ServerMessage();
                tp.Init(LibraryParser.OutgoingRequest("PetTrainerPanelMessageComposer"));
                tp.AppendInteger(PetId);

                var availableCommands = new List <short>();

                tp.AppendInteger(PetCommands.Count);
                foreach (short sh in PetCommands.Keys)
                {
                    tp.AppendInteger(sh);
                    if (PetCommands[sh])
                    {
                        availableCommands.Add(sh);
                    }
                }

                tp.AppendInteger(availableCommands.Count);
                foreach (short sh in availableCommands)
                {
                    tp.AppendInteger(sh);
                }
                ownerSession.SendMessage(tp);
            }
        }
Пример #25
0
        /// <summary>
        ///     Serializes the popular room tags.
        /// </summary>
        /// <returns>ServerMessage.</returns>
        internal ServerMessage SerializePopularRoomTags()
        {
            Dictionary <string, int> dictionary = new Dictionary <string, int>();

            ServerMessage result;

            using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                commitableQueryReactor.SetQuery(
                    "SELECT tags, users_now FROM rooms_data WHERE roomtype = 'private' AND users_now > 0 ORDER BY users_now DESC LIMIT 50");

                DataTable table = commitableQueryReactor.GetTable();

                if (table != null)
                {
                    foreach (DataRow dataRow in table.Rows)
                    {
                        int usersNow;

                        if (!string.IsNullOrEmpty(dataRow["users_now"].ToString()))
                        {
                            usersNow = (int)dataRow["users_now"];
                        }
                        else
                        {
                            usersNow = 0;
                        }

                        string[]      array = dataRow["tags"].ToString().Split(',');
                        List <string> list  = array.ToList();

                        foreach (string current in list)
                        {
                            if (dictionary.ContainsKey(current))
                            {
                                dictionary[current] += usersNow;
                            }
                            else
                            {
                                dictionary.Add(current, usersNow);
                            }
                        }
                    }
                }

                List <KeyValuePair <string, int> > list2 = new List <KeyValuePair <string, int> >(dictionary);

                list2.Sort((firstPair, nextPair) => firstPair.Value.CompareTo(nextPair.Value));

                ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("PopularRoomTagsMessageComposer"));
                serverMessage.AppendInteger(list2.Count);

                foreach (KeyValuePair <string, int> current2 in list2)
                {
                    serverMessage.AppendString(current2.Key);
                    serverMessage.AppendInteger(current2.Value);
                }

                result = serverMessage;
            }

            return(result);
        }
Пример #26
0
        /// <summary>
        /// Serializes the information.
        /// </summary>
        /// <returns>ServerMessage.</returns>
        internal ServerMessage SerializeInfo()
        {
            var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("PetInfoMessageComposer"));

            serverMessage.AppendInteger(PetId);
            serverMessage.AppendString(Name);
            if (Type == 16)
            {
                serverMessage.AppendInteger(MoplaBreed.GrowingStatus);
                serverMessage.AppendInteger(7);
            }
            else
            {
                serverMessage.AppendInteger(Level);
                serverMessage.AppendInteger(MaxLevel);
            }
            serverMessage.AppendInteger(Experience);
            serverMessage.AppendInteger(ExperienceGoal);
            serverMessage.AppendInteger(Energy);
            serverMessage.AppendInteger(MaxEnergy);
            serverMessage.AppendInteger(Nutrition);
            serverMessage.AppendInteger(MaxNutrition);
            serverMessage.AppendInteger(Respect);
            serverMessage.AppendInteger(OwnerId);
            serverMessage.AppendInteger(Age);
            serverMessage.AppendString(OwnerName);
            serverMessage.AppendInteger(Type == 16 ? 0 : 1);
            serverMessage.AppendBool(HaveSaddle);
            serverMessage.AppendBool(false); //mountingId
            serverMessage.AppendInteger(0);
            serverMessage.AppendInteger(AnyoneCanRide);
            if (Type == 16)
            {
                serverMessage.AppendBool(MoplaBreed.LiveState == MoplaState.Grown);
            }
            else
            {
                serverMessage.AppendBool(false);
            }
            serverMessage.AppendBool(false);
            if (Type == 16)
            {
                serverMessage.AppendBool(MoplaBreed.LiveState == MoplaState.Dead);
            }
            else
            {
                serverMessage.AppendBool(false);
            }
            serverMessage.AppendInteger(Rarity);
            if (Type == 16u)
            {
                serverMessage.AppendInteger(129600);
                var lastHealthSeconds = (int)(LastHealth - DateTime.Now).TotalSeconds;
                var untilGrownSeconds = (int)(UntilGrown - DateTime.Now).TotalSeconds;

                if (lastHealthSeconds < 0)
                {
                    lastHealthSeconds = 0;
                }
                if (untilGrownSeconds < 0)
                {
                    untilGrownSeconds = 0;
                }

                switch (MoplaBreed.LiveState)
                {
                case MoplaState.Dead:
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(0);
                    break;

                case MoplaState.Grown:
                    serverMessage.AppendInteger(lastHealthSeconds);
                    serverMessage.AppendInteger(0);
                    break;

                default:
                    serverMessage.AppendInteger(lastHealthSeconds);
                    serverMessage.AppendInteger(untilGrownSeconds);
                    break;
                }
            }
            else
            {
                serverMessage.AppendInteger(-1);
                serverMessage.AppendInteger(-1);
                serverMessage.AppendInteger(-1);
            }

            serverMessage.AppendBool(true); // Allow breed?
            return(serverMessage);
        }
Пример #27
0
        /// <summary>
        /// Delivers the items.
        /// </summary>
        internal void DeliverItems()
        {
            List <UserItem> offeredItems  = this.GetTradeUser(this._oneId).OfferedItems;
            List <UserItem> offeredItems2 = this.GetTradeUser(this._twoId).OfferedItems;

            if (
                offeredItems.Any(
                    current =>
                    this.GetTradeUser(this._oneId).GetClient().GetHabbo().GetInventoryComponent().GetItem(current.Id) == null))
            {
                this.GetTradeUser(this._oneId).GetClient().SendNotif("El tradeo ha fallado.");
                this.GetTradeUser(this._twoId).GetClient().SendNotif("El tradeo ha fallado.");
                return;
            }
            if (
                offeredItems2.Any(
                    current2 =>
                    this.GetTradeUser(this._twoId).GetClient().GetHabbo().GetInventoryComponent().GetItem(current2.Id) == null))
            {
                this.GetTradeUser(this._oneId).GetClient().SendNotif("El tradeo ha fallado.");
                this.GetTradeUser(this._twoId).GetClient().SendNotif("El tradeo ha fallado.");
                return;
            }
            this.GetTradeUser(this._twoId).GetClient().GetHabbo().GetInventoryComponent().RunDbUpdate();
            this.GetTradeUser(this._oneId).GetClient().GetHabbo().GetInventoryComponent().RunDbUpdate();
            foreach (UserItem current3 in offeredItems)
            {
                this.GetTradeUser(this._oneId).GetClient().GetHabbo().GetInventoryComponent().RemoveItem(current3.Id, false);
                this.GetTradeUser(this._twoId)
                .GetClient()
                .GetHabbo()
                .GetInventoryComponent()
                .AddNewItem(current3.Id, current3.BaseItemId, current3.ExtraData, current3.GroupId, false, false, 0, 0,
                            current3.SongCode);
                this.GetTradeUser(this._oneId).GetClient().GetHabbo().GetInventoryComponent().RunDbUpdate();
                this.GetTradeUser(this._twoId).GetClient().GetHabbo().GetInventoryComponent().RunDbUpdate();
            }
            foreach (UserItem current4 in offeredItems2)
            {
                this.GetTradeUser(this._twoId).GetClient().GetHabbo().GetInventoryComponent().RemoveItem(current4.Id, false);
                this.GetTradeUser(this._oneId)
                .GetClient()
                .GetHabbo()
                .GetInventoryComponent()
                .AddNewItem(current4.Id, current4.BaseItemId, current4.ExtraData, current4.GroupId, false, false, 0, 0,
                            current4.SongCode);
                this.GetTradeUser(this._twoId).GetClient().GetHabbo().GetInventoryComponent().RunDbUpdate();
                this.GetTradeUser(this._oneId).GetClient().GetHabbo().GetInventoryComponent().RunDbUpdate();
            }
            var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("NewInventoryObjectMessageComposer"));

            serverMessage.AppendInteger(1);
            int i = 1;

            if (offeredItems.Any(current5 => current5.BaseItem.Type.ToString().ToLower() != "s"))
            {
                i = 2;
            }
            serverMessage.AppendInteger(i);
            serverMessage.AppendInteger(offeredItems.Count);
            foreach (UserItem current6 in offeredItems)
            {
                serverMessage.AppendInteger(current6.Id);
            }
            this.GetTradeUser(this._twoId).GetClient().SendMessage(serverMessage);
            var serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("NewInventoryObjectMessageComposer"));

            serverMessage2.AppendInteger(1);
            i = 1;
            if (offeredItems2.Any(current7 => current7.BaseItem.Type.ToString().ToLower() != "s"))
            {
                i = 2;
            }
            serverMessage2.AppendInteger(i);
            serverMessage2.AppendInteger(offeredItems2.Count);
            foreach (UserItem current8 in offeredItems2)
            {
                serverMessage2.AppendInteger(current8.Id);
            }
            this.GetTradeUser(this._oneId).GetClient().SendMessage(serverMessage2);
            this.GetTradeUser(this._oneId).GetClient().GetHabbo().GetInventoryComponent().UpdateItems(false);
            this.GetTradeUser(this._twoId).GetClient().GetHabbo().GetInventoryComponent().UpdateItems(false);
        }
Пример #28
0
        /// <summary>
        /// Enables the new navigator.
        /// </summary>
        /// <param name="session">The session.</param>
        internal void EnableNewNavigator(GameClient session)
        {
            var navigatorMetaDataParser = new ServerMessage(LibraryParser.OutgoingRequest("NavigatorMetaDataComposer"));

            navigatorMetaDataParser.AppendInteger(4);
            navigatorMetaDataParser.AppendString("official_view");
            navigatorMetaDataParser.AppendInteger(0);
            navigatorMetaDataParser.AppendString("hotel_view");
            navigatorMetaDataParser.AppendInteger(0);
            navigatorMetaDataParser.AppendString("roomads_view");
            navigatorMetaDataParser.AppendInteger(0);
            navigatorMetaDataParser.AppendString("myworld_view");
            navigatorMetaDataParser.AppendInteger(0);
            session.SendMessage(navigatorMetaDataParser);

            var navigatorLiftedRoomsParser =
                new ServerMessage(LibraryParser.OutgoingRequest("NavigatorLiftedRoomsComposer"));

            navigatorLiftedRoomsParser.AppendInteger(_navigatorHeaders.Count);
            foreach (var navHeader in _navigatorHeaders)
            {
                navigatorLiftedRoomsParser.AppendInteger(navHeader.RoomId);
                navigatorLiftedRoomsParser.AppendInteger(0);
                navigatorLiftedRoomsParser.AppendString(navHeader.Image);
                navigatorLiftedRoomsParser.AppendString(navHeader.Caption);
            }
            session.SendMessage(navigatorLiftedRoomsParser);


            var collapsedCategoriesMessageParser = new ServerMessage(LibraryParser.OutgoingRequest("NavigatorCategorys"));

            collapsedCategoriesMessageParser.AppendInteger(FlatCatsCount + 5);
            foreach (FlatCat flat in PrivateCategories.Values)
            {
                collapsedCategoriesMessageParser.AppendString(string.Format("category__{0}", flat.Caption));
            }
            collapsedCategoriesMessageParser.AppendString("recommended");
            collapsedCategoriesMessageParser.AppendString("popular");
            collapsedCategoriesMessageParser.AppendString("new_ads");
            collapsedCategoriesMessageParser.AppendString("staffpicks");
            collapsedCategoriesMessageParser.AppendString("official");
            session.SendMessage(collapsedCategoriesMessageParser);

            var searches = new ServerMessage(LibraryParser.OutgoingRequest("NavigatorSavedSearchesComposer"));

            searches.AppendInteger(session.GetHabbo().NavigatorLogs.Count);
            foreach (var navi in session.GetHabbo().NavigatorLogs.Values)
            {
                searches.AppendInteger(navi.Id);
                searches.AppendString(navi.Value1);
                searches.AppendString(navi.Value2);
                searches.AppendString("");
            }
            session.SendMessage(searches);
            //session.SendMessage(SerlializeNewNavigator("official", "", session));

            var packetName = new ServerMessage(LibraryParser.OutgoingRequest("NewNavigatorSizeMessageComposer"));
            var pref       = session.GetHabbo().Preferences;

            packetName.AppendInteger(pref.NewnaviX);
            packetName.AppendInteger(pref.NewnaviY);
            packetName.AppendInteger(pref.NewnaviWidth);
            packetName.AppendInteger(pref.NewnaviHeight);
            packetName.AppendBool(true);
            packetName.AppendInteger(1);

            session.SendMessage(packetName);
        }
Пример #29
0
        /// <summary>
        ///     Serializes the tool.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <returns>ServerMessage.</returns>
        internal ServerMessage SerializeTool(GameClient session)
        {
            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("LoadModerationToolMessageComposer"));

            serverMessage.AppendInteger(Tickets.Count);

            foreach (SupportTicket current in Tickets)
            {
                current.Serialize(serverMessage);
            }

            serverMessage.AppendInteger(UserMessagePresets.Count);

            foreach (string current2 in UserMessagePresets)
            {
                serverMessage.AppendString(current2);
            }

            IEnumerable <ModerationTemplate> enumerable =
                (from x in ModerationTemplates.Values where x.Category == -1 select x).ToArray();

            serverMessage.AppendInteger(enumerable.Count());
            using (IEnumerator <ModerationTemplate> enumerator3 = enumerable.GetEnumerator())
            {
                bool first = true;

                while (enumerator3.MoveNext())
                {
                    ModerationTemplate template = enumerator3.Current;
                    IEnumerable <ModerationTemplate> enumerable2 =
                        (from x in ModerationTemplates.Values where x.Category == (long)(ulong)template.Id select x)
                        .ToArray();
                    serverMessage.AppendString(template.CName);
                    serverMessage.AppendBool(first);
                    serverMessage.AppendInteger(enumerable2.Count());

                    foreach (ModerationTemplate current3 in enumerable2)
                    {
                        serverMessage.AppendString(current3.Caption);
                        serverMessage.AppendString(current3.BanMessage);
                        serverMessage.AppendInteger(current3.BanHours);
                        serverMessage.AppendInteger(Yupi.BoolToInteger(current3.AvatarBan));
                        serverMessage.AppendInteger(Yupi.BoolToInteger(current3.Mute));
                        serverMessage.AppendInteger(Yupi.BoolToInteger(current3.TradeLock));
                        serverMessage.AppendString(current3.WarningMessage);
                        serverMessage.AppendBool(true);
                    }

                    first = false;
                }
            }

            // but = button
            serverMessage.AppendBool(true);                                        //ticket_queue_but
            serverMessage.AppendBool(session.GetHabbo().HasFuse("fuse_chatlogs")); //chatlog_but
            serverMessage.AppendBool(session.GetHabbo().HasFuse("fuse_alert"));    //message_but
            serverMessage.AppendBool(true);                                        //modaction_but
            serverMessage.AppendBool(session.GetHabbo().HasFuse("fuse_ban"));      //ban_but
            serverMessage.AppendBool(true);
            serverMessage.AppendBool(session.GetHabbo().HasFuse("fuse_kick"));     //kick_but

            serverMessage.AppendInteger(RoomMessagePresets.Count);

            foreach (string current4 in RoomMessagePresets)
            {
                serverMessage.AppendString(current4);
            }

            return(serverMessage);
        }
Пример #30
0
Файл: Pet.cs Проект: sgf/Yupi
        /// <summary>
        ///     Adds the experience.
        /// </summary>
        /// <param name="amount">The amount.</param>
        internal void AddExperience(int amount)
        {
            int oldExperienceGoal = ExperienceGoal;

            Experience += amount;

            if (Experience >= 51900)
            {
                return;
            }

            if (DbState != DatabaseUpdateState.NeedsInsert)
            {
                DbState = DatabaseUpdateState.NeedsUpdate;
            }

            if (Room == null)
            {
                return;
            }

            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("AddPetExperienceMessageComposer"));

            serverMessage.AppendInteger(PetId);
            serverMessage.AppendInteger(VirtualId);
            serverMessage.AppendInteger(amount);
            Room.SendMessage(serverMessage);

            if (Experience < oldExperienceGoal)
            {
                return;
            }

            GameClient ownerSession = Yupi.GetGame().GetClientManager().GetClientByUserId(OwnerId);

            Dictionary <uint, PetCommand> totalPetCommands = PetCommandHandler.GetAllPetCommands();

            Dictionary <uint, PetCommand> petCommands = PetCommandHandler.GetPetCommandByPetType(Type);

            if (ownerSession == null)
            {
                return;
            }

            ServerMessage levelNotify = new ServerMessage(LibraryParser.OutgoingRequest("NotifyNewPetLevelMessageComposer"));

            SerializeInventory(levelNotify, true);

            ownerSession.SendMessage(levelNotify);

            ServerMessage tp = new ServerMessage();

            tp.Init(LibraryParser.OutgoingRequest("PetTrainerPanelMessageComposer"));

            tp.AppendInteger(PetId);

            tp.AppendInteger(totalPetCommands.Count);

            foreach (uint sh in totalPetCommands.Keys)
            {
                tp.AppendInteger(sh);
            }

            tp.AppendInteger(petCommands.Count);

            foreach (uint sh in petCommands.Keys)
            {
                tp.AppendInteger(sh);
            }

            ownerSession.SendMessage(tp);
        }