本文整理汇总了C#中Butterfly.HabboHotel.GameClients.GameClient.GetMessageHandler方法的典型用法代码示例。如果您正苦于以下问题:C# GameClient.GetMessageHandler方法的具体用法?C# GameClient.GetMessageHandler怎么用?C# GameClient.GetMessageHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Butterfly.HabboHotel.GameClients.GameClient
的用法示例。
在下文中一共展示了GameClient.GetMessageHandler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
{
if (dbClient.dbType == DatabaseType.MSSQL)
dbClient.setQuery("INSERT INTO catalog_marketplace_offers (item_id,user_id,asking_price,total_price,public_name,sprite_id,item_type,timestamp,extra_data,state) VALUES (" + Item.BaseItem + "," + Session.GetHabbo().Id + "," + SellingPrice + "," + TotalPrice + ",@public_name," + Item.GetBaseItem().SpriteId + "," + ItemType + "," + ButterflyEnvironment.GetUnixTimestamp() + ",@extra_data, '1')");
else
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 + "," + ButterflyEnvironment.GetUnixTimestamp() + ",@extra_data)");
dbClient.addParameter("public_name", Item.GetBaseItem().PublicName);
dbClient.addParameter("extra_data", Item.ExtraData);
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();
}
示例2: HandlePurchase
internal void HandlePurchase(GameClient Session, int PageId, uint ItemId, string ExtraData, Boolean IsGift, string GiftUser, string GiftMessage)
{
CatalogPage Page;
if (!Pages.TryGetValue(PageId, out Page))
return;
if (Page == null || Page.ComingSoon || !Page.Enabled || !Page.Visible || Session == null || Session.GetHabbo() == null)
{
return;
}
if (Page.ClubOnly && !Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club"))
{
return;
}
if (Session.GetHabbo().Rank != Page.MinRank) // Workaround
{
if (Session.GetHabbo().Rank < Page.MinRank)
{
return;
}
}
CatalogItem Item = Page.GetItem(ItemId);
if (Item == null)
{
return;
}
uint GiftUserId = 0;
if (IsGift)
{
if (!Item.GetBaseItem().AllowGift)
{
return;
}
DataRow dRow;
using (IQueryAdapter dbClient = ButterflyEnvironment.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(76);
Session.GetMessageHandler().GetResponse().AppendBoolean(true);
Session.GetMessageHandler().GetResponse().AppendStringWithBreak(GiftUser);
Session.GetMessageHandler().SendResponse();
return;
}
GiftUserId = Convert.ToUInt32(dRow[0]);
if (GiftUserId == 0)
{
Session.GetMessageHandler().GetResponse().Init(76);
Session.GetMessageHandler().GetResponse().AppendBoolean(true);
Session.GetMessageHandler().GetResponse().AppendStringWithBreak(GiftUser);
Session.GetMessageHandler().SendResponse();
return;
}
}
Boolean CreditsError = false;
Boolean PixelError = false;
if (Session.GetHabbo().Credits < Item.CreditsCost)
{
CreditsError = true;
}
if (Session.GetHabbo().ActivityPoints < Item.PixelsCost)
{
PixelError = true;
}
if (CreditsError || PixelError)
{
Session.GetMessageHandler().GetResponse().Init(68);
Session.GetMessageHandler().GetResponse().AppendBoolean(CreditsError);
Session.GetMessageHandler().GetResponse().AppendBoolean(PixelError);
Session.GetMessageHandler().SendResponse();
return;
}
if (IsGift && Item.GetBaseItem().Type == 'e')
{
Session.SendNotif(LanguageLocale.GetValue("catalog.gift.send.error"));
return;
}
if (Item.CrystalCost > 0)
//.........这里部分代码省略.........
示例3: DeliverItems
//.........这里部分代码省略.........
{
dbClient.runFastQuery("INSERT INTO items_tele_links (tele_one_id,tele_two_id) VALUES (" + idOne + "," + idTwo + ")");
dbClient.runFastQuery("INSERT INTO items_tele_links (tele_one_id,tele_two_id) VALUES (" + idTwo + "," + idOne + ")");
}
break;
case InteractionType.dimmer:
uint id = Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, ExtraData, true, false, 0).Id;
using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
{
dbClient.runFastQuery("INSERT INTO items_moodlight (item_id,enabled,current_preset,preset_one,preset_two,preset_three) VALUES (" + id + ",0,1,'#000000,255,0','#000000,255,0','#000000,255,0')");
}
break;
case InteractionType.musicdisc:
{
Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, songID.ToString(), true, false, songID);
break;
}
default:
Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, ExtraData, true, false, songID);
break;
}
}
Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
break;
case "e":
for (int i = 0; i < Amount; i++)
{
Session.GetHabbo().GetAvatarEffectsInventoryComponent().AddEffect(Item.SpriteId, 3600);
}
break;
case "h":
for (int i = 0; i < Amount; i++)
{
Session.GetHabbo().GetSubscriptionManager().AddOrExtendSubscription("habbo_club", 2678400);
}
if (!Session.GetHabbo().GetBadgeComponent().HasBadge("HC1"))
{
Session.GetHabbo().GetBadgeComponent().GiveBadge("HC1", true);
}
Session.GetMessageHandler().GetResponse().Init(7);
Session.GetMessageHandler().GetResponse().AppendStringWithBreak("habbo_club");
if (Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club"))
{
Double Expire = Session.GetHabbo().GetSubscriptionManager().GetSubscription("habbo_club").ExpireTime;
Double TimeLeft = Expire - ButterflyEnvironment.GetUnixTimestamp();
int TotalDaysLeft = (int)Math.Ceiling(TimeLeft / 86400);
int MonthsLeft = TotalDaysLeft / 31;
if (MonthsLeft >= 1) MonthsLeft--;
Session.GetMessageHandler().GetResponse().AppendInt32(TotalDaysLeft - (MonthsLeft * 31));
Session.GetMessageHandler().GetResponse().AppendBoolean(true);
Session.GetMessageHandler().GetResponse().AppendInt32(MonthsLeft);
}
else
{
for (int i = 0; i < 3; i++)
{
Session.GetMessageHandler().GetResponse().AppendInt32(0);
}
}
Session.GetMessageHandler().SendResponse();
List<string> Rights = ButterflyEnvironment.GetGame().GetRoleManager().GetRightsForHabbo(Session.GetHabbo());
Session.GetMessageHandler().GetResponse().Init(2);
Session.GetMessageHandler().GetResponse().AppendInt32(Rights.Count);
foreach (string Right in Rights)
{
Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Right);
}
Session.GetMessageHandler().SendResponse();
ButterflyEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_BasicClub", 1); //ACH_VipClub
break;
default:
Session.SendNotif(LanguageLocale.GetValue("catalog.buyerror"));
break;
}
}
示例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(33);
Session.GetMessageHandler().GetResponse().AppendInt32(4008);
Session.GetMessageHandler().SendResponse();
}
Session.GetMessageHandler().GetResponse().Init(18);
Session.GetMessageHandler().SendResponse();
}
RoomUser User = GetRoomUserByHabbo(Session.GetHabbo().Id);
if (User != null)
{
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)
{
room.Event = new RoomEvent(0, null, null, 0, new List<string>());
ServerMessage Message = new ServerMessage(370);
Message.AppendStringWithBreak("-1");
room.SendMessage(Message);
ButterflyEnvironment.GetGame().GetRoomManager().GetEventManager().QueueRemoveEvent(room.RoomData, room.Event.Category);
}
}
Session.GetHabbo().CurrentRoomId = 0;
if (Session.GetHabbo().GetMessenger() != null)
Session.GetHabbo().GetMessenger().OnStatusChanged(true);
}
//DateTime Start = DateTime.Now;
//using (IQueryAdapter dbClient = ButterflyEnvironment.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 = '" + ButterflyEnvironment.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);
// //dbClient.runFastQuery("REPLACE INTO room_active VALUES (" + RoomId + ", " + UsersNow + ")");
// dbClient.runFastQuery("UPDATE room_active SET active_users = " + UsersNow);
//}
}
}
usersByUserID.Remove(User.userID);
if (Session.GetHabbo() != null)
usersByUsername.Remove(Session.GetHabbo().Username.ToLower());
User.Dispose();
}
}
catch (Exception e)
{
Logging.LogCriticalException("Error during removing user from room:" + e.ToString());
}
}
示例5: HandlePurchase
//.........这里部分代码省略.........
Days = int.Parse(Item.catalogName.Split('_')[3]);
}
else if (Item.catalogName.Contains("_MONTH"))
{
Days = 31 * int.Parse(Item.catalogName.Split('_')[3]);
}
}
else if (Item.catalogName.Equals("deal_vip_1_year_and_badge"))
{
Days = 31 * 12;
}
else if (Item.catalogName.Equals("HABBO_CLUB_VIP_5_YEAR"))
{
Days = 31 * 5 * 12;
}
if (Item.creditCost > 0)
{
Session.GetHabbo().Credits -= total_cost_credits;
Session.GetHabboDataContainer().UpdateCreditsBalance();
}
if (Item.pixelCost > 0 || Item.diamondCost > 0)
{
Session.GetHabbo().Diamonds -= total_cost_diamonds;
Session.GetHabbo().ActivityPoints -= total_cost_pixels;
Session.GetHabboDataContainer().UpdateActivityPointsBalance();
Session.GetHabboDataContainer().StoreDiamondsNow();
}
Session.GetHabboDataContainer().GetSubscriptionManager().AddOrExtendSubscription(Days * 24 * 3600, SubscriptionManager.SUBSCRIPTION_TYPE_VIP);
//Session.GetHabboDataContainer().SerializeClub();
Session.GetMessageHandler().GetSubscriptionData();
ServerMessage ok = PacketHandelingManager.GetRecycledItem(OutputCode.PurchaseOKMessageEvent);
ok.AddInt32((int)Item.GetBaseItem().ItemId);
ok.AddString(Item.GetBaseItem().Name);
ok.AddBoolean(false);
ok.AddInt32(total_cost_credits);
ok.AddInt32(Item.pixelCost);
ok.AddInt32(0);
ok.AddBoolean(true);
ok.AddInt32(1);
ok.AddString(Item.GetBaseItem().Type.ToString().ToLower());
ok.AddInt32(Item.GetBaseItem().SpriteId);
ok.AddString(string.Empty);
ok.AddInt32(1);
ok.AddInt32(0);
ok.AddString(string.Empty);
ok.AddInt32(1);
Session.SendMessage(ok);
Session.GetHabboDataContainer().SerializeClub();
return;
}
switch (Item.GetBaseItem().InteractionType)
{
case InteractionType.groupClickable:
case InteractionType.groupGate:
case InteractionType.none:
if (Item.GetBaseItem().IsGroupItem)
{
uint groupID = TextHandling.ParseUInt32(ExtraData);