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