コード例 #1
0
ファイル: QuestListComposer.cs プロジェクト: BjkGkh/Mercury
		internal static void SerializeQuest(ServerMessage Message, GameClient Session, Quest Quest, string Category)
		{
			if (Message == null || Session == null)
			{
				return;
			}
			int amountOfQuestsInCategory = MercuryEnvironment.GetGame().GetQuestManager().GetAmountOfQuestsInCategory(Category);
			checked
			{
				int num = (Quest == null) ? amountOfQuestsInCategory : (Quest.Number - 1);
				int num2 = (Quest == null) ? 0 : Session.GetHabbo().GetQuestProgress(Quest.Id);
				if (Quest != null && Quest.IsCompleted(num2))
				{
					num++;
				}
				Message.AppendString(Category);
				Message.AppendInt32((Quest == null) ? 0 : (Quest.Category.Contains("xmas2012") ? 0 : num));
				Message.AppendInt32((Quest == null) ? 0 : (Quest.Category.Contains("xmas2012") ? 0 : amountOfQuestsInCategory));
				Message.AppendInt32((Quest == null) ? 3 : Quest.RewardType);
				Message.AppendUInt((Quest == null) ? 0u : Quest.Id);
				Message.AppendBoolean(Quest != null && Session.GetHabbo().CurrentQuestId == Quest.Id);
				Message.AppendString((Quest == null) ? string.Empty : Quest.ActionName);
				Message.AppendString((Quest == null) ? string.Empty : Quest.DataBit);
				Message.AppendInt32((Quest == null) ? 0 : Quest.Reward);
				Message.AppendString((Quest == null) ? string.Empty : Quest.Name);
				Message.AppendInt32(num2);
				Message.AppendUInt((Quest == null) ? 0u : Quest.GoalData);
				Message.AppendInt32((Quest == null) ? 0 : Quest.TimeUnlock);
				Message.AppendString("");
				Message.AppendString("");
				Message.AppendBoolean(true);
			}
		}
コード例 #2
0
		internal static ServerMessage Compose(GameClient Session, Quest Quest)
		{
			int amountOfQuestsInCategory = MercuryEnvironment.GetGame().GetQuestManager().GetAmountOfQuestsInCategory(Quest.Category);
			int i = (Quest == null) ? amountOfQuestsInCategory : Quest.Number;
			int i2 = (Quest == null) ? 0 : Session.GetHabbo().GetQuestProgress(Quest.Id);
			ServerMessage serverMessage = new ServerMessage(Outgoing.QuestCompletedMessageComposer);
			serverMessage.AppendString(Quest.Category);
			serverMessage.AppendInt32(i);
			serverMessage.AppendInt32(Quest.Name.Contains("xmas2012") ? 1 : amountOfQuestsInCategory);
			serverMessage.AppendInt32((Quest == null) ? 3 : Quest.RewardType);
			serverMessage.AppendUInt((Quest == null) ? 0u : Quest.Id);
			serverMessage.AppendBoolean(Quest != null && Session.GetHabbo().CurrentQuestId == Quest.Id);
			serverMessage.AppendString((Quest == null) ? string.Empty : Quest.ActionName);
			serverMessage.AppendString((Quest == null) ? string.Empty : Quest.DataBit);
			serverMessage.AppendInt32((Quest == null) ? 0 : Quest.Reward);
			serverMessage.AppendString((Quest == null) ? string.Empty : Quest.Name);
			serverMessage.AppendInt32(i2);
			serverMessage.AppendUInt((Quest == null) ? 0u : Quest.GoalData);
			serverMessage.AppendInt32((Quest == null) ? 0 : Quest.TimeUnlock);
			serverMessage.AppendString("");
			serverMessage.AppendString("");
			serverMessage.AppendBoolean(true);
			serverMessage.AppendBoolean(true);
			return serverMessage;
		}
コード例 #3
0
ファイル: AchievementManager.cs プロジェクト: BjkGkh/Mercury
        internal void TryProgressRegistrationAchievements(GameClient Session)
        {
            if (Session.GetHabbo() == null)
            {
                return;
            }
            UserAchievement regACH = Session.GetHabbo().GetAchievementData("ACH_RegistrationDuration");
            if (regACH == null)
            {
                ProgressUserAchievement(Session, "ACH_RegistrationDuration", 1, true);
                return;
            }
            else if (regACH.Level == 5)
            {
                return;//Already Completed!
            }
            int sinceMember = MercuryEnvironment.GetUnixTimestamp() - (int)Session.GetHabbo().CreateDate;
            int daysSinceMember = Convert.ToInt32(Math.Round((double)259200 / 86400));

            if (daysSinceMember == regACH.Progress)
            {
                return;
            }
            int dais = daysSinceMember - regACH.Progress;
            if (dais < 1)
                return;

            ProgressUserAchievement(Session, "ACH_RegistrationDuration", dais, false);

        }
コード例 #4
0
ファイル: InteractorHopper.cs プロジェクト: BjkGkh/Mercury
		public void OnTrigger(GameClient Session, RoomItem Item, int Request, bool HasRights)
		{
			if (Item == null || Item.GetRoom() == null || Session == null || Session.GetHabbo() == null)
			{
				return;
			}
			RoomUser roomUserByHabbo = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
			if (roomUserByHabbo == null)
			{
				return;
			}
			if (!(roomUserByHabbo.Coordinate == Item.Coordinate) && !(roomUserByHabbo.Coordinate == Item.SquareInFront))
			{
				if (roomUserByHabbo.CanWalk)
				{
					roomUserByHabbo.MoveTo(Item.SquareInFront);
				}
				return;
			}
			if (Item.InteractingUser != 0u)
			{
				return;
			}
			roomUserByHabbo.TeleDelay = 2;
			Item.InteractingUser = roomUserByHabbo.GetClient().GetHabbo().Id;
		}
コード例 #5
0
ファイル: MessengerBuddy.cs プロジェクト: BjkGkh/Mercury
		internal void UpdateUser(GameClient client)
		{
			this.client = client;
			if (client != null && client.GetHabbo() != null)
			{
				this.currentRoom = client.GetHabbo().CurrentRoom;
			}
		}
コード例 #6
0
ファイル: TalentManager.cs プロジェクト: BjkGkh/Mercury
		internal bool LevelIsCompleted(GameClient Session, string TrackType, int TalentLevel)
		{
			foreach (Talent current in this.GetTalents(TrackType, TalentLevel))
			{
				if (Session.GetHabbo().GetAchievementData(current.AchievementGroup) != null && Session.GetHabbo().GetAchievementData(current.AchievementGroup).Level >= current.AchievementLevel)
				{
					return false;
				}
			}
			return true;
		}
コード例 #7
0
 public void OnTrigger(GameClient Session, RoomItem Item, int Request, bool HasRights)
 {
     if (Session == null || Session.GetHabbo() == null || Item.InteractingUser > 0U)
         return;
     string pName = Session.GetHabbo().Username;
     RoomUser roomUserByHabbo = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(pName);
     roomUserByHabbo.GoalX = Item.GetX;
     roomUserByHabbo.GoalY = Item.GetY;
     if (roomUserByHabbo.team != Team.none)
         roomUserByHabbo.throwBallAtGoal = true;
 }
コード例 #8
0
ファイル: QuestListComposer.cs プロジェクト: BjkGkh/Mercury
		internal static ServerMessage Compose(GameClient Session, List<Quest> Quests, bool Send)
		{
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			Dictionary<string, Quest> dictionary2 = new Dictionary<string, Quest>();
			foreach (Quest current in Quests)
			{
				if (!current.Category.Contains("xmas2012"))
				{
					if (!dictionary.ContainsKey(current.Category))
					{
						dictionary.Add(current.Category, 1);
						dictionary2.Add(current.Category, null);
					}
					if (current.Number >= dictionary[current.Category])
					{
						int questProgress = Session.GetHabbo().GetQuestProgress(current.Id);
						if (Session.GetHabbo().CurrentQuestId != current.Id && (long)questProgress >= (long)((ulong)current.GoalData))
						{
							dictionary[current.Category] = checked(current.Number + 1);
						}
					}
				}
			}
			foreach (Quest current2 in Quests)
			{
				foreach (KeyValuePair<string, int> current3 in dictionary)
				{
					if (!current2.Category.Contains("xmas2012") && current2.Category == current3.Key && current2.Number == current3.Value)
					{
						dictionary2[current3.Key] = current2;
						break;
					}
				}
			}
			ServerMessage serverMessage = new ServerMessage(Outgoing.QuestListMessageComposer);
			serverMessage.AppendInt32(dictionary2.Count);
			foreach (KeyValuePair<string, Quest> current4 in dictionary2)
			{
				if (current4.Value != null)
				{
					QuestListComposer.SerializeQuest(serverMessage, Session, current4.Value, current4.Key);
				}
			}
			foreach (KeyValuePair<string, Quest> current5 in dictionary2)
			{
				if (current5.Value == null)
				{
					QuestListComposer.SerializeQuest(serverMessage, Session, current5.Value, current5.Key);
				}
			}
			serverMessage.AppendBoolean(Send);
			return serverMessage;
		}
コード例 #9
0
ファイル: CreditManager.cs プロジェクト: BjkGkh/Mercury
		internal static void GiveCredits(GameClient Client, int amount)
		{
			if (Client == null || Client.GetHabbo() == null)
			{
				return;
			}
			double arg_12_0 = (double)MercuryEnvironment.GetUnixTimestamp();
			checked
			{
				Client.GetHabbo().Credits += amount;
				Client.GetHabbo().UpdateCreditsBalance();
			}
		}
コード例 #10
0
ファイル: InteractorDice.cs プロジェクト: BjkGkh/Mercury
		public void OnTrigger(GameClient Session, RoomItem Item, int Request, bool HasRights)
		{
			RoomUser roomUser = null;
			if (Session != null)
			{
				roomUser = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
			}
			if (roomUser == null)
			{
				return;
			}
			if (Gamemap.TilesTouching(Item.GetX, Item.GetY, roomUser.X, roomUser.Y))
			{
				if (Item.ExtraData != "-1")
				{
					if (Request == -1)
					{
						Item.ExtraData = "0";
						Item.UpdateState();
						return;
					}
					Item.ExtraData = "-1";
					Item.UpdateState(false, true);
					Item.ReqUpdate(4, true);
					return;
				}
			}
			else
			{
				roomUser.MoveTo(Item.SquareInFront);
			}
		}
