internal ServerMessage AppendEntrySubmitMessage(ServerMessage message, int status, Room room = null) { message.Init(LibraryParser.OutgoingRequest("CompetitionEntrySubmitResultMessageComposer")); message.AppendInteger(Id); message.AppendString(Name); message.AppendInteger(status); // 0 : roomSent - 1 : send room - 2 : confirm register - 3 : neededFurnis - 4 : doorClosed - 6 : acceptRules if (status != 3) { message.AppendInteger(0); message.AppendInteger(0); } else { message.StartArray(); foreach (string furni in RequiredFurnis) { message.AppendString(furni); message.SaveArray(); } message.EndArray(); if (room == null) message.AppendInteger(0); else { message.StartArray(); foreach (string furni in RequiredFurnis) { if (!room.GetRoomItemHandler().HasFurniByItemName(furni)) { message.AppendString(furni); message.SaveArray(); } } message.EndArray(); } } return message; }
public override bool Execute(GameClient session, string[] pms) { Room room = session.GetHabbo().CurrentRoom; string message = string.Join(" ", pms); foreach (GameClient client in Yupi.GetGame().GetClientManager().Clients.Values) { ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("WhisperMessageComposer")); serverMessage.AppendInteger(room.RoomId); serverMessage.AppendString(message); serverMessage.AppendInteger(0); serverMessage.AppendInteger(36); serverMessage.AppendInteger(0); serverMessage.AppendInteger(-1); client.SendMessage(serverMessage); } return true; }
public override bool Execute(GameClient session, string[] pms) { ushort result; ushort.TryParse(pms[0], out result); if (result > 4) { session.SendWhisper(Yupi.GetLanguage().GetVar("command_dance_false")); result = 0; } ServerMessage message = new ServerMessage(); message.Init(LibraryParser.OutgoingRequest("DanceStatusMessageComposer")); message.AppendInteger(session.CurrentRoomUserId); message.AppendInteger(result); session.GetHabbo().CurrentRoom.SendMessage(message); return true; }
internal static void GenerateMessage(ServerMessage message, TargetedOffer offer) { message.Init(LibraryParser.OutgoingRequest("TargetedOfferMessageComposer")); message.AppendInteger(1); message.AppendInteger(offer.Id); message.AppendString(offer.Identifier); message.AppendString(offer.Identifier); message.AppendInteger(offer.CostCredits); if (offer.CostDiamonds > 0) { message.AppendInteger(offer.CostDiamonds); message.AppendInteger(105); } else { message.AppendInteger(offer.CostDuckets); message.AppendInteger(0); } message.AppendInteger(offer.PurchaseLimit); int timeLeft = offer.ExpirationTime - Yupi.GetUnixTimeStamp(); message.AppendInteger(timeLeft); message.AppendString(offer.Title); message.AppendString(offer.Description); message.AppendString(offer.Image); message.AppendString(string.Empty); message.StartArray(); foreach (string product in offer.Products) { message.AppendString(product); message.SaveArray(); } message.EndArray(); }
/// <summary> /// Serializes the messenger action. /// </summary> /// <param name="type">The type.</param> /// <param name="name">The name.</param> internal void SerializeMessengerAction(int type, string name) { if (GetClient() == null) return; ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("ConsoleMessengerActionMessageComposer")); serverMessage.AppendString(GetClient().GetHabbo().Id.ToString()); serverMessage.AppendInteger(type); serverMessage.AppendString(name); foreach (MessengerBuddy current in Friends.Values.Where(current => current.Client != null)) current.Client.SendMessage(serverMessage); }
/// <summary> /// Handles the <see cref="E:UserAdd" /> event. /// </summary> /// <param name="user"></param> private void OnUserAdd(RoomUser user) { try { if (user?.GetClient() == null || user.GetClient().GetHabbo() == null) return; GameClient client = user.GetClient(); if (client?.GetHabbo() == null || _userRoom == null) return; if (!user.IsSpectator) { DynamicRoomModel model = _userRoom.GetGameMap().Model; if (model == null) return; user.SetPos(model.DoorX, model.DoorY, model.DoorZ); user.SetRot(model.DoorOrientation, false); user.AddStatus(_userRoom.CheckRights(client, true) ? "flatctrl 4" : "flatctrl 1", string.Empty); user.CurrentItemEffect = ItemEffectType.None; if (!user.IsBot && client.GetHabbo().IsTeleporting) { client.GetHabbo().IsTeleporting = false; client.GetHabbo().TeleportingRoomId = 0; RoomItem item = _userRoom.GetRoomItemHandler().GetItem(client.GetHabbo().TeleporterId); if (item != null) { item.ExtraData = "2"; item.UpdateState(false, true); user.SetPos(item.X, item.Y, item.Z); user.SetRot(item.Rot, false); item.InteractingUser2 = client.GetHabbo().Id; item.ExtraData = "0"; item.UpdateState(false, true); } } if (!user.IsBot && client.GetHabbo().IsHopping) { client.GetHabbo().IsHopping = false; client.GetHabbo().HopperId = 0; RoomItem item2 = _userRoom.GetRoomItemHandler().GetItem(client.GetHabbo().HopperId); if (item2 != null) { item2.ExtraData = "1"; item2.UpdateState(false, true); user.SetPos(item2.X, item2.Y, item2.Z); user.SetRot(item2.Rot, false); user.AllowOverride = false; item2.InteractingUser2 = client.GetHabbo().Id; item2.ExtraData = "2"; item2.UpdateState(false, true); } } if (!user.IsSpectator) { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("SetRoomUserMessageComposer")); serverMessage.AppendInteger(1); user.Serialize(serverMessage, _userRoom.GetGameMap().GotPublicPool); _userRoom.SendMessage(serverMessage); } if (!user.IsBot) { ServerMessage serverMessage2 = new ServerMessage(); serverMessage2.Init(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer")); serverMessage2.AppendInteger(user.VirtualId); serverMessage2.AppendString(client.GetHabbo().Look); serverMessage2.AppendString(client.GetHabbo().Gender.ToLower()); serverMessage2.AppendString(client.GetHabbo().Motto); serverMessage2.AppendInteger(client.GetHabbo().AchievementPoints); _userRoom.SendMessage(serverMessage2); } if (_userRoom.RoomData.Owner != client.GetHabbo().UserName) { Yupi.GetGame() .GetAchievementManager() .ProgressUserAchievement(client, "ACH_RoomEntry", 1); } } if (client.GetHabbo().GetMessenger() != null) client.GetHabbo().GetMessenger().OnStatusChanged(true); client.GetMessageHandler().OnRoomUserAdd(); //if (client.GetHabbo().HasFuse("fuse_mod")) client.GetHabbo().GetAvatarEffectsInventoryComponent().ActivateCustomEffect(102); //if (client.GetHabbo().Rank == Convert.ToUInt32(Yupi.GetDbConfig().DbData["ambassador.minrank"])) client.GetHabbo().GetAvatarEffectsInventoryComponent().ActivateCustomEffect(178); if (OnUserEnter != null) OnUserEnter(user, null); if (_userRoom.GotMusicController() && _userRoom.GotMusicController()) _userRoom.GetRoomMusicController().OnNewUserEnter(user); _userRoom.OnUserEnter(user); } catch (Exception ex) { ServerLogManager.LogCriticalException(ex.ToString()); } }
internal bool UserCanWalkInTile(RoomUser roomUsers) { // Check if User CanWalk... if (_userRoom.GetGameMap().CanWalk(roomUsers.SetX, roomUsers.SetY, roomUsers.AllowOverride) || roomUsers.RidingHorse) { // Let's Update his Movement... _userRoom.GetGameMap() .UpdateUserMovement(new Point(roomUsers.Coordinate.X, roomUsers.Coordinate.Y), new Point(roomUsers.SetX, roomUsers.SetY), roomUsers); List<RoomItem> hasItemInPlace = _userRoom.GetGameMap().GetCoordinatedItems(new Point(roomUsers.X, roomUsers.Y)); // Set His Actual X,Y,Z Position... roomUsers.X = roomUsers.SetX; roomUsers.Y = roomUsers.SetY; roomUsers.Z = roomUsers.SetZ; // Check Sub Items Interactionables foreach (RoomItem roomItem in hasItemInPlace.ToArray()) { roomItem.UserWalksOffFurni(roomUsers); switch (roomItem.GetBaseItem().InteractionType) { case Interaction.RunWaySage: case Interaction.ChairState: case Interaction.Shower: case Interaction.PressurePad: case Interaction.PressurePadBed: case Interaction.Guillotine: roomItem.ExtraData = "0"; roomItem.UpdateState(); break; case Interaction.Tent: case Interaction.BedTent: if (!roomUsers.IsBot && roomUsers.OnCampingTent) { ServerMessage serverMessage = new ServerMessage(); serverMessage.Init( LibraryParser.OutgoingRequest("UpdateFloorItemExtraDataMessageComposer")); serverMessage.AppendString(roomItem.Id.ToString()); serverMessage.AppendInteger(0); serverMessage.AppendString("0"); roomUsers.GetClient().SendMessage(serverMessage); roomUsers.OnCampingTent = false; } break; case Interaction.None: break; } } // Let's Update user Status.. UpdateUserStatus(roomUsers, true); return false; } return true; }
/// <summary> /// Serializes the ticket chatlog. /// </summary> /// <param name="ticket">The ticket.</param> /// <param name="roomData">The room data.</param> /// <param name="timestamp">The timestamp.</param> /// <returns>ServerMessage.</returns> /// <exception cref="System.NullReferenceException">No room found.</exception> internal static ServerMessage SerializeTicketChatlog(SupportTicket ticket, RoomData roomData, double timestamp) { ServerMessage message = new ServerMessage(); RoomData room = Yupi.GetGame().GetRoomManager().GenerateRoomData(ticket.RoomId); if (room != null) { message.Init(LibraryParser.OutgoingRequest("ModerationToolIssueChatlogMessageComposer")); message.AppendInteger(ticket.TicketId); message.AppendInteger(ticket.SenderId); message.AppendInteger(ticket.ReportedId); message.AppendInteger(ticket.RoomId); message.AppendByte(1); message.AppendShort(2); message.AppendString("roomName"); message.AppendByte(2); message.AppendString(ticket.RoomName); message.AppendString("roomId"); message.AppendByte(1); message.AppendInteger(ticket.RoomId); List<Chatlog> tempChatlogs = room.RoomChat.Reverse().Skip(Math.Max(0, room.RoomChat.Count() - 60)).Take(60).ToList(); message.AppendShort(tempChatlogs.Count); foreach (Chatlog chatLog in tempChatlogs) chatLog.Serialize(ref message); return message; } return null; }
/// <summary> /// News the height map. /// </summary> /// <returns>ServerMessage.</returns> private ServerMessage NewHeightMap() { ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("HeightMapMessageComposer")); serverMessage.AppendInteger(Model.MapSizeX); serverMessage.AppendInteger(Model.MapSizeX*Model.MapSizeY); for (int i = 0; i < Model.MapSizeY; i++) { for (int j = 0; j < Model.MapSizeX; j++) { serverMessage.AppendShort((short) (SqAbsoluteHeight(j, i)*256)); } } // serverMessage.AppendShort(this.Model.SqFloorHeight[j, i] * 256); return serverMessage; }
private void FreezeUser(RoomUser user) { if (user.IsBot || user.ShieldActive || user.Team == Team.None || user.Freezed) return; user.Freezed = true; user.FreezeCounter = 0; --user.FreezeLives; if (user.FreezeLives <= 0) { ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("UpdateFreezeLivesMessageComposer")); serverMessage.AppendInteger(user.InternalRoomId); serverMessage.AppendInteger(user.FreezeLives); user.GetClient().SendMessage(serverMessage); user.ApplyEffect(-1); _room.GetGameManager().AddPointToTeam(user.Team, -10, user); TeamManager managerForFreeze = _room.GetTeamManagerForFreeze(); managerForFreeze.OnUserLeave(user); user.Team = Team.None; if (ExitTeleport != null) _room.GetGameMap().TeleportToItem(user, ExitTeleport); user.Freezed = false; user.SetStep = false; user.IsWalking = false; user.UpdateNeeded = true; if (!managerForFreeze.BlueTeam.Any() && !managerForFreeze.RedTeam.Any() && !managerForFreeze.GreenTeam.Any() && managerForFreeze.YellowTeam.Any()) StopGame(); else if (managerForFreeze.BlueTeam.Any() && !managerForFreeze.RedTeam.Any() && !managerForFreeze.GreenTeam.Any() && !managerForFreeze.YellowTeam.Any()) StopGame(); else if (!managerForFreeze.BlueTeam.Any() && managerForFreeze.RedTeam.Any() && !managerForFreeze.GreenTeam.Any() && !managerForFreeze.YellowTeam.Any()) StopGame(); else { if (managerForFreeze.BlueTeam.Any() || managerForFreeze.RedTeam.Any() || !managerForFreeze.GreenTeam.Any() || managerForFreeze.YellowTeam.Any()) return; StopGame(); } } else { _room.GetGameManager().AddPointToTeam(user.Team, -10, user); user.ApplyEffect(12); ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("UpdateFreezeLivesMessageComposer")); serverMessage.AppendInteger(user.InternalRoomId); serverMessage.AppendInteger(user.FreezeLives); user.GetClient().SendMessage(serverMessage); } }
private void PickUpPowerUp(RoomItem item, RoomUser user) { switch (item.FreezePowerUp) { case FreezePowerUp.BlueArrow: case FreezePowerUp.GreenArrow: case FreezePowerUp.OrangeSnowball: user.BanzaiPowerUp = item.FreezePowerUp; break; case FreezePowerUp.Shield: ActivateShield(user); break; case FreezePowerUp.Heart: if (user.FreezeLives < 5) { { ++user.FreezeLives; } _room.GetGameManager().AddPointToTeam(user.Team, 10, user); } ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("UpdateFreezeLivesMessageComposer")); serverMessage.AppendInteger(user.InternalRoomId); serverMessage.AppendInteger(user.FreezeLives); user.GetClient().SendMessage(serverMessage); break; } item.FreezePowerUp = FreezePowerUp.None; item.ExtraData = $"1{item.ExtraData}"; item.UpdateState(false, true); }
private void CountTeamPoints() { _room.GetGameManager().Reset(); foreach ( RoomUser roomUser in _room.GetRoomUserManager() .UserList.Values.Where( roomUser => !roomUser.IsBot && roomUser.Team != Team.None && roomUser.GetClient() != null)) { roomUser.BanzaiPowerUp = FreezePowerUp.None; roomUser.FreezeLives = 3; roomUser.ShieldActive = false; roomUser.ShieldCounter = 11; _room.GetGameManager().AddPointToTeam(roomUser.Team, 30, null); ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("UpdateFreezeLivesMessageComposer")); serverMessage.AppendInteger(roomUser.InternalRoomId); serverMessage.AppendInteger(roomUser.FreezeLives); roomUser.GetClient().SendMessage(serverMessage); } }
/// <summary> /// Serializes the event information. /// </summary> /// <param name="roomId">The room identifier.</param> internal void SerializeEventInfo(uint roomId) { Room room = Yupi.GetGame().GetRoomManager().GetRoom(roomId); if (room == null) { return; } RoomEvent @event = GetEvent(roomId); if (@event == null || @event.HasExpired) { return; } if (!RoomHasEvents(roomId)) { return; } ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("RoomEventMessageComposer")); serverMessage.AppendInteger(roomId); serverMessage.AppendInteger(room.RoomData.OwnerId); serverMessage.AppendString(room.RoomData.Owner); serverMessage.AppendInteger(1); serverMessage.AppendInteger(1); serverMessage.AppendString(@event.Name); serverMessage.AppendString(@event.Description); serverMessage.AppendInteger(0); serverMessage.AppendInteger( (int) Math.Floor((@event.Time - Yupi.GetUnixTimeStamp())/60.0)); serverMessage.AppendInteger(@event.Category); room.SendMessage(serverMessage); }
internal bool MoveBall(RoomItem item, GameClient mover, int newX, int newY) { if (item == null || item.GetBaseItem() == null /*|| mover == null || mover.GetHabbo() == null*/) return false; if (!_room.GetGameMap().ItemCanBePlacedHere(newX, newY)) return false; Point oldRoomCoord = item.Coordinate; bool itemIsOnGameItem = GameItemOverlaps(item); double newZ = _room.GetGameMap().Model.SqFloorHeight[newX][newY]; ServerMessage mMessage = new ServerMessage(); mMessage.Init(LibraryParser.OutgoingRequest("ItemAnimationMessageComposer")); // Cf mMessage.AppendInteger(item.Coordinate.X); mMessage.AppendInteger(item.Coordinate.Y); mMessage.AppendInteger(newX); mMessage.AppendInteger(newY); mMessage.AppendInteger(1); mMessage.AppendInteger(item.Id); mMessage.AppendString(ServerUserChatTextHandler.GetString(item.Z)); mMessage.AppendString(ServerUserChatTextHandler.GetString(newZ)); mMessage.AppendInteger(item.Id); _room.SendMessage(mMessage); if (oldRoomCoord.X == newX && oldRoomCoord.Y == newY) return false; item.SetState(newX, newY, item.Z, Gamemap.GetAffectedTiles(item.GetBaseItem().Length, item.GetBaseItem().Width, newX, newY, item.Rot)); if (itemIsOnGameItem || mover == null || mover.GetHabbo() == null) return false; HandleFootballGameItems(new Point(newX, newY), _room.GetRoomUserManager().GetRoomUserByHabbo(mover.GetHabbo().Id)); return false; }
/// <summary> /// Updates the item on roller. /// </summary> /// <param name="item">The item.</param> /// <param name="nextCoord">The next coord.</param> /// <param name="rolledId">The rolled identifier.</param> /// <param name="nextZ">The next z.</param> /// <returns>ServerMessage.</returns> internal ServerMessage UpdateItemOnRoller(RoomItem item, Point nextCoord, uint rolledId, double nextZ) { ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("ItemAnimationMessageComposer")); serverMessage.AppendInteger(item.X); serverMessage.AppendInteger(item.Y); serverMessage.AppendInteger(nextCoord.X); serverMessage.AppendInteger(nextCoord.Y); serverMessage.AppendInteger(1); serverMessage.AppendInteger(item.Id); serverMessage.AppendString(ServerUserChatTextHandler.GetString(item.Z)); serverMessage.AppendString(ServerUserChatTextHandler.GetString(nextZ)); serverMessage.AppendInteger(rolledId); SetFloorItem(item, nextCoord.X, nextCoord.Y, nextZ); return serverMessage; }
/// <summary> /// Updates the user on roller. /// </summary> /// <param name="user">The user.</param> /// <param name="nextCoord">The next coord.</param> /// <param name="rollerId">The roller identifier.</param> /// <param name="nextZ">The next z.</param> /// <returns>ServerMessage.</returns> internal ServerMessage UpdateUserOnRoller(RoomUser user, Point nextCoord, uint rollerId, double nextZ) { ServerMessage serverMessage = new ServerMessage(0); serverMessage.Init(LibraryParser.OutgoingRequest("ItemAnimationMessageComposer")); serverMessage.AppendInteger(user.X); serverMessage.AppendInteger(user.Y); serverMessage.AppendInteger(nextCoord.X); serverMessage.AppendInteger(nextCoord.Y); serverMessage.AppendInteger(0); serverMessage.AppendInteger(rollerId); serverMessage.AppendInteger(2); serverMessage.AppendInteger(user.VirtualId); serverMessage.AppendString(ServerUserChatTextHandler.GetString(user.Z)); serverMessage.AppendString(ServerUserChatTextHandler.GetString(nextZ)); _room.GetGameMap() .UpdateUserMovement(new Point(user.X, user.Y), new Point(nextCoord.X, nextCoord.Y), user); _room.GetGameMap().GameMap[user.X, user.Y] = 1; user.X = nextCoord.X; user.Y = nextCoord.Y; user.Z = nextZ; _room.GetGameMap().GameMap[user.X, user.Y] = 0; return serverMessage; }
public override void OnTrigger(GameClient session, RoomItem item, int request, bool hasRights) { if (session == null) return; RoomUser roomUserByHabbo = item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().Id); if (roomUserByHabbo == null) return; if (PathFinder.GetDistance(roomUserByHabbo.X, roomUserByHabbo.Y, item.X, item.Y) > 1) roomUserByHabbo.MoveTo(item.X + 1, item.Y); if (Math.Abs(roomUserByHabbo.X - item.X) < 2 && Math.Abs(roomUserByHabbo.Y - item.Y) < 2) { roomUserByHabbo.SetRot( PathFinder.CalculateRotation(roomUserByHabbo.X, roomUserByHabbo.Y, item.X, item.Y), false); Room room = item.GetRoom(); Point point = new Point(0, 0); switch (roomUserByHabbo.RotBody) { case 4: point = new Point(item.X, item.Y + 1); break; case 0: point = new Point(item.X, item.Y - 1); break; case 6: point = new Point(item.X - 1, item.Y); break; default: if (roomUserByHabbo.RotBody != 2) return; point = new Point(item.X + 1, item.Y); break; } if (!room.GetGameMap().ValidTile2(point.X, point.Y)) return; List<RoomItem> coordinatedItems = room.GetGameMap().GetCoordinatedItems(point); if (coordinatedItems.Any(i => !i.GetBaseItem().Stackable)) return; double num = item.GetRoom().GetGameMap().SqAbsoluteHeight(point.X, point.Y); ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("ItemAnimationMessageComposer")); serverMessage.AppendInteger(item.X); serverMessage.AppendInteger(item.Y); serverMessage.AppendInteger(point.X); serverMessage.AppendInteger(point.Y); serverMessage.AppendInteger(1); serverMessage.AppendInteger(item.Id); serverMessage.AppendString(item.Z.ToString(Yupi.CultureInfo)); serverMessage.AppendString(num.ToString(Yupi.CultureInfo)); serverMessage.AppendInteger(0); room.SendMessage(serverMessage); item.GetRoom() .GetRoomItemHandler() .SetFloorItem(roomUserByHabbo.GetClient(), item, point.X, point.Y, item.Rot, false, false, false); } }
/// <summary> /// Serializes the club. /// </summary> internal void SerializeClub() { GameClient client = GetClient(); ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("SubscriptionStatusMessageComposer")); serverMessage.AppendString("club_habbo"); if (client.GetHabbo().GetSubscriptionManager().HasSubscription) { double num = client.GetHabbo().GetSubscriptionManager().GetSubscription().ExpireTime; double num2 = num - Yupi.GetUnixTimeStamp(); int num3 = (int) Math.Ceiling(num2/86400.0); int i = (int) Math.Ceiling((Yupi.GetUnixTimeStamp() - (double) client.GetHabbo().GetSubscriptionManager().GetSubscription().ActivateTime)/ 86400.0); int num4 = num3/31; if (num4 >= 1) num4--; serverMessage.AppendInteger(num3 - num4*31); serverMessage.AppendInteger(1); serverMessage.AppendInteger(num4); serverMessage.AppendInteger(1); serverMessage.AppendBool(true); serverMessage.AppendBool(true); serverMessage.AppendInteger(i); serverMessage.AppendInteger(i); serverMessage.AppendInteger(10); } else { serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendBool(false); serverMessage.AppendBool(false); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); } client.SendMessage(serverMessage); ServerMessage serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("UserClubRightsMessageComposer")); serverMessage2.AppendInteger(GetSubscriptionManager().HasSubscription ? 2 : 0); serverMessage2.AppendInteger(Rank); serverMessage2.AppendBool(Rank >= Convert.ToUInt32(Yupi.GetDbConfig().DbData["ambassador.minrank"])); client.SendMessage(serverMessage2); }
/// <summary> /// Serializes the badge. /// </summary> /// <param name="badge">The badge.</param> /// <returns>ServerMessage.</returns> internal ServerMessage SerializeBadge(string badge) { ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("ReceiveBadgeMessageComposer")); serverMessage.AppendInteger(1); serverMessage.AppendString(badge); return serverMessage; }
/// <summary> /// Serializes the room chatlog. /// </summary> /// <param name="roomId">The room identifier.</param> /// <returns>ServerMessage.</returns> /// <exception cref="System.NullReferenceException">No room found.</exception> internal static ServerMessage SerializeRoomChatlog(uint roomId) { ServerMessage message = new ServerMessage(); Room room = Yupi.GetGame().GetRoomManager().LoadRoom(roomId); if (room?.RoomData != null) { message.Init(LibraryParser.OutgoingRequest("ModerationToolRoomChatlogMessageComposer")); message.AppendByte(1); message.AppendShort(2); message.AppendString("roomName"); message.AppendByte(2); message.AppendString(room.RoomData.Name); message.AppendString("roomId"); message.AppendByte(1); message.AppendInteger(room.RoomData.Id); List<Chatlog> tempChatlogs = room.RoomData.RoomChat.Reverse() .Skip(Math.Max(0, room.RoomData.RoomChat.Count - 60)) .Take(60) .ToList(); message.AppendShort(tempChatlogs.Count); foreach (Chatlog chatLog in tempChatlogs) chatLog.Serialize(ref message); return message; } return null; }
/// <summary> /// Serializes the badge reward. /// </summary> /// <param name="success">if set to <c>true</c> [success].</param> /// <returns>ServerMessage.</returns> internal ServerMessage SerializeBadgeReward(bool success) { ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("WiredRewardAlertMessageComposer")); serverMessage.AppendInteger(success ? 7 : 1); return serverMessage; }
/// <summary> /// Deploys the bot. /// </summary> /// <param name="bot">The bot.</param> /// <param name="petData">The pet data.</param> /// <returns>RoomUser.</returns> internal RoomUser DeployBot(RoomBot bot, Pet petData) { int virtualId = _primaryPrivateUserId++; RoomUser roomUser = new RoomUser(0u, _userRoom.RoomId, virtualId, _userRoom, false); int num = _secondaryPrivateUserId++; roomUser.InternalRoomId = num; UserList.TryAdd(num, roomUser); OnUserAdd(roomUser); DynamicRoomModel model = _userRoom.GetGameMap().Model; Point coord = new Point(bot.X, bot.Y); if ((bot.X > 0) && (bot.Y >= 0) && (bot.X < model.MapSizeX) && (bot.Y < model.MapSizeY)) { _userRoom.GetGameMap().AddUserToMap(roomUser, coord); roomUser.SetPos(bot.X, bot.Y, bot.Z); roomUser.SetRot(bot.Rot, false); } else { bot.X = model.DoorX; bot.Y = model.DoorY; roomUser.SetPos(model.DoorX, model.DoorY, model.DoorZ); roomUser.SetRot(model.DoorOrientation, false); } bot.RoomUser = roomUser; roomUser.BotData = bot; roomUser.BotAi = bot.GenerateBotAi(roomUser.VirtualId, (int) bot.BotId); if (roomUser.IsPet) { roomUser.BotAi.Init(bot.BotId, roomUser.VirtualId, _userRoom.RoomId, roomUser, _userRoom); roomUser.PetData = petData; roomUser.PetData.VirtualId = roomUser.VirtualId; } else roomUser.BotAi.Init(bot.BotId, roomUser.VirtualId, _userRoom.RoomId, roomUser, _userRoom); UpdateUserStatus(roomUser, false); roomUser.UpdateNeeded = true; ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("SetRoomUserMessageComposer")); serverMessage.AppendInteger(1); roomUser.Serialize(serverMessage, _userRoom.GetGameMap().GotPublicPool); _userRoom.SendMessage(serverMessage); roomUser.BotAi.OnSelfEnterRoom(); if (roomUser.IsPet) { if (_pets.Contains(roomUser.PetData.PetId)) _pets[roomUser.PetData.PetId] = roomUser; else _pets.Add(roomUser.PetData.PetId, roomUser); PetCount++; } roomUser.BotAi.Modified(); if (roomUser.BotData.AiType != AiType.Generic) return roomUser; if (_bots.Contains(roomUser.BotData.BotId)) _bots[roomUser.BotData.BotId] = roomUser; else _bots.Add(roomUser.BotData.BotId, roomUser); serverMessage.Init(LibraryParser.OutgoingRequest("DanceStatusMessageComposer")); serverMessage.AppendInteger(roomUser.VirtualId); serverMessage.AppendInteger(roomUser.BotData.DanceId); _userRoom.SendMessage(serverMessage); PetCount++; return roomUser; }
/// <summary> /// Serializes the room data. /// </summary> /// <param name="message">The message.</param> /// <param name="session">The session.</param> /// <param name="isNotReload">if set to <c>true</c> [from view].</param> /// <param name="sendRoom">if set to <c>true</c> [send room].</param> /// <param name="show">if set to <c>true</c> [show].</param> internal void SerializeRoomData(ServerMessage message, GameClient session, bool isNotReload, bool? sendRoom = false, bool show = true) { Room room = Yupi.GetGame().GetRoomManager().GetRoom(session.GetHabbo().CurrentRoomId); message.Init(LibraryParser.OutgoingRequest("RoomDataMessageComposer")); message.AppendBool(show); //flatId Serialize(message, true, !isNotReload); message.AppendBool(isNotReload); message.AppendBool(Yupi.GetGame().GetNavigator() != null && Yupi.GetGame().GetNavigator().GetPublicItem(Id) != null); // staffPick message.AppendBool(!isNotReload || session.GetHabbo().HasFuse("fuse_mod")); // bypass bell, pass ... message.AppendBool(room != null && room.RoomMuted); //roomMuted message.AppendInteger(WhoCanMute); message.AppendInteger(WhoCanKick); message.AppendInteger(WhoCanBan); message.AppendBool(room != null && room.CheckRights(session, true)); message.AppendInteger(ChatType); message.AppendInteger(ChatBalloon); message.AppendInteger(ChatSpeed); message.AppendInteger(ChatMaxDistance); message.AppendInteger(ChatFloodProtection); if (sendRoom == null) return; if (sendRoom.Value) { if (Yupi.GetGame().GetRoomManager().GetRoom(Id) != null) Yupi.GetGame().GetRoomManager().GetRoom(Id).SendMessage(message); } else session.SendMessage(message); }
/// <summary> /// Updates the user status. /// </summary> /// <param name="user">The user.</param> /// <param name="cycleGameItems">if set to <c>true</c> [cyclegameitems].</param> internal void UpdateUserStatus(RoomUser user, bool cycleGameItems) { if (user == null) return; if (user.Statusses.ContainsKey("lay") || user.Statusses.ContainsKey("sit")) { user.Statusses.Remove("lay"); user.Statusses.Remove("sit"); user.UpdateNeeded = true; } bool isBot = user.IsBot; if (isBot) cycleGameItems = false; try { Gamemap roomMap = _userRoom.GetGameMap(); Point userPoint = new Point(user.X, user.Y); RoomItem[] allRoomItemForSquare = roomMap.GetCoordinatedHeighestItems(userPoint).ToArray(); List<RoomItem> itemsOnSquare = roomMap.GetCoordinatedItems(userPoint); double newZ = _userRoom.GetGameMap().SqAbsoluteHeight(user.X, user.Y, itemsOnSquare) + (user.RidingHorse && user.IsPet == false ? 1 : 0); if (Math.Abs(newZ - user.Z) > 0) { user.Z = newZ; user.UpdateNeeded = true; } foreach (RoomItem item in allRoomItemForSquare) { if (cycleGameItems) { item.UserWalksOnFurni(user); } if (item.GetBaseItem().IsSeat) { if (!user.Statusses.ContainsKey("sit")) { if (item.GetBaseItem().StackMultipler && !string.IsNullOrWhiteSpace(item.ExtraData)) if (item.ExtraData != "0") { int num2 = Convert.ToInt32(item.ExtraData); if (!user.Statusses.ContainsKey("sit")) user.Statusses.Add("sit", item.GetBaseItem().ToggleHeight[num2].ToString(CultureInfo.InvariantCulture) .Replace(',', '.')); } else { if (!user.Statusses.ContainsKey("sit")) user.Statusses.Add("sit", Convert.ToString(item.GetBaseItem().Height, CultureInfo.InvariantCulture)); } else { if (!user.Statusses.ContainsKey("sit")) user.Statusses.Add("sit", Convert.ToString(item.GetBaseItem().Height, CultureInfo.InvariantCulture)); } } if (Math.Abs(user.Z - item.Z) > 0 || user.RotBody != item.Rot) { user.Z = item.Z; user.RotHead = item.Rot; user.RotBody = item.Rot; user.UpdateNeeded = true; } } Interaction interactionType = item.GetBaseItem().InteractionType; switch (interactionType) { case Interaction.QuickTeleport: case Interaction.GuildGate: case Interaction.WalkInternalLink: { item.Interactor.OnUserWalk(user.GetClient(), item, user); break; } case Interaction.None: break; case Interaction.PressurePadBed: case Interaction.Bed: { if (!user.Statusses.ContainsKey("lay")) user.Statusses.Add("lay", ServerUserChatTextHandler.GetString(item.GetBaseItem().Height)); else { if (user.Statusses["lay"] != ServerUserChatTextHandler.GetString(item.GetBaseItem().Height)) user.Statusses["lay"] = ServerUserChatTextHandler.GetString(item.GetBaseItem().Height); } user.Z = item.Z; user.RotHead = item.Rot; user.RotBody = item.Rot; user.UpdateNeeded = true; if (item.GetBaseItem().InteractionType == Interaction.PressurePadBed) { item.ExtraData = "1"; item.UpdateState(); } break; } case Interaction.Guillotine: { if (!user.Statusses.ContainsKey("lay")) user.Statusses.Add("lay", ServerUserChatTextHandler.GetString(item.GetBaseItem().Height)); else if (user.Statusses["lay"] != ServerUserChatTextHandler.GetString(item.GetBaseItem().Height)) user.Statusses["lay"] = ServerUserChatTextHandler.GetString(item.GetBaseItem().Height); user.Z = item.Z; user.RotBody = item.Rot; item.ExtraData = "1"; item.UpdateState(); AvatarEffectComponent avatarEffectsInventoryComponent = user.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent(); avatarEffectsInventoryComponent.ActivateCustomEffect(133); break; } case Interaction.FootballGate: break; case Interaction.BanzaiGateBlue: case Interaction.BanzaiGateRed: case Interaction.BanzaiGateYellow: case Interaction.BanzaiGateGreen: { int effect = (int) item.Team + 32; TeamManager teamManagerForBanzai = user.GetClient().GetHabbo().CurrentRoom.GetTeamManagerForBanzai(); AvatarEffectComponent avatarEffectsInventoryComponent = user.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent(); if (user.Team == Team.None) { if (!teamManagerForBanzai.CanEnterOnTeam(item.Team)) break; if (user.Team != Team.None) teamManagerForBanzai.OnUserLeave(user); user.Team = item.Team; teamManagerForBanzai.AddUser(user); if (avatarEffectsInventoryComponent.CurrentEffect != effect) avatarEffectsInventoryComponent.ActivateCustomEffect(effect); break; } if (user.Team != Team.None && user.Team != item.Team) { teamManagerForBanzai.OnUserLeave(user); user.Team = Team.None; avatarEffectsInventoryComponent.ActivateCustomEffect(0); break; } teamManagerForBanzai.OnUserLeave(user); if (avatarEffectsInventoryComponent.CurrentEffect == effect) avatarEffectsInventoryComponent.ActivateCustomEffect(0); user.Team = Team.None; break; } case Interaction.Jump: break; case Interaction.Pinata: { if (!user.IsWalking || item.ExtraData.Length <= 0) break; int num5 = int.Parse(item.ExtraData); if (num5 >= 100 || user.CurrentEffect != 158) break; int num6 = num5 + 1; item.ExtraData = num6.ToString(); item.UpdateState(); Yupi.GetGame() .GetAchievementManager() .ProgressUserAchievement(user.GetClient(), "ACH_PinataWhacker", 1); if (num6 == 100) { Yupi.GetGame().GetPinataHandler().DeliverRandomPinataItem(user, _userRoom, item); Yupi.GetGame() .GetAchievementManager() .ProgressUserAchievement(user.GetClient(), "ACH_PinataBreaker", 1); } break; } case Interaction.TileStackMagic: case Interaction.Poster: break; case Interaction.Tent: case Interaction.BedTent: if (user.LastItem == item.Id) break; if (!user.IsBot && !user.OnCampingTent) { ServerMessage serverMessage22 = new ServerMessage(); serverMessage22.Init( LibraryParser.OutgoingRequest("UpdateFloorItemExtraDataMessageComposer")); serverMessage22.AppendString(item.Id.ToString()); serverMessage22.AppendInteger(0); serverMessage22.AppendString("1"); user.GetClient().SendMessage(serverMessage22); user.OnCampingTent = true; user.LastItem = item.Id; } break; case Interaction.RunWaySage: { int num7 = new Random().Next(1, 4); item.ExtraData = num7.ToString(); item.UpdateState(); break; } case Interaction.Shower: case Interaction.ChairState: case Interaction.PressurePad: { item.ExtraData = "1"; item.UpdateState(); break; } case Interaction.BanzaiTele: { if (user.IsWalking) _userRoom.GetGameItemHandler().OnTeleportRoomUserEnter(user, item); break; } case Interaction.FreezeYellowGate: case Interaction.FreezeRedGate: case Interaction.FreezeGreenGate: case Interaction.FreezeBlueGate: { if (cycleGameItems) { int num4 = (int) (item.Team + 39); TeamManager teamManagerForFreeze = user.GetClient().GetHabbo().CurrentRoom.GetTeamManagerForFreeze(); AvatarEffectComponent avatarEffectsInventoryComponent2 = user.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent(); if (user.Team != item.Team) { if (teamManagerForFreeze.CanEnterOnTeam(item.Team)) { if (user.Team != Team.None) teamManagerForFreeze.OnUserLeave(user); user.Team = item.Team; teamManagerForFreeze.AddUser(user); if (avatarEffectsInventoryComponent2.CurrentEffect != num4) avatarEffectsInventoryComponent2.ActivateCustomEffect(num4); } } else { teamManagerForFreeze.OnUserLeave(user); if (avatarEffectsInventoryComponent2.CurrentEffect == num4) avatarEffectsInventoryComponent2.ActivateCustomEffect(0); user.Team = Team.None; } ServerMessage serverMessage33 = new ServerMessage( LibraryParser.OutgoingRequest("UserIsPlayingFreezeMessageComposer")); serverMessage33.AppendBool(user.Team != Team.None); user.GetClient().SendMessage(serverMessage33); } break; } } if (item.GetBaseItem().InteractionType == Interaction.BedTent) user.OnCampingTent = true; user.LastItem = item.Id; } if (user.IsSitting && user.TeleportEnabled) { user.Z -= 0.35; user.UpdateNeeded = true; } if (cycleGameItems) { _userRoom.GetSoccer().OnUserWalk(user); _userRoom.GetBanzai().OnUserWalk(user); _userRoom.GetFreeze().OnUserWalk(user); } } catch (Exception e) { ServerLogManager.HandleException(e, "RoomUserManager.cs:UpdateUserStatus"); } }
/// <summary> /// Serializes the bot inventory. /// </summary> /// <returns>ServerMessage.</returns> internal ServerMessage SerializeBotInventory() { ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("BotInventoryMessageComposer")); serverMessage.AppendInteger(_inventoryBots.Count); foreach (RoomBot current in _inventoryBots.Values) { serverMessage.AppendInteger(current.BotId); serverMessage.AppendString(current.Name); serverMessage.AppendString(current.Motto); serverMessage.AppendString("m"); serverMessage.AppendString(current.Look); } return serverMessage; }
internal ServerMessage AppendVoteMessage(ServerMessage message, Habbo user, int status = 0) { message.Init(LibraryParser.OutgoingRequest("CompetitionVotingInfoMessageComposer")); message.AppendInteger(Id); message.AppendString(Name); message.AppendInteger(status); // 0 : vote - 1 : can't vote - 2 : you need the vote badge message.AppendInteger(user.DailyCompetitionVotes); return message; }
/// <summary> /// Sends the new items. /// </summary> /// <param name="id">The identifier.</param> internal void SendNewItems(uint id) { ServerMessage serverMessage = new ServerMessage(); serverMessage.Init(LibraryParser.OutgoingRequest("NewInventoryObjectMessageComposer")); serverMessage.AppendInteger(1); serverMessage.AppendInteger(1); serverMessage.AppendInteger(1); serverMessage.AppendInteger(id); _mClient.SendMessage(serverMessage); }
/// <summary> /// Serializes the theGroup information. /// </summary> /// <param name="group">The theGroup.</param> /// <param name="response">The response.</param> /// <param name="session">The session.</param> /// <param name="room">The room.</param> /// <param name="newWindow">if set to <c>true</c> [new window].</param> internal void SerializeGroupInfo(Group group, ServerMessage response, GameClient session, Room room, bool newWindow = false) { if (room == null || group == null) return; DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); DateTime dateTime2 = dateTime.AddSeconds(group.CreateTime); response.Init(LibraryParser.OutgoingRequest("GroupDataMessageComposer")); response.AppendInteger(group.Id); response.AppendBool(true); response.AppendInteger(group.State); response.AppendString(group.Name); response.AppendString(group.Description); response.AppendString(group.Badge); response.AppendInteger(group.RoomId); response.AppendString(Yupi.GetGame().GetRoomManager().GenerateRoomData(@group.RoomId) == null ? "No room found.." : Yupi.GetGame().GetRoomManager().GenerateRoomData(group.RoomId).Name); response.AppendInteger(@group.CreatorId == session.GetHabbo().Id ? 3 : (group.Requests.ContainsKey(session.GetHabbo().Id) ? 2 : (group.Members.ContainsKey(session.GetHabbo().Id) ? 1 : 0))); response.AppendInteger(group.Members.Count); response.AppendBool(session.GetHabbo().FavouriteGroup == group.Id); response.AppendString($"{dateTime2.Day.ToString("00")}-{dateTime2.Month.ToString("00")}-{dateTime2.Year}"); response.AppendBool(group.CreatorId == session.GetHabbo().Id); response.AppendBool(group.Admins.ContainsKey(session.GetHabbo().Id)); response.AppendString(Yupi.GetHabboById(@group.CreatorId) == null ? string.Empty : Yupi.GetHabboById(group.CreatorId).UserName); response.AppendBool(newWindow); response.AppendBool(group.AdminOnlyDeco == 0u); response.AppendInteger(group.Requests.Count); response.AppendBool(group.Forum.Id != 0); room.SendMessage(response); }
/// <summary> /// Adds the experience. /// </summary> /// <param name="amount">The amount.</param> internal void AddExperience(int amount) { int oldExperienceGoal = ExperienceGoal; Experience += amount; if (Experience >= 51900) return; if (DbState != DatabaseUpdateState.NeedsInsert) DbState = DatabaseUpdateState.NeedsUpdate; if (Room == null) return; ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("AddPetExperienceMessageComposer")); serverMessage.AppendInteger(PetId); serverMessage.AppendInteger(VirtualId); serverMessage.AppendInteger(amount); Room.SendMessage(serverMessage); if (Experience < oldExperienceGoal) return; GameClient ownerSession = Yupi.GetGame().GetClientManager().GetClientByUserId(OwnerId); Dictionary<uint, PetCommand> totalPetCommands = PetCommandHandler.GetAllPetCommands(); Dictionary<uint, PetCommand> petCommands = PetCommandHandler.GetPetCommandByPetType(Type); if (ownerSession == null) return; ServerMessage levelNotify = new ServerMessage(LibraryParser.OutgoingRequest("NotifyNewPetLevelMessageComposer")); SerializeInventory(levelNotify, true); ownerSession.SendMessage(levelNotify); ServerMessage tp = new ServerMessage(); tp.Init(LibraryParser.OutgoingRequest("PetTrainerPanelMessageComposer")); tp.AppendInteger(PetId); tp.AppendInteger(totalPetCommands.Count); foreach (uint sh in totalPetCommands.Keys) tp.AppendInteger(sh); tp.AppendInteger(petCommands.Count); foreach (uint sh in petCommands.Keys) tp.AppendInteger(sh); ownerSession.SendMessage(tp); }