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


C# GameClient.GetMessageHandler方法代码示例

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


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

示例1: SellItem

        internal static void SellItem(GameClient Session, uint ItemId, int SellingPrice)
        {
            UserItem Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);

            if (Item == null || SellingPrice > 10000 || !CanSellItem(Item))
            {
                Session.GetMessageHandler().GetResponse().Init(610);
                Session.GetMessageHandler().GetResponse().AppendBoolean(false);
                Session.GetMessageHandler().GetResponse();
                Session.GetMessageHandler().SendResponse();
                return;
            }

            int Comission = CalculateComissionPrice(SellingPrice);
            int TotalPrice = SellingPrice + Comission;
            int ItemType = 1;

            if (Item.GetBaseItem().Type == 'i')
                ItemType++;

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("INSERT INTO catalog_marketplace_offers (item_id,user_id,asking_price,total_price,public_name,sprite_id,item_type,timestamp,extra_data) VALUES (" + Item.BaseItem + "," + Session.GetHabbo().Id + "," + SellingPrice + "," + TotalPrice + ",@public_name," + Item.GetBaseItem().SpriteId + "," + ItemType + "," + FirewindEnvironment.GetUnixTimestamp() + ",@extra_data)");
                dbClient.addParameter("public_name", "NEEDS REPLACMENT HERE");
                dbClient.addParameter("extra_data", Item.Data);
                dbClient.runQuery();
            }

            Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId, false);
            Session.GetHabbo().GetInventoryComponent().RunDBUpdate();

            Session.GetMessageHandler().GetResponse().Init(610);
            Session.GetMessageHandler().GetResponse().AppendBoolean(true);
            Session.GetMessageHandler().SendResponse();
        }
开发者ID:Kristopher-RZ,项目名称:Firewind,代码行数:35,代码来源:Marketplace.cs

示例2: HandlePurchase

        internal void HandlePurchase(GameClient Session, int PageId, uint ItemId, string extraParameter, int buyAmount, Boolean IsGift, string GiftUser, string GiftMessage, int GiftSpriteId, int GiftLazo, int GiftColor, bool giftShowIdentity)
        {
            int finalAmount = buyAmount;
            if (buyAmount > 5) // Possible discount!
            {
                // Nearest number that increases the amount of free items
                int nearestDiscount = ((int)Math.Floor(buyAmount / 6.0) * 6);

                // How many free ones we get
                int freeItemsCount = (nearestDiscount - 3) / 3;

                // Add 1 free if more than 42
                if (buyAmount >= 42)
                    freeItemsCount++;

                // Doesn't follow rules as it isn't dividable by 6, but still increases free items
                if (buyAmount >= 99)
                {
                    freeItemsCount = 33;
                }

                // This is how many we pay for in the end
                finalAmount = buyAmount - freeItemsCount;
            }

            //Logging.WriteLine("Amount: " + priceAmount + "; withOffer= " + finalAmount);
            CatalogPage Page;
            if (!Pages.TryGetValue(PageId, out Page))
                return;
            if (Page == null || !Page.Enabled || !Page.Visible || Session == null || Session.GetHabbo() == null)
            {
                Session.SendMessage(new ServerMessage(Outgoing.PurchaseError));
                return;
            }
            if (Page.ClubOnly && !Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club") && !Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip"))
            {
                Session.SendMessage(new ServerMessage(Outgoing.PurchaseError));
                return;
            }
            if (Page.MinRank > Session.GetHabbo().Rank)
            {
                Session.SendMessage(new ServerMessage(Outgoing.PurchaseError));
                return;
            }
            CatalogItem Item = Page.GetItem(ItemId);

            if (Item == null) // TODO: Check item minimum club rank
            {
                Session.SendMessage(new ServerMessage(Outgoing.PurchaseError));
                return;
            }
            if (!Item.HaveOffer && buyAmount > 1) // Check if somebody is bulk-buying when not allowed
            {
                Session.SendMessage(new ServerMessage(Outgoing.PurchaseError));
                return;
            }
            if (Item.IsLimited && Item.LimitedStack <= Item.LimitedSelled)
            {
                Session.SendMessage(new ServerMessage(Outgoing.PurchaseError));
                return;
            }

            uint GiftUserId = 0;
            //int giftWrappingCost = 0;
            if (IsGift)
            {
                if(!Item.AllowGift)
                {
                    Session.SendMessage(new ServerMessage(Outgoing.PurchaseError));
                    return;
                }
                if(Item.Items.Count > 1 || Item.Amount > 1) // Gifts can only have 1 item?
                {
                    Session.SendMessage(new ServerMessage(Outgoing.PurchaseError));
                    return;
                }

                DataRow dRow;
                using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT id FROM users WHERE username = @gift_user");
                    dbClient.addParameter("gift_user", GiftUser);

                    dRow = dbClient.getRow();
                }

                if (dRow == null)
                {
                    Session.GetMessageHandler().GetResponse().Init(Outgoing.GiftError);
                    Session.GetMessageHandler().GetResponse().AppendString(GiftUser);
                    Session.GetMessageHandler().SendResponse();

                    return;
                }

                GiftUserId = Convert.ToUInt32(dRow[0]);

                if (GiftUserId == 0)
                {
                    Session.GetMessageHandler().GetResponse().Init(Outgoing.GiftError);
//.........这里部分代码省略.........
开发者ID:TheNaked,项目名称:Firewind,代码行数:101,代码来源:Catalog.cs

示例3: OnTrigger

        internal override bool OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            Room Room = Session.GetHabbo().CurrentRoom;
            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            MapStuffData data = (MapStuffData)Item.data;

            string figure = data.Data["FIGURE"];
            string gender = data.Data["GENDER"];

            // We gotta keep our skin and headgear!
            string filteredLook = "";
            string[] sp = Session.GetHabbo().Look.Split('.');
            foreach (string s in sp)
            {
                if ((s.StartsWith("hd") || s.StartsWith("ha") || s.StartsWith("he") || s.StartsWith("fa") || s.StartsWith("ea") || s.StartsWith("hr")))
                {
                    filteredLook += s + ".";
                }
            }
            filteredLook += figure;

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {

                dbClient.setQuery("UPDATE users SET gender = @gender, look = @look WHERE id = @id");
                dbClient.addParameter("id", Session.GetHabbo().Id);
                dbClient.addParameter("gender", gender);
                dbClient.addParameter("look", filteredLook);
                dbClient.runQuery();
            }

            Session.GetHabbo().Look = filteredLook;
            Session.GetHabbo().Gender = gender;

            Session.GetMessageHandler().GetResponse().Init(Outgoing.UpdateUserInformation);
            Session.GetMessageHandler().GetResponse().AppendInt32(-1);
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Session.GetHabbo().Look);
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Session.GetHabbo().Gender.ToLower());
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Session.GetHabbo().Motto);
            Session.GetMessageHandler().GetResponse().AppendInt32(Session.GetHabbo().AchievementPoints);
            Session.GetMessageHandler().SendResponse();

            ServerMessage RoomUpdate = new ServerMessage(Outgoing.UpdateUserInformation);
            RoomUpdate.AppendInt32(User.VirtualId);
            RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Look);
            RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Gender.ToLower());
            RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Motto);
            RoomUpdate.AppendInt32(Session.GetHabbo().AchievementPoints);
            Room.SendMessage(RoomUpdate);

            return true;
        }