コード例 #11
0
ファイル: AchievementManager.cs プロジェクト: BjkGkh/Mercury
        internal void TryProgressLoginAchievements(GameClient Session)
        {
            if (Session.GetHabbo() == null)
            {
                return;
            }
            UserAchievement loginACH = Session.GetHabbo().GetAchievementData("ACH_Login");
            if (loginACH == null)
            {
                ProgressUserAchievement(Session, "ACH_Login", 1, true);
                return;
            }

            int daysBtwLastLogin = MercuryEnvironment.GetUnixTimestamp() - Session.GetHabbo().PreviousOnline;
            if (daysBtwLastLogin >= 51840 && daysBtwLastLogin <= 112320)
            {
                ProgressUserAchievement(Session, "ACH_Login", 1, true);
            }
        }
コード例 #12
0
		public void OnTrigger(GameClient Session, RoomItem Item, int Request, bool HasRights)
		{
			if (Session == null)
			{
				return;
			}
			RoomUser roomUserByHabbo = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
			if (Item.InteractingUser2 != roomUserByHabbo.UserID)
			{
				Item.InteractingUser2 = roomUserByHabbo.UserID;
			}
			if (roomUserByHabbo == null)
			{
				return;
			}
			if (roomUserByHabbo.Coordinate != Item.SquareInFront && roomUserByHabbo.CanWalk)
			{
				roomUserByHabbo.MoveTo(Item.SquareInFront);
				return;
			}
			if (!Item.GetRoom().GetGameMap().ValidTile(Item.SquareBehind.X, Item.SquareBehind.Y) || !Item.GetRoom().GetGameMap().CanWalk(Item.SquareBehind.X, Item.SquareBehind.Y, false, 0u) || !Item.GetRoom().GetGameMap().SquareIsOpen(Item.SquareBehind.X, Item.SquareBehind.Y, false))
			{
				return;
			}
			checked
			{
				if (roomUserByHabbo.LastInteraction - MercuryEnvironment.GetUnixTimestamp() < 0 && roomUserByHabbo.InteractingGate && roomUserByHabbo.GateId == Item.Id)
				{
					roomUserByHabbo.InteractingGate = false;
					roomUserByHabbo.GateId = 0u;
				}
				{
					if (!Item.GetRoom().GetGameMap().CanWalk(Item.SquareBehind.X, Item.SquareBehind.Y, roomUserByHabbo.AllowOverride, 0u))
					{
						return;
					}
					if (Item.InteractingUser == 0u)
					{
						roomUserByHabbo.InteractingGate = true;
						roomUserByHabbo.GateId = Item.Id;
						Item.InteractingUser = roomUserByHabbo.HabboId;
						roomUserByHabbo.CanWalk = false;
						if (roomUserByHabbo.IsWalking && (roomUserByHabbo.GoalX != Item.SquareInFront.X || roomUserByHabbo.GoalY != Item.SquareInFront.Y))
						{
							roomUserByHabbo.ClearMovement(true);
						}

						roomUserByHabbo.InteractingGate = false;
						roomUserByHabbo.GateId = 0u;
						return;
					}
					return;
				}
			}
		}
コード例 #13
0
ファイル: GroupManager.cs プロジェクト: BjkGkh/Mercury
		internal void CreateGroup(string Name, string Desc, uint RoomId, string Badge, GameClient Session, int Colour1, int Colour2, out Guild Group)
		{
			using (IQueryAdapter queryreactor = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
			{
				queryreactor.setQuery(string.Concat(new object[]
				{
					"INSERT INTO groups (`name`, `desc`,`badge`,`owner_id`,`created`,`room_id`,`colour1`,`colour2`) VALUES(@name, @desc, @badge, ",
					Session.GetHabbo().Id,
					", UNIX_TIMESTAMP(), ",
					RoomId,
					",'",
					Colour1,
					"','",
					Colour2,
					"')"
				}));
				queryreactor.addParameter("name", Name);
				queryreactor.addParameter("desc", Desc);
				queryreactor.addParameter("badge", Badge);
				uint num = checked((uint)queryreactor.insertQuery());
				queryreactor.runFastQuery(string.Concat(new object[]
				{
					"UPDATE rooms SET group_id=",
					num,
					" WHERE id=",
					RoomId,
					" LIMIT 1"
				}));
				Dictionary<uint, GroupUser> dictionary = new Dictionary<uint, GroupUser>();
				dictionary.Add(Session.GetHabbo().Id, new GroupUser(Session.GetHabbo().Id, num, 2));
				this.Groups.Add(num, new Guild(num, Name, Desc, RoomId, Badge, MercuryEnvironment.GetUnixTimestamp(), Session.GetHabbo().Id, Colour1, Colour2, dictionary, new List<uint>(), new Dictionary<uint, GroupUser>(), 0u, 1u, false, Name, Desc, 0, 0.0, 0, "", 0));

				queryreactor.runFastQuery(string.Concat(new object[]
				{
					"INSERT INTO group_memberships (group_id, user_id, rank) VALUES (",
					num,
					", ",
					Session.GetHabbo().Id,
					", '2')"
				}));
				Group = this.GetGroup(num);
                GroupUser User = new GroupUser(Session.GetHabbo().Id, num, 2);
                Session.GetHabbo().UserGroups.Add(User);
                Group.Admins.Add(Session.GetHabbo().Id, User);
				queryreactor.runFastQuery(string.Concat(new object[]
				{
					"UPDATE user_stats SET favourite_group=",
					num,
					" WHERE id= ",
					Session.GetHabbo().Id,
					" LIMIT 1"
				}));
				queryreactor.runFastQuery("DELETE FROM room_rights WHERE room_id=" + RoomId);
			}
		}
コード例 #14
0
ファイル: InteractorVendor.cs プロジェクト: BjkGkh/Mercury
		public void OnTrigger(GameClient Session, RoomItem Item, int Request, bool HasRights)
		{
			if (Item.ExtraData != "1" && Item.GetBaseItem().VendingIds.Count >= 1 && Item.InteractingUser == 0u && Session != null)
			{
				RoomUser roomUserByHabbo = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
				if (roomUserByHabbo == null)
				{
					return;
				}
				if (!Gamemap.TilesTouching(roomUserByHabbo.X, roomUserByHabbo.Y, Item.GetX, Item.GetY))
				{
					roomUserByHabbo.MoveTo(Item.SquareInFront);
					return;
				}
				Item.InteractingUser = Session.GetHabbo().Id;
				roomUserByHabbo.CanWalk = false;
				roomUserByHabbo.ClearMovement(true);
                roomUserByHabbo.SetRot(PathFinder.CalculateRotation(roomUserByHabbo.X, roomUserByHabbo.Y, Item.GetX, Item.GetY));
				Item.ReqUpdate(2, true);
				Item.ExtraData = "1";
				Item.UpdateState(false, true);
			}
		}
コード例 #15
0
		public void OnTrigger(GameClient Session, RoomItem Item, int Request, bool HasRights)
		{
			checked
			{
				int num = Item.GetBaseItem().Modes - 1;
				if (Session == null || !HasRights || num <= 0 || Item.GetBaseItem().InteractionType == InteractionType.pinata)
				{
					return;
				}
				MercuryEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.FURNI_SWITCH, 0u);
				int num2 = 0;
				int.TryParse(Item.ExtraData, out num2);
				int num3;
				if (num2 <= 0)
				{
					num3 = 1;
				}
				else
				{
					if (num2 >= num)
					{
						num3 = 0;
					}
					else
					{
						num3 = num2 + 1;
					}
				}
				Item.ExtraData = num3.ToString();
				Item.UpdateState();
				Item.GetRoom().GetWiredHandler().ExecuteWired(WiredItemType.TriggerToggleFurni, new object[]
				{
					Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id),
					Item
				});
				if (Item.GetBaseItem().StackMultipler)
				{
					Room room = Item.GetRoom();
					foreach (RoomUser current in room.GetRoomUserManager().UserList.Values)
					{
						if (current.Statusses.ContainsKey("sit"))
						{
							room.GetRoomUserManager().UpdateUserStatus(current, true);
						}
					}
				}
			}
		}
コード例 #16
0
ファイル: InteractorGate.cs プロジェクト: BjkGkh/Mercury
		public void OnTrigger(GameClient Session, RoomItem Item, int Request, bool HasRights)
		{
			checked
			{
				int num = Item.GetBaseItem().Modes - 1;
				if (!HasRights)
				{
					return;
				}
				if (num <= 0)
				{
					Item.UpdateState(false, true);
				}
				int num2 = 0;
				int.TryParse(Item.ExtraData, out num2);
				int num3;
				if (num2 <= 0)
				{
					num3 = 1;
				}
				else
				{
					if (num2 >= num)
					{
						num3 = 0;
					}
					else
					{
						num3 = num2 + 1;
					}
				}
				if (num3 == 0 && !Item.GetRoom().GetGameMap().itemCanBePlacedHere(Item.GetX, Item.GetY))
				{
					return;
				}
				Item.ExtraData = num3.ToString();
				Item.UpdateState();
				Item.GetRoom().GetGameMap().updateMapForItem(Item);
				Item.GetRoom().GetWiredHandler().ExecuteWired(WiredItemType.TriggerToggleFurni, new object[]
				{
					Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id),
					Item
				});
			}
		}
