当前位置: 首页>>代码示例>>C#>>正文


C# ServerMessage.SaveArray方法代码示例

本文整理汇总了C#中ServerMessage.SaveArray方法的典型用法代码示例。如果您正苦于以下问题:C# ServerMessage.SaveArray方法的具体用法?C# ServerMessage.SaveArray怎么用?C# ServerMessage.SaveArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ServerMessage的用法示例。


在下文中一共展示了ServerMessage.SaveArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateBadges

        /// <summary>
        ///     Updates the badges.
        /// </summary>
        internal void UpdateBadges()
        {
            Session.GetHabbo().GetBadgeComponent().ResetSlots();

            using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                commitableQueryReactor.RunFastQuery(
                    $"UPDATE users_badges SET badge_slot = 0 WHERE user_id = {Session.GetHabbo().Id}");

            for (int i = 0; i < 5; i++)
            {
                int slot = Request.GetInteger();
                string code = Request.GetString();

                if (code.Length == 0)
                    continue;

                if (!Session.GetHabbo().GetBadgeComponent().HasBadge(code) || slot < 1 || slot > 5)
                    return;

                Session.GetHabbo().GetBadgeComponent().GetBadge(code).Slot = slot;

                using (IQueryAdapter queryreactor2 = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    queryreactor2.SetQuery("UPDATE users_badges SET badge_slot = " + slot +
                                           " WHERE badge_id = @badge AND user_id = " + Session.GetHabbo().Id);
                    queryreactor2.AddParameter("badge", code);
                    queryreactor2.RunQuery();
                }
            }

            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("UserBadgesMessageComposer"));
            serverMessage.AppendInteger(Session.GetHabbo().Id);

            serverMessage.StartArray();

            foreach (
                Badge badge in
                    Session.GetHabbo().GetBadgeComponent().BadgeList.Values.Cast<Badge>().Where(badge => badge.Slot > 0)
                )
            {
                serverMessage.AppendInteger(badge.Slot);
                serverMessage.AppendString(badge.Code);
                serverMessage.SaveArray();
            }

            serverMessage.EndArray();

            if (Session.GetHabbo().InRoom &&
                Yupi.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId) != null)
                Yupi.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId).SendMessage(serverMessage);
            else
                Session.SendMessage(serverMessage);
        }
开发者ID:weslley17w,项目名称:Yupi,代码行数:56,代码来源:Users.cs

示例2: UpdateBadges

        /// <summary>
        /// Updates the badges.
        /// </summary>
        internal void UpdateBadges()
        {
            Session.GetHabbo().GetBadgeComponent().ResetSlots();
            using (var queryReactor = AzureEmulator.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery(string.Format("UPDATE users_badges SET badge_slot = 0 WHERE user_id = {0}",
                    Session.GetHabbo().Id));
            for (var i = 0; i < 5; i++)
            {
                var slot = Request.GetInteger();
                var code = Request.GetString();
                if (code.Length == 0) continue;
                if (!Session.GetHabbo().GetBadgeComponent().HasBadge(code) || slot < 1 || slot > 5) return;
                Session.GetHabbo().GetBadgeComponent().GetBadge(code).Slot = slot;
                using (var queryreactor2 = AzureEmulator.GetDatabaseManager().GetQueryReactor())
                {
                    queryreactor2.SetQuery("UPDATE users_badges SET badge_slot = " + slot +
                                           " WHERE badge_id = @badge AND user_id = " + Session.GetHabbo().Id);
                    queryreactor2.AddParameter("badge", code);
                    queryreactor2.RunQuery();
                }
            }
            AzureEmulator.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.ProfileBadge, 0);
            var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("UserBadgesMessageComposer"));
            serverMessage.AppendInteger(Session.GetHabbo().Id);

            serverMessage.StartArray();
            foreach (
                var badge in
                    Session.GetHabbo()
                        .GetBadgeComponent()
                        .BadgeList.Values.Cast<Badge>()
                        .Where(badge => badge.Slot > 0))
            {
                serverMessage.AppendInteger(badge.Slot);
                serverMessage.AppendString(badge.Code);

                serverMessage.SaveArray();
            }

            serverMessage.EndArray();
            if (Session.GetHabbo().InRoom &&
                AzureEmulator.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId) != null)
            {
                AzureEmulator.GetGame()
                    .GetRoomManager()
                    .GetRoom(Session.GetHabbo().CurrentRoomId)
                    .SendMessage(serverMessage);
                return;
            }
            Session.SendMessage(serverMessage);
        }
开发者ID:BjkGkh,项目名称:Azure2,代码行数:54,代码来源:Users.cs


注:本文中的ServerMessage.SaveArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。