开发者ID:TheNaked,项目名称:Firewind,代码行数:52,代码来源:FurniInteractor.cs

示例4: RemoveUserFromRoom

        internal void RemoveUserFromRoom(GameClient Session, Boolean NotifyClient, Boolean NotifyKick)
        {
            try
            {
                if (Session == null)
                    return;

                if (Session.GetHabbo() == null)
                    return;

                Session.GetHabbo().GetAvatarEffectsInventoryComponent().OnRoomExit();

                if (NotifyClient)
                {
                    if (NotifyKick)
                    {
                        Session.GetMessageHandler().GetResponse().Init(Outgoing.GenericError);
                        Session.GetMessageHandler().GetResponse().AppendInt32(4008);
                        Session.GetMessageHandler().SendResponse();
                    }

                    Session.GetMessageHandler().GetResponse().Init(Outgoing.OutOfRoom);
                    Session.GetMessageHandler().SendResponse();
                }

                RoomUser User = GetRoomUserByHabbo(Session.GetHabbo().Id);

                if (User != null)
                {
                    if (User.team != Team.none)
                    {
                        room.GetTeamManagerForBanzai().OnUserLeave(User);
                        room.GetTeamManagerForFreeze().OnUserLeave(User);
                    }
                    if (User.isMounted == true)
                    {
                        User.isMounted = false;
                        RoomUser usuarioVinculado = GetRoomUserByVirtualId((int)User.mountID);
                        if (usuarioVinculado != null)
                        {
                            usuarioVinculado.isMounted = false;
                            usuarioVinculado.mountID = 0;

                        }
                    }

                    if (User.sentadoBol == true || User.acostadoBol == true)
                    {
                        User.sentadoBol = false;
                        User.acostadoBol = false;
                    }

                    RemoveRoomUser(User);

                    if (Session.GetHabbo() != null)
                    {
                        if (!User.IsSpectator)
                        {
                            if (User.CurrentItemEffect != ItemEffectType.None)
                            {
                                User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().CurrentEffect = -1;
                            }
                            //UserMatrix[User.X, User.Y] = false;

                            if (Session.GetHabbo() != null)
                            {
                                if (room.HasActiveTrade(Session.GetHabbo().Id))
                                    room.TryStopTrade(Session.GetHabbo().Id);

                                if (Session.GetHabbo().Username == room.Owner)
                                {
                                    if (room.HasOngoingEvent)
                                    {
                                        ServerMessage Message = new ServerMessage(Outgoing.RoomEvent);
                                        Message.AppendStringWithBreak("-1");
                                        room.SendMessage(Message);

                                        FirewindEnvironment.GetGame().GetRoomManager().GetEventManager().QueueRemoveEvent(room.RoomData, room.Event.Category);
                                        room.Event = null;
                                    }
                                }
                                Session.GetHabbo().CurrentRoomId = 0;

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

                            //DateTime Start = DateTime.Now;
                            //using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                            //{
                            //    //TimeSpan TimeUsed1 = DateTime.Now - Start;
                            //    //Logging.LogThreadException("Time used on sys part 2: " + TimeUsed1.Seconds + "s, " + TimeUsed1.Milliseconds + "ms", "");

                            //    //if (Session.GetHabbo() != null)
                            //    //    dbClient.runFastQuery("UPDATE user_roomvisits SET exit_timestamp = '" + FirewindEnvironment.GetUnixTimestamp() + "' WHERE room_id = '" + this.Id + "' AND user_id = '" + Id + "' ORDER BY exit_timestamp DESC LIMIT 1");
                            //    //dbClient.runFastQuery("UPDATE rooms SET users_now = " + UsersNow + " WHERE id = " + Id);
//.........这里部分代码省略.........
开发者ID:TheNaked,项目名称:Firewind,代码行数:101,代码来源:RoomUserManager.cs


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