コード例 #17
0
        internal static ServerMessage Compose(GameClient Session, List<Achievement> Achievements)
        {
            ServerMessage serverMessage = new ServerMessage(Outgoing.AchievementListMessageComposer);
            serverMessage.AppendInt32(Achievements.Count);
            foreach (Achievement achievement in Achievements)
            {
                UserAchievement achievementData = Session.GetHabbo().GetAchievementData(achievement.GroupName);
                int i = achievementData != null ? checked(achievementData.Level + 1) : 1;
                int count = achievement.Levels.Count;
                if (i > count)
                {
                    i = count;
                }
                AchievementLevel achievementLevel = achievement.Levels[i];
                AchievementLevel oldLevel = (achievement.Levels.ContainsKey(i - 1)) ? achievement.Levels[i - 1] : achievementLevel;

                serverMessage.AppendUInt(achievement.Id);
                serverMessage.AppendInt32(i);
                serverMessage.AppendString(achievement.GroupName + i);
                serverMessage.AppendInt32(oldLevel.Requirement); // Requisito Anterior
                serverMessage.AppendInt32(achievementLevel.Requirement); // Requisito Nuevo
                serverMessage.AppendInt32(achievementLevel.RewardPoints);
                serverMessage.AppendInt32(0);
                serverMessage.AppendInt32(achievementData != null ? achievementData.Progress : 0); // Progreso Total
                if (achievementData == null)
                {
                    serverMessage.AppendBoolean(false);
                }
                else if (achievementData.Level >= count)
                {
                    serverMessage.AppendBoolean(true);
                }
                else
                {
                    serverMessage.AppendBoolean(false); // Terminado
                }
                serverMessage.AppendString(achievement.Category);
                serverMessage.AppendString(string.Empty);
                serverMessage.AppendInt32(count); // Número de niveles
                serverMessage.AppendInt32(0);
            }
            serverMessage.AppendString("");
            return serverMessage;
        }
コード例 #18
0
		public void OnTrigger(GameClient Session, RoomItem Item, int Request, bool HasRights)
		{
			RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
			if (User == null)
			{
				return;
			}
			
			if (User.CurrentEffect == 172 || User.CurrentEffect == 5 || User.CurrentEffect == 173)
			{
				if (Item.ExtraData != "5")
				{
					if (!Item.VikingCotieBurning)
					{
                        Item.ExtraData = "1";
                        Item.UpdateState();

						Item.VikingCotieBurning = true;
                        GameClient clientByUsername = MercuryEnvironment.GetGame().GetClientManager().GetClientByUsername(Item.GetRoom().Owner);
                       
                        if (clientByUsername != null )
                        {
                            if (clientByUsername.GetHabbo().Username != Item.GetRoom().Owner)
                            {
                                clientByUsername.SendNotif("" + User.GetUsername() + " ha empezado a quemar una cabaña vikingo de tu Sala!");
                            }
                        }

                        this.mItem = Item;

                        Timer Timer = new Timer(5000);
                        Timer.Elapsed += OnElapse;
                        Timer.Enabled = true;
						return;
					}
				}
				else
				{
					Session.SendNotif("¡Lo sentimos! Esta cabaña Vikingo ya ha sido quemada y no hay marcha atrás!");
				}
			}
		}
コード例 #19
0
ファイル: RoomUserManager.cs プロジェクト: BjkGkh/Mercury
        internal void AddUserToRoom(GameClient Session, bool Spectator, bool snow = false)
        {
            RoomUser roomUser = new RoomUser(Session.GetHabbo().Id, this.room.RoomId, this.primaryPrivateUserID++, this.room, Spectator);
            if (roomUser == null || roomUser.GetClient() == null)
            {
                return;
            }
            roomUser.GetClient().GetHabbo();
            roomUser.UserID = Session.GetHabbo().Id;
            string username = Session.GetHabbo().Username;
            uint userID = roomUser.UserID;
            if (this.usersByUsername.Contains(username.ToLower()))
            {
                this.usersByUsername.Remove(username.ToLower());
            }
            if (this.usersByUserID.Contains(userID))
            {
                this.usersByUserID.Remove(userID);
            }
            this.usersByUsername.Add(Session.GetHabbo().Username.ToLower(), roomUser);
            this.usersByUserID.Add(Session.GetHabbo().Id, roomUser);
            int num = this.secondaryPrivateUserID++;
            roomUser.InternalRoomID = num;
            Session.CurrentRoomUserID = num;
            Session.GetHabbo().CurrentRoomId = this.room.RoomId;
            this.UserList.Add(num, roomUser);

            if (MercuryEnvironment.GetGame().GetNavigator().PrivateCategories.Contains(room.Category))
            {
                ((FlatCat)MercuryEnvironment.GetGame().GetNavigator().PrivateCategories[room.Category]).addUser();
            }
        }
コード例 #20
0
ファイル: SongManager.cs プロジェクト: BjkGkh/Mercury
		private static void GetPlaylist(GameClient Session, ClientMessage Message)
		{
			Room currentRoom = Session.GetHabbo().CurrentRoom;
			if (currentRoom == null || !currentRoom.CheckRights(Session, true, false))
			{
				return;
			}
			Session.SendMessage(JukeboxComposer.Compose(currentRoom.GetRoomMusicController().PlaylistCapacity, currentRoom.GetRoomMusicController().Playlist.Values.ToList<SongInstance>()));
		}
コード例 #21
0
ファイル: RoomItemHandling.cs プロジェクト: BjkGkh/Mercury
		internal bool SetFloorItem(GameClient Session, RoomItem Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage, bool updateRoomUserStatuses)
		{
			bool flag = false;
			if (!newItem)
			{
				flag = this.room.GetGameMap().RemoveFromMap(Item);
			}
			Dictionary<int, ThreeDCoord> affectedTiles = Gamemap.GetAffectedTiles(Item.GetBaseItem().InteractionType, Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot);
			if (!this.room.GetGameMap().ValidTile(newX, newY) || (this.room.GetGameMap().SquareHasUsers(newX, newY) && !Item.GetBaseItem().IsSeat))
			{
				if (flag)
				{
					this.AddItem(Item);
					this.room.GetGameMap().AddToMap(Item);
				}
				return false;
			}
            
			foreach (ThreeDCoord current in affectedTiles.Values)
			{
				if (!this.room.GetGameMap().ValidTile(current.X, current.Y) || (this.room.GetGameMap().SquareHasUsers(current.X, current.Y) && !Item.GetBaseItem().IsSeat))
				{
					if (flag)
					{
						this.AddItem(Item);
						this.room.GetGameMap().AddToMap(Item);
					}
					bool result = false;
					return result;
				}
			}
			double num = (double)this.room.GetGameMap().Model.SqFloorHeight[newX, newY];
			if (!OnRoller)
			{
				if (this.room.GetGameMap().Model.SqState[newX, newY] != SquareState.OPEN && !Item.GetBaseItem().IsSeat)
				{
					if (flag)
					{
						this.AddItem(Item);
						if (newItem)
						{
							this.room.GetGameMap().AddToMap(Item);
						}
					}
					return false;
				}
				foreach (ThreeDCoord current2 in affectedTiles.Values)
				{
					if (this.room.GetGameMap().Model.SqState[current2.X, current2.Y] != SquareState.OPEN && !Item.GetBaseItem().IsSeat)
					{
						if (flag)
						{
							this.AddItem(Item);
							this.room.GetGameMap().AddToMap(Item);
						}
						bool result = false;
						return result;
					}
				}
				if (!Item.GetBaseItem().IsSeat && !Item.IsRoller)
				{
					foreach (ThreeDCoord current3 in affectedTiles.Values)
					{
						if (this.room.GetGameMap().GetRoomUsers(new Point(current3.X, current3.Y)).Count > 0)
						{
							if (flag)
							{
								this.AddItem(Item);
								this.room.GetGameMap().AddToMap(Item);
							}
							bool result = false;
							return result;
						}
					}
				}
			}
			List<RoomItem> furniObjects = this.GetFurniObjects(newX, newY);
			List<RoomItem> list = new List<RoomItem>();
			List<RoomItem> list2 = new List<RoomItem>();
			foreach (ThreeDCoord current4 in affectedTiles.Values)
			{
				List<RoomItem> furniObjects2 = this.GetFurniObjects(current4.X, current4.Y);
				if (furniObjects2 != null)
				{
					list.AddRange(furniObjects2);
				}
			}
			list2.AddRange(furniObjects);
			list2.AddRange(list);
			if (!OnRoller)
			{
				foreach (RoomItem current5 in list2)
				{
					if (current5 != null && current5.Id != Item.Id && current5.GetBaseItem() != null && !current5.GetBaseItem().Stackable)
					{
						if (flag)
						{
							this.AddItem(Item);
							this.room.GetGameMap().AddToMap(Item);
						}
						bool result = false;
						return result;
					}
				}
			}
			if (Item.Rot != newRot && Item.GetX == newX && Item.GetY == newY)
			{
				num = Item.GetZ;
			}
			foreach (RoomItem current6 in list2)
			{
				if (current6.Id != Item.Id && current6.TotalHeight > num)
				{
					num = current6.TotalHeight;
				}
			}
			if (newRot != 0 && newRot != 2 && newRot != 4 && newRot != 6 && newRot != 8 && Item.GetBaseItem().InteractionType != InteractionType.mannequin)
			{
				newRot = 0;
			}
			Item.Rot = newRot;
			int arg_47A_0 = Item.GetX;
			int arg_481_0 = Item.GetY;
			Item.SetState(newX, newY, num, affectedTiles);
			if (!OnRoller && Session != null)
			{
				Item.Interactor.OnPlace(Session, Item);
			}
			if (newItem)
			{
				if (this.mFloorItems.ContainsKey(Item.Id))
				{
					return true;
				}
				if (Item.IsFloorItem && !this.mFloorItems.ContainsKey(Item.Id))
				{
					this.mFloorItems.Add(Item.Id, Item);
				}
				else
				{
					if (Item.IsWallItem && !this.mWallItems.ContainsKey(Item.Id))
					{
						this.mWallItems.Add(Item.Id, Item);
					}
				}
				this.AddItem(Item);
				if (sendMessage)
				{
					ServerMessage serverMessage = new ServerMessage(Outgoing.AddFloorItemMessageComposer);
					Item.Serialize(serverMessage);
					if (this.room.Group != null)
					{
						serverMessage.AppendString(Session.GetHabbo().Username);
					}
					else
					{
						serverMessage.AppendString(this.room.Owner);
					}
					this.room.SendMessage(serverMessage);
                     
				}
			}
			else
			{
				this.UpdateItem(Item);
				if (!OnRoller && sendMessage)
				{
					ServerMessage message = new ServerMessage(Outgoing.UpdateRoomItemMessageComposer);
					Item.Serialize(message);
					this.room.SendMessage(message);
				}
				if (Item.IsWired)
				{
					this.room.GetWiredHandler().MoveWired(Item);
				}
			}
			this.room.GetGameMap().AddToMap(Item);
			if (Item.GetBaseItem().IsSeat)
			{
				updateRoomUserStatuses = true;
			}
			if (updateRoomUserStatuses)
			{
				this.room.GetRoomUserManager().UpdateUserStatusses();
			}
            if (newItem)
            {
                this.OnHeightmapUpdate(affectedTiles);
            }

			return true;
		}
コード例 #22
0
ファイル: SongManager.cs プロジェクト: BjkGkh/Mercury
		private static void AddToPlaylist(GameClient Session, ClientMessage Message)
		{
			Room currentRoom = Session.GetHabbo().CurrentRoom;
			if (currentRoom == null || !currentRoom.CheckRights(Session, true, false) || !currentRoom.GotMusicController() || currentRoom.GetRoomMusicController().PlaylistSize >= currentRoom.GetRoomMusicController().PlaylistCapacity)
			{
				return;
			}
			UserItem item = Session.GetHabbo().GetInventoryComponent().GetItem(Message.PopWiredUInt());
			if (item == null || item.GetBaseItem().InteractionType != InteractionType.musicdisc)
			{
				return;
			}
			SongItem songItem = new SongItem(item);
			int num = currentRoom.GetRoomMusicController().AddDisk(songItem);
			if (num < 0)
			{
				return;
			}
			Session.GetHabbo().GetInventoryComponent().RemoveItem(songItem.itemID, true);
			Session.SendMessage(JukeboxComposer.Compose(currentRoom.GetRoomMusicController().PlaylistCapacity, currentRoom.GetRoomMusicController().Playlist.Values.ToList<SongInstance>()));
		}
コード例 #23
0
ファイル: SongManager.cs プロジェクト: BjkGkh/Mercury
		private static void RemoveFromPlaylist(GameClient Session, ClientMessage Message)
		{
			Room currentRoom = Session.GetHabbo().CurrentRoom;
			if (currentRoom == null || !currentRoom.GotMusicController() || !currentRoom.CheckRights(Session, true, false))
			{
				return;
			}
			SongItem songItem = currentRoom.GetRoomMusicController().RemoveDisk(Message.PopWiredInt32());
			if (songItem == null)
			{
				return;
			}
			Session.GetHabbo().GetInventoryComponent().AddNewItem(songItem.itemID, songItem.baseItem.ItemId, songItem.songID.ToString(), 0u, true, true, 0, 0, "");
			Session.SendMessage(JukeboxComposer.Compose(Session));
			Session.SendMessage(JukeboxComposer.Compose(currentRoom.GetRoomMusicController().PlaylistCapacity, currentRoom.GetRoomMusicController().Playlist.Values.ToList<SongInstance>()));
		}
コード例 #24
0
ファイル: MessengerBuddy.cs プロジェクト: BjkGkh/Mercury
		internal void Serialize(ServerMessage Message, GameClient Session)
		{
			Relationship value = Session.GetHabbo().Relationships.FirstOrDefault((KeyValuePair<int, Relationship> x) => x.Value.UserId == Convert.ToInt32(this.UserId)).Value;
			int i = (value == null) ? 0 : value.Type;
			Message.AppendUInt(this.UserId);
			Message.AppendString(this.mUsername);
			Message.AppendInt32(1);
			if (!this.mAppearOffline || Session.GetHabbo().Rank >= 4u)
			{
				Message.AppendBoolean(this.IsOnline);
			}
			else
			{
				Message.AppendBoolean(false);
			}
			if (!this.mHideInroom || Session.GetHabbo().Rank >= 4u)
			{
				Message.AppendBoolean(this.InRoom);
			}
			else
			{
				Message.AppendBoolean(false);
			}
			Message.AppendString(this.IsOnline ? this.mLook : "");
			Message.AppendInt32(0);
			Message.AppendString(this.mMotto);
			Message.AppendString(string.Empty);
			Message.AppendString(string.Empty);
			Message.AppendBoolean(true);
			Message.AppendBoolean(false);
			Message.AppendBoolean(false);
			Message.AppendShort(i);
		}
コード例 #25
0
ファイル: RoomUserManager.cs プロジェクト: BjkGkh/Mercury
        internal void RemoveUserFromRoom(GameClient Session, bool NotifyClient, bool NotifyKick)
        {
            try
            {
                if (Session == null || Session.GetHabbo() == null || this.room == null)
                {
                    return;
                }
                Session.GetHabbo().GetAvatarEffectsInventoryComponent().OnRoomExit();
                using (IQueryAdapter queryreactor = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    queryreactor.runFastQuery(string.Concat(new object[]
					{
						"UPDATE user_roomvisits SET exit_timestamp = '",
						MercuryEnvironment.GetUnixTimestamp(),
						"' WHERE room_id = '",
						this.room.RoomId,
						"' AND user_id = '",
						Session.GetHabbo().Id,
						"' ORDER BY entry_timestamp DESC LIMIT 1"
					}));
                }
                RoomUser roomUserByHabbo = this.GetRoomUserByHabbo(Session.GetHabbo().Id);
                if (roomUserByHabbo == null)
                {
                    return;
                }
                if (NotifyKick || (NotifyClient && NotifyKick))
                {
                    Room room = MercuryEnvironment.GetGame().GetRoomManager().GetRoom(roomUserByHabbo.RoomId);
                    DynamicRoomModel model = room.GetGameMap().Model;
                    roomUserByHabbo.MoveTo(model.DoorX, model.DoorY);
                    roomUserByHabbo.CanWalk = false;
                    Session.GetMessageHandler().GetResponse().Init(Outgoing.RoomErrorMessageComposer);
                    Session.GetMessageHandler().GetResponse().AppendInt32(4008);
                    Session.GetMessageHandler().SendResponse();


                    Session.GetMessageHandler().GetResponse().Init(Outgoing.OutOfRoomMessageComposer);
                    Session.GetMessageHandler().GetResponse().AppendShort(2);
                    Session.GetMessageHandler().SendResponse();
                }
                else
                {
                    if (NotifyClient && !NotifyKick)
                    {
                        ServerMessage serverMessage = new ServerMessage(Outgoing.UserIsPlayingFreezeMessageComposer);
                        serverMessage.AppendBoolean(roomUserByHabbo.team != Team.none);
                        roomUserByHabbo.GetClient().SendMessage(serverMessage);
                        Session.GetMessageHandler().GetResponse().Init(Outgoing.OutOfRoomMessageComposer);
                        Session.GetMessageHandler().GetResponse().AppendShort(2);
                        Session.GetMessageHandler().SendResponse();
                    }
                }
                if (roomUserByHabbo != null)
                {
                    if (roomUserByHabbo.team != Team.none)
                    {
                        this.room.GetTeamManagerForBanzai().OnUserLeave(roomUserByHabbo);
                        this.room.GetTeamManagerForFreeze().OnUserLeave(roomUserByHabbo);
                    }
                    if (roomUserByHabbo.RidingHorse)
                    {
                        roomUserByHabbo.RidingHorse = false;
                        RoomUser Horse = this.GetRoomUserByVirtualId((int)roomUserByHabbo.HorseID);
                        if (Horse != null)
                        {
                            Horse.RidingHorse = false;
                            Horse.HorseID = 0u;
                        }
                    }
                    if (roomUserByHabbo.IsLyingDown || roomUserByHabbo.IsSitting)
                    {
                        roomUserByHabbo.IsSitting = false;
                        roomUserByHabbo.IsLyingDown = false;
                    }
                    this.RemoveRoomUser(roomUserByHabbo);
                    if (Session.GetHabbo() != null && !roomUserByHabbo.IsSpectator)
                    {
                        if (roomUserByHabbo.CurrentItemEffect != ItemEffectType.None)
                        {
                            roomUserByHabbo.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().CurrentEffect = -1;
                        }
                        if (Session.GetHabbo() != null)
                        {
                            if (this.room.HasActiveTrade(Session.GetHabbo().Id))
                            {
                                this.room.TryStopTrade(Session.GetHabbo().Id);
                            }
                            Session.GetHabbo().CurrentRoomId = 0u;
                            if (Session.GetHabbo().GetMessenger() != null)
                            {
                                Session.GetHabbo().GetMessenger().OnStatusChanged(true);
                            }
                        }
                        DateTime now = DateTime.Now;
                        using (IQueryAdapter queryreactor2 = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
                        {

                            if (Session.GetHabbo() != null)
                            {
                                queryreactor2.runFastQuery(string.Concat(new object[]
								{
									"UPDATE user_roomvisits SET exit_timestamp = '",
									MercuryEnvironment.GetUnixTimestamp(),
									"' WHERE room_id = '",
									this.room.RoomId,
									"' AND user_id = '",
									Session.GetHabbo().Id,
									"' ORDER BY exit_timestamp DESC LIMIT 1"
								}));
                            }
                        }
                    }
                    this.usersByUserID.Remove(roomUserByHabbo.UserID);
                    if (Session.GetHabbo() != null)
                    {
                        this.usersByUsername.Remove(Session.GetHabbo().Username.ToLower());
                    }
                    roomUserByHabbo.Dispose();
                }
            }
            catch (Exception ex)
            {
                Logging.LogCriticalException("Error during removing user from room:" + ex.ToString());
            }
        }
コード例 #26
0
ファイル: GameClientManager.cs プロジェクト: BjkGkh/Mercury
		internal void SendSuperNotif(string Title, string Notice, string Picture, GameClient Client, string Link, string LinkTitle, bool Broadcast, bool Event)
		{
			ServerMessage serverMessage = new ServerMessage(Outgoing.SuperNotificationMessageComposer);
			serverMessage.AppendString(Picture);
			serverMessage.AppendInt32(4);
			serverMessage.AppendString("title");
			serverMessage.AppendString(Title);
			serverMessage.AppendString("message");
			if (Broadcast)
			{
				if (Event)
				{
					serverMessage.AppendString("<b>¡Nuevo evento abierto ahora en la Sala de " + Client.GetHabbo().CurrentRoom.Owner + "!</b> ¡Corre! No querrás ser el último en llegar.\r\n<b>Más detalles:</b>\r\n" + Notice);
				}
				else
				{
					serverMessage.AppendString(string.Concat(new string[]
					{
						"<b>Mensaje del Equipo Staff:</b>\r\n",
						Notice,
						"\r\n- <i>",
						Client.GetHabbo().Username,
						"</i>"
					}));
				}
			}
			else
			{
				serverMessage.AppendString(Notice);
			}
			if (Link != "")
			{
				serverMessage.AppendString("linkUrl");
				serverMessage.AppendString(Link);
                serverMessage.AppendString("linkTitle");
                serverMessage.AppendString(LinkTitle);
			}
            else
            {
                serverMessage.AppendString("linkUrl");
                serverMessage.AppendString("event:");
                serverMessage.AppendString("linkTitle");
                serverMessage.AppendString("ok");
            }
           
			if (Broadcast)
			{
				this.QueueBroadcaseMessage(serverMessage);
				return;
			}
			Client.SendMessage(serverMessage);
		}
コード例 #27
0
ファイル: Catalog.cs プロジェクト: BjkGkh/Mercury
        internal List<UserItem> DeliverItems(GameClient Session, Item Item, int Amount, string ExtraData, int limno, int limtot, string SongCode)
        {
            List<UserItem> list = new List<UserItem>();
            if (Item.InteractionType == InteractionType.postit)
            {
                Amount = Amount * 20;
            }
            checked
            {
                string a;
                if ((a = Item.Type.ToString()) != null)
                {
                    if (a == "i" || a == "s")
                    {
                        int i = 0;
                        while (i < Amount)
                        {
                            InteractionType interactionType = Item.InteractionType;
                            switch (interactionType)
                            {
                                case InteractionType.dimmer:
                                    goto IL_F87;
                                case InteractionType.trophy:
                                case InteractionType.bed:
                                case InteractionType.scoreboard:
                                case InteractionType.vendingmachine:
                                case InteractionType.alert:
                                case InteractionType.onewaygate:
                                case InteractionType.loveshuffler:
                                case InteractionType.habbowheel:
                                case InteractionType.dice:
                                case InteractionType.bottle:
                                case InteractionType.hopper:
                                case InteractionType.rentals:
                                case InteractionType.pet:
                                case InteractionType.pool:
                                case InteractionType.roller:
                                case InteractionType.fbgate:
                                    goto IL_10C3;
                                case InteractionType.teleport:
                                    {
                                        UserItem userItem = Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, Item.ItemId, "0", 0u, true, false, 0, 0, "");
                                        uint id = userItem.Id;
                                        UserItem userItem2 = Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, Item.ItemId, "0", 0u, true, false, 0, 0, "");
                                        uint id2 = userItem2.Id;
                                        list.Add(userItem);
                                        list.Add(userItem2);
                                        using (IQueryAdapter queryreactor = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
                                        {
                                            queryreactor.runFastQuery(string.Concat(new object[]
									{
										"INSERT INTO tele_links (tele_one_id,tele_two_id) VALUES (",
										id,
										",",
										id2,
										")"
									}));
                                            queryreactor.runFastQuery(string.Concat(new object[]
									{
										"INSERT INTO tele_links (tele_one_id,tele_two_id) VALUES (",
										id2,
										",",
										id,
										")"
									}));
                                            break;
                                        }
                                    }
                                case InteractionType.pet0:
                                    {
                                        string[] array = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet = Catalog.CreatePet(Session.GetHabbo().Id, array[0], 0, array[1], array[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet1:
                                    {
                                        string[] array2 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet2 = Catalog.CreatePet(Session.GetHabbo().Id, array2[0], 1, array2[1], array2[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet2);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet2:
                                    {
                                        string[] array3 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet3 = Catalog.CreatePet(Session.GetHabbo().Id, array3[0], 2, array3[1], array3[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet3);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet3:
                                    {
                                        string[] array4 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet4 = Catalog.CreatePet(Session.GetHabbo().Id, array4[0], 3, array4[1], array4[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet4);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet4:
                                    {
                                        string[] array5 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet5 = Catalog.CreatePet(Session.GetHabbo().Id, array5[0], 4, array5[1], array5[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet5);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet5:
                                    {
                                        string[] array6 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet6 = Catalog.CreatePet(Session.GetHabbo().Id, array6[0], 5, array6[1], array6[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet6);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet6:
                                    {
                                        string[] array7 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet7 = Catalog.CreatePet(Session.GetHabbo().Id, array7[0], 6, array7[1], array7[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet7);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet7:
                                    {
                                        string[] array8 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet8 = Catalog.CreatePet(Session.GetHabbo().Id, array8[0], 7, array8[1], array8[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet8);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet8:
                                    {
                                        string[] array9 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet9 = Catalog.CreatePet(Session.GetHabbo().Id, array9[0], 8, array9[1], array9[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet9);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet9:
                                    {
                                        string[] array10 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet10 = Catalog.CreatePet(Session.GetHabbo().Id, array10[0], 9, array10[1], array10[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet10);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet10:
                                    {
                                        string[] array11 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet11 = Catalog.CreatePet(Session.GetHabbo().Id, array11[0], 10, array11[1], array11[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet11);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet11:
                                    {
                                        string[] array12 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet12 = Catalog.CreatePet(Session.GetHabbo().Id, array12[0], 11, array12[1], array12[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet12);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet12:
                                    {
                                        string[] array13 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet13 = Catalog.CreatePet(Session.GetHabbo().Id, array13[0], 12, array13[1], array13[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet13);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet13:
                                    {
                                        string[] array14 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet14 = Catalog.CreatePet(Session.GetHabbo().Id, array14[0], 13, array14[1], array14[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet14);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet14:
                                    {
                                        string[] array15 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet15 = Catalog.CreatePet(Session.GetHabbo().Id, array15[0], 14, array15[1], array15[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet15);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet15:
                                    {
                                        string[] array16 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet16 = Catalog.CreatePet(Session.GetHabbo().Id, array16[0], 15, array16[1], array16[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet16);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet16:
                                    {
                                        string[] array17 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet17 = Catalog.CreatePet(Session.GetHabbo().Id, array17[0], 16, array17[1], array17[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet17);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet17:
                                    {
                                        string[] array18 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet18 = Catalog.CreatePet(Session.GetHabbo().Id, array18[0], 17, array18[1], array18[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet18);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet18:
                                    {
                                        string[] array19 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet19 = Catalog.CreatePet(Session.GetHabbo().Id, array19[0], 18, array19[1], array19[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet19);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet19:
                                    {
                                        string[] array20 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet20 = Catalog.CreatePet(Session.GetHabbo().Id, array20[0], 19, array20[1], array20[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet20);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet20:
                                    {
                                        string[] array21 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet21 = Catalog.CreatePet(Session.GetHabbo().Id, array21[0], 20, array21[1], array21[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet21);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet21:
                                    {
                                        string[] array22 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet22 = Catalog.CreatePet(Session.GetHabbo().Id, array22[0], 21, array22[1], array22[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet22);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet22:
                                    {
                                        string[] array23 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet23 = Catalog.CreatePet(Session.GetHabbo().Id, array23[0], 22, array23[1], array23[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet23);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet23:
                                    {
                                        string[] array24 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet24 = Catalog.CreatePet(Session.GetHabbo().Id, array24[0], 23, array24[1], array24[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet24);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet24:
                                    {
                                        string[] array25 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet25 = Catalog.CreatePet(Session.GetHabbo().Id, array25[0], 24, array25[1], array25[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet25);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet25:
                                    {
                                        string[] array26 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet26 = Catalog.CreatePet(Session.GetHabbo().Id, array26[0], 25, array26[1], array26[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet26);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                case InteractionType.pet26:
                                    {
                                        string[] array27 = ExtraData.Split(new char[]
								{
									'\n'
								});
                                        Pet pet27 = Catalog.CreatePet(Session.GetHabbo().Id, array27[0], 26, array27[1], array27[2], 0);
                                        Session.GetHabbo().GetInventoryComponent().AddPet(pet27);
                                        list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, 320u, "0", 0u, true, false, 0, 0, ""));
                                        break;
                                    }
                                default:
                                    switch (interactionType)
                                    {
                                        case InteractionType.musicdisc:
                                            goto IL_1067;
                                        case InteractionType.puzzlebox:
                                            goto IL_10C3;
                                        case InteractionType.roombg:
                                            goto IL_FF7;
                                        default:
                                            switch (interactionType)
                                            {
                                                case InteractionType.gld_item:
                                                case InteractionType.gld_gate:
                                                case InteractionType.groupforumterminal:
                                                    list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, Item.ItemId, "0", Convert.ToUInt32(ExtraData), true, false, 0, 0, ""));
                                                    break;
                                                default:
                                                    goto IL_10C3;
                                            }
                                            break;
                                    }
                                    break;
                            }
                        IL_10EE:
                            i++;
                            continue;
                        IL_F87:
                            UserItem userItem3 = Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, Item.ItemId, ExtraData, 0u, true, false, 0, 0, "");
                            uint id3 = userItem3.Id;
                            list.Add(userItem3);
                            using (IQueryAdapter queryreactor2 = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                queryreactor2.runFastQuery("INSERT INTO room_items_moodlight (item_id,enabled,current_preset,preset_one,preset_two,preset_three) VALUES (" + id3 + ",'0',1,'#000000,255,0','#000000,255,0','#000000,255,0')");
                                goto IL_10EE;
                            }
                        IL_FF7:
                            UserItem userItem4 = Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, Item.ItemId, ExtraData, 0u, true, false, 0, 0, "");
                            uint id4 = userItem4.Id;
                            list.Add(userItem4);
                            using (IQueryAdapter queryreactor3 = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
                            {
                                queryreactor3.runFastQuery("INSERT INTO room_items_toner VALUES (" + id4 + ",'0',0,0,0)");
                                goto IL_10EE;
                            }
                        IL_1067:
                            list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, Item.ItemId, ExtraData, 0u, true, false, 0, 0, SongCode));
                            goto IL_10EE;
                        IL_10C3:
                            list.Add(Session.GetHabbo().GetInventoryComponent().AddNewItem(0u, Item.ItemId, ExtraData, 0u, true, false, limno, limtot, ""));
                            goto IL_10EE;
                        }
                        return list;
                    }
                    if (a == "e")
                    {
                        for (int j = 0; j < Amount; j++)
                        {
                            Session.GetHabbo().GetAvatarEffectsInventoryComponent().AddNewEffect(Item.SpriteId, 7200);
                        }
                        return list;
                    }
                    if (a == "r")
                    {
                        if (Item.Name == "bot_bartender")
                        {
                            RoomBot bot = Catalog.CreateBot(Session.GetHabbo().Id, "Camarera", "hr-9534-39.hd-600-1.ch-819-92.lg-3058-64.sh-3064-110.wa-2005", "¡Te calma la sed y sabe bailar!", "f", true);
                            Session.GetHabbo().GetInventoryComponent().AddBot(bot);
                            Session.SendMessage(Session.GetHabbo().GetInventoryComponent().SerializeBotInventory());
                        }
                        else
                        {
                            RoomBot bot2 = Catalog.CreateBot(Session.GetHabbo().Id, "Robbie", "hr-3020-34.hd-3091-2.ch-225-92.lg-3058-100.sh-3089-1338.ca-3084-78-108.wa-2005", "Habla, anda, baila y se viste", "m", false);
                            Session.GetHabbo().GetInventoryComponent().AddBot(bot2);
                            Session.SendMessage(Session.GetHabbo().GetInventoryComponent().SerializeBotInventory());
                        }
                        return list;
                    }
                }
                return list;
            }
        }
コード例 #28
0
ファイル: Catalog.cs プロジェクト: BjkGkh/Mercury
        internal void HandlePurchase(GameClient Session, int PageId, int ItemId, string ExtraData, int priceAmount, bool IsGift, string GiftUser, string GiftMessage, int GiftSpriteId, int GiftLazo, int GiftColor, bool undef, uint Group)
        {
            if (priceAmount < 1 || priceAmount > 100)
            {
                priceAmount = 1;
            }
            int num = priceAmount;
            int num2 = 0;
            int limtot = 0;
            CatalogPage catalogPage;
            CatalogItem item;
            uint num3;
            checked
            {
                if (priceAmount >= 6)
                {
                    num--;
                }
                if (priceAmount >= 12)
                {
                    num -= 2;
                }
                if (priceAmount >= 18)
                {
                    num -= 2;
                }
                if (priceAmount >= 24)
                {
                    num -= 2;
                }
                if (priceAmount >= 30)
                {
                    num -= 2;
                }
                if (priceAmount >= 36)
                {
                    num -= 2;
                }
                if (priceAmount >= 42)
                {
                    num -= 2;
                }
                if (priceAmount >= 48)
                {
                    num -= 2;
                }
                if (priceAmount >= 54)
                {
                    num -= 2;
                }
                if (priceAmount >= 60)
                {
                    num -= 2;
                }
                if (priceAmount >= 66)
                {
                    num -= 2;
                }
                if (priceAmount >= 72)
                {
                    num -= 2;
                }
                if (priceAmount >= 78)
                {
                    num -= 2;
                }
                if (priceAmount >= 84)
                {
                    num -= 2;
                }
                if (priceAmount >= 90)
                {
                    num -= 2;
                }
                if (priceAmount >= 96)
                {
                    num -= 2;
                }
                if (priceAmount >= 99)
                {
                    num -= 2;
                }
                if (!this.Categories.Contains(PageId) && PageId != -12345678)
                {
                    return;
                }

                if (PageId == -12345678)
                {
                    item = GetItemFromOffer(ItemId);

                    if (item == null)
                    {
                        return;
                    }
                }
                else
                {
                    catalogPage = (CatalogPage)Categories[PageId];
                    if (catalogPage == null || !catalogPage.Enabled || !catalogPage.Visible || Session == null || Session.GetHabbo() == null)
                    {
                        return;
                    }
                    if (catalogPage.MinRank > Session.GetHabbo().Rank || catalogPage.Layout == "sold_ltd_items")
                    {
                        return;
                    }

                    item = catalogPage.GetItem(ItemId);
                    if (item == null)
                    {
                        return;
                    }

                    if (catalogPage.Layout == "vip_buy" || catalogPage.Layout == "club_buy" || HabboClubItems.Contains(item))
                    {
                        string[] array = item.Name.Split(new char[]
				{
					'_'
				});
                        double dayLength;
                        if (item.Name.Contains("DAY"))
                        {
                            dayLength = double.Parse(array[3]);
                        }
                        else
                        {
                            if (item.Name.Contains("MONTH"))
                            {
                                double num4 = double.Parse(array[3]);
                                dayLength = Math.Ceiling((num4 * 31) - 0.205);
                            }
                            else
                            {
                                if (item.Name.Contains("YEAR"))
                                {
                                    double num5 = double.Parse(array[3]);
                                    dayLength = (num5 * 31 * 12);
                                }
                                else
                                {
                                    dayLength = 31;
                                }
                            }
                        }
                        Session.GetHabbo().GetSubscriptionManager().AddSubscription(dayLength);
                       
                        return;
                    }
                }

                if (item.Name == "room_ad_plus_badge")
                {
                    return;
                }

                if (item.ClubOnly && !Session.GetHabbo().GetSubscriptionManager().HasSubscription)
                {
                    ServerMessage serverMessage = new ServerMessage(Outgoing.CatalogPurchaseNotAllowedMessageComposer);
                    serverMessage.AppendInt32(1);
                    Session.SendMessage(serverMessage);
                    return;
                }
                else if (item.Name.Contains("guild_forum"))
                {
                    uint GroupId;
                    if (!uint.TryParse(ExtraData, out GroupId))
                    {
                        Session.SendNotif("Your group forum couldn't be created by an unknown error. Please report it.");
                        return;
                    }
                    else
                    {
                        Guild Grap = MercuryEnvironment.GetGame().GetGroupManager().GetGroup(GroupId);
                        if (Grap == null)
                        {
                            Session.SendNotif("Your group forum couldn't be created by an unknown error. Please report it");
                            return;
                        }
                        else if (!Grap.HasForum && Grap.CreatorId == Session.GetHabbo().Id)
                        {
                            Grap.HasForum = true;
                            MercuryEnvironment.GetGame().GetClientManager().SendSuperNotif("Congratulations!", "You successfully purchased a Forum for your group.", "admin", Session, "event:groupforum/" + Grap.Id, "Enter my new Group Forum", false, false);
                            Grap.UpdateForum();
                        }
                        else if (Grap.CreatorId != Session.GetHabbo().Id && !Grap.HasForum)
                        {
                            Session.SendNotif("Uhm, looks like you're not the owner of the group. Anyway, you received a Group Forum Terminal, which would work only when the owner of the group buys a forum.");
                        }
                    }
                }
                bool flag = false;
                foreach (uint current in item.Items.Keys)
                {
                    if (item.GetBaseItem(current).InteractionType == InteractionType.pet1 || item.GetBaseItem(current).InteractionType == InteractionType.pet2 || item.GetBaseItem(current).InteractionType == InteractionType.pet3 || item.GetBaseItem(current).InteractionType == InteractionType.pet4 || item.GetBaseItem(current).InteractionType == InteractionType.pet5 || item.GetBaseItem(current).InteractionType == InteractionType.pet6 || item.GetBaseItem(current).InteractionType == InteractionType.pet7 || item.GetBaseItem(current).InteractionType == InteractionType.pet8 || item.GetBaseItem(current).InteractionType == InteractionType.pet9 || item.GetBaseItem(current).InteractionType == InteractionType.pet10 || item.GetBaseItem(current).InteractionType == InteractionType.pet11 || item.GetBaseItem(current).InteractionType == InteractionType.pet12 || item.GetBaseItem(current).InteractionType == InteractionType.pet13 || item.GetBaseItem(current).InteractionType == InteractionType.pet14 || item.GetBaseItem(current).InteractionType == InteractionType.pet15 || item.GetBaseItem(current).InteractionType == InteractionType.pet16 || item.GetBaseItem(current).InteractionType == InteractionType.pet17 || item.GetBaseItem(current).InteractionType == InteractionType.pet18 || item.GetBaseItem(current).InteractionType == InteractionType.pet19 || item.GetBaseItem(current).InteractionType == InteractionType.pet20 || item.GetBaseItem(current).InteractionType == InteractionType.pet21 || item.GetBaseItem(current).InteractionType == InteractionType.pet22 || item.GetBaseItem(current).InteractionType == InteractionType.pet23 || item.GetBaseItem(current).InteractionType == InteractionType.pet24 || item.GetBaseItem(current).InteractionType == InteractionType.pet25 || item.GetBaseItem(current).InteractionType == InteractionType.pet26)
                    {
                        flag = true;
                    }
                }
                if (!flag && (item.CreditsCost * num < 0 || item.DucketsCost * num < 0 || item.BelCreditsCost * num < 0 || item.LoyaltyCost * num < 0))
                {
                    return;
                }
                if (item.IsLimited)
                {
                    num = 1;
                    priceAmount = 1;
                    if (item.LimitedSelled >= item.LimitedStack)
                    {
                        Session.SendMessage(new ServerMessage(Outgoing.CatalogLimitedItemSoldOutMessageComposer));
                        return;
                    }
                    item.LimitedSelled++;
                    using (IQueryAdapter queryreactor = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        queryreactor.runFastQuery(string.Concat(new object[]
						{
							"UPDATE catalog_items SET limited_sells = ",
							item.LimitedSelled,
							" WHERE id = ",
							item.Id
						}));
                        num2 = item.LimitedSelled;
                        limtot = item.LimitedStack;
                    }
                }
                else
                {
                    if (IsGift & priceAmount > 1)
                    {
                        num = 1;
                        priceAmount = 1;
                    }
                }
                num3 = 0u;
                if (Session.GetHabbo().Credits < item.CreditsCost * num)
                {
                    return;
                }
                if (Session.GetHabbo().ActivityPoints < item.DucketsCost * num)
                {
                    return;
                }
                if (Session.GetHabbo().BelCredits < item.BelCreditsCost * num)
                {
                    return;
                }
                if (Session.GetHabbo().BelCredits < item.LoyaltyCost * num)
                {
                    return;
                }
                if (item.CreditsCost > 0 && !IsGift)
                {
                    Session.GetHabbo().Credits -= item.CreditsCost * num;
                    Session.GetHabbo().UpdateCreditsBalance();
                }
                if (item.DucketsCost > 0 && !IsGift)
                {
                    Session.GetHabbo().ActivityPoints -= item.DucketsCost * num;
                    Session.GetHabbo().UpdateActivityPointsBalance();
                }
                if (item.BelCreditsCost > 0 && !IsGift)
                {
                    Session.GetHabbo().BelCredits -= item.BelCreditsCost * num;
                    Session.GetHabbo().UpdateSeasonalCurrencyBalance();
                }
                if (item.LoyaltyCost > 0 && !IsGift)
                {
                    Session.GetHabbo().BelCredits -= item.LoyaltyCost * num;
                    Session.GetHabbo().UpdateSeasonalCurrencyBalance();
                }
            }

            

            checked
            {
                foreach (uint current2 in item.Items.Keys)
                {
                    if (IsGift)
                    {
                        if ((DateTime.Now - Session.GetHabbo().LastGiftPurchaseTime).TotalSeconds <= 15.0)
                        {
                            Session.SendNotif("You're purchasing gifts too fast! Please wait 15 seconds, then you purchase another gift.");
                            return;
                        }

                        if (!item.GetBaseItem(current2).AllowGift)
                        {
                            return;
                        }
                        DataRow row;
                        using (IQueryAdapter queryreactor3 = MercuryEnvironment.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(Outgoing.GiftErrorMessageComposer);
                            Session.GetMessageHandler().GetResponse().AppendString(GiftUser);
                            Session.GetMessageHandler().SendResponse();
                            return;
                        }
                        num3 = Convert.ToUInt32(row["id"]);
                        if (num3 == 0u)
                        {
                            Session.GetMessageHandler().GetResponse().Init(Outgoing.GiftErrorMessageComposer);
                            Session.GetMessageHandler().GetResponse().AppendString(GiftUser);
                            Session.GetMessageHandler().SendResponse();
                            return;
                        }
                        if (item.CreditsCost > 0 && IsGift)
                        {
                            Session.GetHabbo().Credits -= item.CreditsCost * num;
                            Session.GetHabbo().UpdateCreditsBalance();
                        }
                        if (item.DucketsCost > 0 && IsGift)
                        {
                            Session.GetHabbo().ActivityPoints -= item.DucketsCost * num;
                            Session.GetHabbo().UpdateActivityPointsBalance();
                        }
                        if (item.BelCreditsCost > 0 && IsGift)
                        {
                            Session.GetHabbo().BelCredits -= item.BelCreditsCost * num;
                            Session.GetHabbo().UpdateSeasonalCurrencyBalance();
                        }
                        if (item.LoyaltyCost > 0 && IsGift)
                        {
                            Session.GetHabbo().BelCredits -= item.LoyaltyCost * num;
                            Session.GetHabbo().UpdateSeasonalCurrencyBalance();
                        }
                    }
                    if (IsGift && item.GetBaseItem(current2).Type == 'e')
                    {
                        Session.SendNotif("You can't send effects as gifts.");
                        return;
                    }
                    string text = "";
                    InteractionType interactionType = item.GetBaseItem(current2).InteractionType;
                    switch (interactionType)
                    {
                        case InteractionType.none:
                            ExtraData = "";
                            break;
                        case InteractionType.gate:
                        case InteractionType.bed:
                        case InteractionType.scoreboard:
                        case InteractionType.vendingmachine:
                        case InteractionType.alert:
                        case InteractionType.onewaygate:
                        case InteractionType.loveshuffler:
                        case InteractionType.habbowheel:
                        case InteractionType.dice:
                        case InteractionType.bottle:
                        case InteractionType.hopper:
                        case InteractionType.teleport:
                        case InteractionType.pet:
                        case InteractionType.pool:
                        case InteractionType.roller:
                        case InteractionType.fbgate:
                            goto IL_DF5;
                        case InteractionType.postit:
                            ExtraData = "FFFF33";
                            break;
                        case InteractionType.roomeffect:
                            {
                                double num6 = 0.0;
                                try
                                {
                                    if (string.IsNullOrEmpty(ExtraData))
                                    {
                                        num6 = 0.0;
                                    }
                                    else
                                    {
                                        num6 = double.Parse(ExtraData, MercuryEnvironment.cultureInfo);
                                    }
                                }
                                catch (Exception pException)
                                {
                                    Logging.HandleException(pException, "Catalog.HandlePurchase: " + ExtraData);
                                }
                                ExtraData = TextHandling.GetString(num6);
                                break;
                            }
                        case InteractionType.dimmer:
                            ExtraData = "1,1,1,#000000,255";
                            break;
                        case InteractionType.trophy:
                            ExtraData = string.Concat(new object[]
						{
							Session.GetHabbo().Username,
							Convert.ToChar(9),
							DateTime.Now.Day,
							"-",
							DateTime.Now.Month,
							"-",
							DateTime.Now.Year,
							Convert.ToChar(9),
							ExtraData
						});
                            break;
                        case InteractionType.rentals:
                            goto IL_C41;
                        case InteractionType.pet0:
                        case InteractionType.pet1:
                        case InteractionType.pet2:
                        case InteractionType.pet3:
                        case InteractionType.pet4:
                        case InteractionType.pet5:
                        case InteractionType.pet6:
                        case InteractionType.pet7:
                        case InteractionType.pet8:
                        case InteractionType.pet9:
                        case InteractionType.pet10:
                        case InteractionType.pet11:
                        case InteractionType.pet12:
                        case InteractionType.pet13:
                        case InteractionType.pet14:
                        case InteractionType.pet15:
                        case InteractionType.pet16:
                        case InteractionType.pet17:
                        case InteractionType.pet18:
                        case InteractionType.pet19:
                        case InteractionType.pet20:
                        case InteractionType.pet21:
                        case InteractionType.pet22:
                        case InteractionType.pet23:
                        case InteractionType.pet24:
                        case InteractionType.pet25:
                        case InteractionType.pet26:
                            try
                            {
                                string[] array2 = ExtraData.Split(new char[]
							{
								'\n'
							});
                                string petName = array2[0];
                                string text2 = array2[1];
                                string text3 = array2[2];
                                int.Parse(text2);
                                if (!Catalog.CheckPetName(petName))
                                {
                                    return;
                                }
                                if (text2.Length != 1)
                                {
                                    return;
                                }
                                if (text3.Length != 6)
                                {
                                    return;
                                }
                                MercuryEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_PetLover", 1, false);
                                break;
                            }
                            catch (Exception ex)
                            {
                                Logging.WriteLine(ex.ToString(), ConsoleColor.Gray);
                                Logging.HandleException(ex, "Catalog.HandlePurchase");
                                return;
                            }
                        default:
                            switch (interactionType)
                            {
                                case InteractionType.mannequin:
                                    ExtraData = string.Concat(new object[]
								{
									"m",
									Convert.ToChar(5),
									"ch-215-92.lg-3202-1322-73",
									Convert.ToChar(5),
									"Mannequin"
								});
                                    break;
                                case InteractionType.vip_gate:
                                case InteractionType.mystery_box:
                                case InteractionType.youtubetv:
                                case InteractionType.tilestackmagic:
                                case InteractionType.tent:
                                case InteractionType.bedtent:
                                    goto IL_DF5;
                                case InteractionType.badge_display:
                                    if (!Session.GetHabbo().GetBadgeComponent().HasBadge(ExtraData))
                                        ExtraData = "UMAD";
                                    break;
                                case InteractionType.fbgate:
                                    ExtraData = "hd-99999-99999.lg-270-62;hd-99999-99999.ch-630-62.lg-695-62";
                                    break;

                                case InteractionType.lovelock:
                                    ExtraData = "0";
                                break;

                                case InteractionType.pinata:
                                case InteractionType.runwaysage:
                                case InteractionType.shower:
                                    ExtraData = "0";
                                    break;
                                case InteractionType.groupforumterminal:
                                case InteractionType.gld_item:
                                case InteractionType.gld_gate:
                                case InteractionType.poster:
                                    break;
                                case InteractionType.moplaseed:
                                    ExtraData = new Random().Next(0, 12).ToString();
                                    break;
                                case InteractionType.musicdisc:
                                    text = SongManager.GetCodeById((uint)item.songID);
                                    SongData song = SongManager.GetSongById((uint)item.songID);
                                    ExtraData = string.Concat(new object[]
							    {
								    Session.GetHabbo().Username,
								    '\n',
								    DateTime.Now.Year,
								    '\n',
								    DateTime.Now.Month,
								    '\n',
								    DateTime.Now.Day,
								    '\n',
								    song.LengthSeconds,
								    '\n',
								    song.Name
							    });
                                    break;
                                default:
                                    goto IL_DF5;
                            }
                            break;
                    }
                IL_DFC:
                    Session.GetMessageHandler().GetResponse().Init(Outgoing.UpdateInventoryMessageComposer);
                    Session.GetMessageHandler().SendResponse();
                    Session.SendMessage(CatalogPacket.PurchaseOK());
                    if (IsGift)
                    {
                        Item itemBySprite = MercuryEnvironment.GetGame().GetItemManager().GetItemBySprite(GiftSpriteId, 's');

                        if (itemBySprite == null)
                        {
                            return;
                        }

                        GameClient clientByUserID = MercuryEnvironment.GetGame().GetClientManager().GetClientByUserID(num3);
                        uint num7;
                        using (IQueryAdapter queryreactor4 = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            queryreactor4.setQuery(string.Concat(new object[]
							{
								"INSERT INTO items (base_item,user_id) VALUES (",
								itemBySprite.ItemId,
								", ",
								num3,
								")"
							}));
                            num7 = (uint)queryreactor4.insertQuery();
                            queryreactor4.setQuery(string.Concat(new object[]
							{
								"INSERT INTO user_gifts (gift_id,item_id,extradata,giver_name,message,ribbon,color,gift_sprite,show_sender,rare_id) VALUES (",
								num7,
								", ",
								item.GetBaseItem(current2).ItemId,
								",@extradata, @name, @message,",
								GiftLazo,
								",",
								GiftColor,
								",",
								GiftSpriteId,
								",",
								undef ? 1 : 0,
								",",
								num2,
								")"
							}));
                            queryreactor4.addParameter("extradata", ExtraData);
                            queryreactor4.addParameter("name", GiftUser);
                            queryreactor4.addParameter("message", GiftMessage);
                            queryreactor4.runQuery();
                            if (Session.GetHabbo().Id != num3)
                            {
                                queryreactor4.runFastQuery(string.Concat(new object[]
								{
									"UPDATE user_stats SET gifts_given = gifts_given + 1 WHERE id = ",
									Session.GetHabbo().Id,
									" LIMIT 1;UPDATE user_stats SET gifts_received = gifts_received + 1 WHERE id = ",
									num3,
									" LIMIT 1"
								}));
                            }
                        }
                        if (clientByUserID.GetHabbo().Id != Session.GetHabbo().Id)
                        {
                            MercuryEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_GiftGiver", 1, false);
                            MercuryEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.GIFT_OTHERS, 0u);
                        }
                        if (clientByUserID != null)
                        {
                            UserItem userItem = clientByUserID.GetHabbo().GetInventoryComponent().AddNewItem(num7, itemBySprite.ItemId, string.Concat(new object[]
							{
								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, "");
                       //     clientByUserID.GetHabbo().GetInventoryComponent().SendFloorInventoryUpdate();
                          /*  clientByUserID.GetMessageHandler().GetResponse().Init(Outgoing.NewInventoryObjectMessageComposer);
                            clientByUserID.GetMessageHandler().GetResponse().AppendInt32(1);
                            clientByUserID.GetMessageHandler().GetResponse().AppendInt32(1);
                            clientByUserID.GetMessageHandler().GetResponse().AppendInt32(1);
                            clientByUserID.GetMessageHandler().GetResponse().AppendUInt(userItem.Id);
                            clientByUserID.GetMessageHandler().SendResponse();*/
                           if (clientByUserID.GetHabbo().Id != Session.GetHabbo().Id)
                            {
                                MercuryEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(clientByUserID, "ACH_GiftReceiver", 1, false);
                            }
                        }
                        Session.GetHabbo().LastGiftPurchaseTime = DateTime.Now;
                        continue;
                    }
                    Session.GetMessageHandler().GetResponse().Init(Outgoing.NewInventoryObjectMessageComposer);
                    Session.GetMessageHandler().GetResponse().AppendInt32(1);
                    int i = 1;
                    if (item.GetBaseItem(current2).Type.ToString().ToLower().Equals("s"))
                    {
                        if (item.GetBaseItem(current2).InteractionType == InteractionType.pet1 || item.GetBaseItem(current2).InteractionType == InteractionType.pet2 || item.GetBaseItem(current2).InteractionType == InteractionType.pet3 || item.GetBaseItem(current2).InteractionType == InteractionType.pet4 || item.GetBaseItem(current2).InteractionType == InteractionType.pet5 || item.GetBaseItem(current2).InteractionType == InteractionType.pet6 || item.GetBaseItem(current2).InteractionType == InteractionType.pet7 || item.GetBaseItem(current2).InteractionType == InteractionType.pet8 || item.GetBaseItem(current2).InteractionType == InteractionType.pet9 || item.GetBaseItem(current2).InteractionType == InteractionType.pet10 || item.GetBaseItem(current2).InteractionType == InteractionType.pet11 || item.GetBaseItem(current2).InteractionType == InteractionType.pet12 || item.GetBaseItem(current2).InteractionType == InteractionType.pet13 || item.GetBaseItem(current2).InteractionType == InteractionType.pet14 || item.GetBaseItem(current2).InteractionType == InteractionType.pet15 || item.GetBaseItem(current2).InteractionType == InteractionType.pet16 || item.GetBaseItem(current2).InteractionType == InteractionType.pet17 || item.GetBaseItem(current2).InteractionType == InteractionType.pet18)
                        {
                            i = 3;
                        }
                        else
                        {
                            i = 1;
                        }
                    }
                    Session.GetMessageHandler().GetResponse().AppendInt32(i);
                    List<UserItem> list = this.DeliverItems(Session, item.GetBaseItem(current2), priceAmount * item.Items[current2], ExtraData, num2, limtot, text);
                    Session.GetMessageHandler().GetResponse().AppendInt32(list.Count);
                    foreach (UserItem current3 in list)
                    {
                        Session.GetMessageHandler().GetResponse().AppendUInt(current3.Id);
                    }
                    Session.GetMessageHandler().SendResponse();
                    Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
                    if (item.GetBaseItem(current2).InteractionType == InteractionType.pet1 || item.GetBaseItem(current2).InteractionType == InteractionType.pet2 || item.GetBaseItem(current2).InteractionType == InteractionType.pet3 || item.GetBaseItem(current2).InteractionType == InteractionType.pet4 || item.GetBaseItem(current2).InteractionType == InteractionType.pet5 || item.GetBaseItem(current2).InteractionType == InteractionType.pet6 || item.GetBaseItem(current2).InteractionType == InteractionType.pet7 || item.GetBaseItem(current2).InteractionType == InteractionType.pet8 || item.GetBaseItem(current2).InteractionType == InteractionType.pet9 || item.GetBaseItem(current2).InteractionType == InteractionType.pet10 || item.GetBaseItem(current2).InteractionType == InteractionType.pet11 || item.GetBaseItem(current2).InteractionType == InteractionType.pet12 || item.GetBaseItem(current2).InteractionType == InteractionType.pet13 || item.GetBaseItem(current2).InteractionType == InteractionType.pet14 || item.GetBaseItem(current2).InteractionType == InteractionType.pet15 || item.GetBaseItem(current2).InteractionType == InteractionType.pet16 || item.GetBaseItem(current2).InteractionType == InteractionType.pet17 || item.GetBaseItem(current2).InteractionType == InteractionType.pet18)
                    {
                        Session.SendMessage(Session.GetHabbo().GetInventoryComponent().SerializePetInventory());
                        continue;
                    }
                    continue;
                IL_C41:
                    ExtraData = item.ExtraData;
                    goto IL_DFC;
                IL_DF5:
                    ExtraData = "";
                    goto IL_DFC;
                }
                if (item.Badge.Length >= 1)
                {
                    Session.GetHabbo().GetBadgeComponent().GiveBadge(item.Badge, true, Session, false);
                }
            }
        }
コード例 #29
0
		internal void BanUser(GameClient Client, string Moderator, double LengthSeconds, string Reason, bool IpBan, bool Machine)
		{
			ModerationBanType type = ModerationBanType.USERNAME;
			string text = Client.GetHabbo().Username;
			string query = "user";
			double num = (double)MercuryEnvironment.GetUnixTimestamp() + LengthSeconds;
			if (IpBan)
			{
				type = ModerationBanType.IP;
				using (IQueryAdapter queryreactor = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
				{
					queryreactor.setQuery("SELECT ip_last FROM users WHERE username='******' LIMIT 1");
					text = queryreactor.getString();
				}
				query = "ip";
			}
			if (Machine)
			{
				type = ModerationBanType.MACHINE;
				query = "machine";
				text = Client.MachineId;
			}
			ModerationBan moderationBan = new ModerationBan(type, text, Reason, num);
			if (moderationBan.Type == ModerationBanType.IP)
			{
                if (this.bannedIPs.Contains(text))
				{
					this.bannedIPs[text] = moderationBan;
				}
				else
				{
					this.bannedIPs.Add(text, moderationBan);
				}
			}
			else
			{
				if (moderationBan.Type == ModerationBanType.MACHINE)
				{
					if (this.bannedMachines.ContainsKey(text))
					{
						this.bannedMachines[text] = moderationBan;
					}
					else
					{
						this.bannedMachines.Add(text, moderationBan);
					}
				}
				else
				{
                    if (this.bannedUsernames.Contains(text))
					{
						this.bannedUsernames[text] = moderationBan;
					}
					else
					{
						this.bannedUsernames.Add(text, moderationBan);
					}
				}
			}
			using (IQueryAdapter queryreactor2 = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
			{
				queryreactor2.setQuery(string.Concat(new object[]
				{
					"INSERT INTO bans (bantype,value,reason,expire,added_by,added_date) VALUES (@rawvar,@var,@reason,'",
					num,
					"',@mod,'",
					DateTime.Now.ToLongDateString(),
					"')"
				}));
				queryreactor2.addParameter("rawvar", query);
				queryreactor2.addParameter("var", text);
				queryreactor2.addParameter("reason", Reason);
				queryreactor2.addParameter("mod", Moderator);
				queryreactor2.runQuery();
			}
			if (IpBan)
			{
				DataTable dataTable = null;
				using (IQueryAdapter queryreactor3 = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
				{
					queryreactor3.setQuery("SELECT id FROM users WHERE ip_last = @var");
					queryreactor3.addParameter("var", text);
					dataTable = queryreactor3.getTable();
				}
				if (dataTable != null)
				{
					using (IQueryAdapter queryreactor4 = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
					{
						foreach (DataRow dataRow in dataTable.Rows)
						{
							queryreactor4.runFastQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = " + Convert.ToUInt32(dataRow["id"]));
						}
					}
				}
				this.BanUser(Client, Moderator, LengthSeconds, Reason, false, false);
				return;
			}
			using (IQueryAdapter queryreactor5 = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
			{
				queryreactor5.runFastQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = " + Client.GetHabbo().Id);
			}
			Client.Disconnect();
		}
コード例 #30
0
ファイル: JukeboxComposer.cs プロジェクト: BjkGkh/Mercury
		internal static ServerMessage Compose(GameClient Session)
		{
			return Session.GetHabbo().GetInventoryComponent().SerializeMusicDiscs();
		}