internal Boolean CheckRights(GameClient Session, bool RequireOwnership) { try { if (Session == null || Session.GetHabbo() == null) { return(false); } if (Session.GetHabbo().Id == RoomData.OwnerId) { return(true); } if (Session.GetHabbo().HasFuse("fuse_admin") || Session.GetHabbo().HasFuse("fuse_any_room_rights")) { return(true); } if (!RequireOwnership) { GroupItem group = OtanixEnvironment.GetGame().GetGroup().LoadGroup(RoomData.GroupId); if (group != null) // si la sala contiene un grupo { if (group.RightsType == 0) // todos los miembros pueden mover { if (Session.GetHabbo().MyGroups.Contains(RoomData.GroupId)) // soy miembro. { return(true); } } else if (group.RightsType == 1) // solo los administradores pueden mover { if (group.Admins.ContainsKey(Session.GetHabbo().Id)) // soy administrador { return(true); } } } if (UsersWithRights.Contains(Session.GetHabbo().Id)) { return(true); } if (RoomData.AllowRightsOverride) { return(true); } } } catch (Exception e) { Logging.HandleException(e, "Room.CheckRights"); } return(false); }
internal static void DestroyJson() { InfoModelo dados = OtanixEnvironment.getStatusApi(); dados.hotel = 0; dados.onlines = 0; dados.loadRooms = 0; dados.uptime = "Servidor desligado"; APIexterna.enviaAlerta(dados); }
internal void UpdateLastFollowingLogin() { if ((DateTime.Now - this.LastFollowingLogin).TotalDays > 2) // reseteamos { OtanixEnvironment.GetGame().GetAchievementManager().ResetAchievement(this.GetClient(), "ACH_Login"); OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Id, "ACH_RegistrationDuration", 1); if (this.Rank > 1) { OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Id, "ACH_GuideEnrollmentLifetime", 1); } if (CitizenshipLevel == 2 || CitizenshipLevel == 3) { OtanixEnvironment.GetGame().GetTalentManager().UpdateTalentTravel(mClient, "citizenship"); } else if (HelperLevel == 3 || HelperLevel == 4 || HelperLevel == 5 || HelperLevel == 6 || HelperLevel == 7) { OtanixEnvironment.GetGame().GetTalentManager().UpdateTalentTravel(mClient, "helper"); } this.DailyRespectPoints = 3; this.DailyPetRespectPoints = 3; this.LastFollowingLogin = DateTime.Now; } else if ((DateTime.Now - this.LastFollowingLogin).TotalDays > 1) { OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Id, "ACH_Login", 1); OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Id, "ACH_RegistrationDuration", 1); if (this.Rank > 1) { OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Id, "ACH_GuideEnrollmentLifetime", 1); } if (CitizenshipLevel == 2 || CitizenshipLevel == 3) { OtanixEnvironment.GetGame().GetTalentManager().UpdateTalentTravel(mClient, "citizenship"); } else if (HelperLevel == 3 || HelperLevel == 4 || HelperLevel == 5 || HelperLevel == 6 || HelperLevel == 7) { OtanixEnvironment.GetGame().GetTalentManager().UpdateTalentTravel(mClient, "helper"); } this.DailyRespectPoints = 3; this.DailyPetRespectPoints = 3; this.LastFollowingLogin = DateTime.Now; } UserAchievement ach_friendlistsize = this.GetAchievementData("ACH_FriendListSize"); if (ach_friendlistsize != null) { ach_friendlistsize.Progress = FriendsCount; } }
internal static MoodlightPreset GeneratePreset(string Data) { var Bits = Data.Split(','); if (!IsValidColor(Bits[0])) { Bits[0] = "#000000"; } return(new MoodlightPreset(Bits[0], int.Parse(Bits[1]), OtanixEnvironment.EnumToBool(Bits[2]))); }
/// <summary> /// Acción que reliaza cuando un usuario termina la encuesta. /// </summary> /// <param name="UserId"></param> /// <param name="Answers"></param> /// <returns></returns> public ServerMessage SaveInformation(uint UserId, string Answers) { using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("INSERT INTO room_polls_answers VALUES ('" + UserId + "','" + RoomId + "','" + 0 + "',@answers)"); dbClient.addParameter("answers", Answers); dbClient.runQuery(); } return(null); }
internal void sendCommand(String data) { try { socket.Send(OtanixEnvironment.GetDefaultEncoding().GetBytes(data)); } catch { tryClose(); } }
public ClothingItem(DataRow dRow) { this.ItemName = (string)dRow["item_name"]; string[] ClothesParts = ((string)dRow["clothes_id"]).Split(','); this.ClothesId = new int[ClothesParts.Length]; for (int i = 0; i < this.ClothesId.Length; i++) { this.ClothesId[i] = Convert.ToInt32(ClothesParts[i]); OtanixEnvironment.GetGame().GetClothingManager().AddClothesPart(this.ClothesId[i]); } }
internal void ModPickTicket() { if (!Session.GetHabbo().HasFuse("fuse_mod")) { return; } int Junk = Request.PopWiredInt32(); uint TicketId = Request.PopWiredUInt(); OtanixEnvironment.GetGame().GetModerationTool().PickTicket(Session, TicketId); }
public static void SaveUserLog(uint UserId, uint RoomId, string Message, int ReceiverId) { if (ContainsUser(UserId)) { using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("INSERT INTO user_chat_logs VALUES ('" + UserId + "','" + RoomId + "','" + ReceiverId + "','" + DateTime.Now + "',@msg)"); dbClient.addParameter("msg", Message); dbClient.runQuery(); } } }
internal void RequestBuddy() { if (Session.GetHabbo().GetMessenger() == null) { return; } if (Session.GetHabbo().GetMessenger().RequestBuddy(Request.PopFixedString())) { OtanixEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.SOCIAL_FRIEND); } }
internal static void Notifica(string imagem, string mensagem) { ServerMessage Alert = new ServerMessage(Outgoing.CustomAlert); Alert.AppendString("furni_placement_error"); Alert.AppendInt32(2); Alert.AppendString("message"); Alert.AppendString(mensagem); Alert.AppendString("image"); Alert.AppendString("${image.library.url}notifications/" + imagem + ".png"); OtanixEnvironment.GetGame().GetClientManager().QueueBroadcaseMessage(Alert, "fuse_sa", 0); }
internal TargetedOffer GetRoomIdTargetedOffer(uint RoomId) { foreach (TargetedOffer to in targetedOffers) { if (to.roomId == RoomId && to.ExpirationTime > OtanixEnvironment.GetUnixTimestamp()) { return(to); } } return(null); }
private static DataRow GetRowFromBaseId(uint BaseId) { DataRow dRow = null; using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT offer_id, item_type, total_price, extra_data, timestamp FROM catalog_marketplace_offers WHERE item_id = '" + BaseId + "' AND " + WhereString + " ORDER BY total_price ASC LIMIT 1"); dRow = dbClient.getRow(); } return(dRow); }
internal bool IsMember(uint Userid) { using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT null FROM groups_users WHERE groupid = '" + Id + "' AND userid = '" + Userid + "' AND acepted = '1'"); if (dbClient.getRow() != null) { return(true); } } return(false); }
internal void DeliverInstantMessage(string message, uint convoID, int timeSended = 0) { var InstantMessage = new ServerMessage(Outgoing.InstantChat); InstantMessage.AppendUInt(convoID); InstantMessage.AppendString(message); InstantMessage.AppendInt32(timeSended == 0 ? 0 : OtanixEnvironment.GetUnixTimestamp() - timeSended); if (GetClient() != null) { GetClient().SendMessage(InstantMessage); } }
internal void Delete() { using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("DELETE FROM groups WHERE id = '" + Id + "'"); dbClient.runFastQuery("DELETE FROM groups_users WHERE groupid = '" + Id + "'"); if (Forum != null) { dbClient.runFastQuery("DELETE FROM groups_forums WHERE groupid = '" + Id + "'"); dbClient.runFastQuery("DELETE FROM groups_forums_boards WHERE groupid = '" + Id + "'"); } dbClient.runFastQuery("UPDATE users SET FavoriteGroup = '0' WHERE FavoriteGroup = '" + Id + "'"); dbClient.runFastQuery("UPDATE rooms SET groupId = '0' WHERE id = '" + RoomId + "'"); } OtanixEnvironment.GetGame().GetGroup().RemoveGroupQueue(Id); RoomData roomData = OtanixEnvironment.GetGame().GetRoomManager().GenerateRoomData(RoomId); if (roomData != null) { roomData.GroupId = 0; // Reload Room: Room TargetRoom = OtanixEnvironment.GetGame().GetRoomManager().GetRoom(roomData.Id); if (TargetRoom != null && TargetRoom.GetRoomUserManager() != null) { List <RoomUser> users = new List <RoomUser>(TargetRoom.GetRoomUserManager().UserList.Values); OtanixEnvironment.GetGame().GetRoomManager().UnloadRoom(TargetRoom); if (users != null && users.Count > 0) { foreach (RoomUser user in users) { if (user != null && user.GetClient() != null) { user.GetClient().GetMessageHandler().enterOnRoom3(TargetRoom); } user.GetClient().GetHabbo().MyGroups.Remove(Id); if (user.GetClient().GetHabbo().FavoriteGroup == Id) { user.GetClient().GetHabbo().FavoriteGroup = 0; } } } } } }
internal void NewNavigatorPacket() { if (Session == null) { return; } string name = Request.PopFixedString(); string textbox = Request.PopFixedString(); Session.SendMessage(OtanixEnvironment.GetGame().GetNewNavigatorManager().SerlializeNewNavigator(name, textbox, Session)); }
internal void EndEvent() { Room Room = OtanixEnvironment.GetGame().GetRoomManager().LoadRoom(RoomId); if (Room == null || Room.RoomData == null) { return; } OtanixEnvironment.GetGame().GetRoomManager().GetEventManager().QueueRemoveEvent(Room.RoomData); Room.RoomData.Event = null; }
internal void RunDBUpdate() { try { if (mRemovedItems.Count > 0 || mAddedItems.Count > 0 || InventoryPets.Count > 0) { QueryChunk queries = new QueryChunk(); if (mAddedItems.Count > 0) // This should be checked more carefully { foreach (UserItem Item in mAddedItems.Values) { queries.AddQuery("UPDATE items_users SET user_id = " + GetUserInventaryId() + " WHERE item_id = " + Item.Id); } mAddedItems.Clear(); } if (mRemovedItems.Count > 0) { foreach (UInt32 ItemID in mRemovedItems.ToArray()) { queries.AddQuery("DELETE FROM items_users WHERE item_id=" + ItemID + " AND user_id=" + GetUserInventaryId()); } mRemovedItems.Clear(); } foreach (var pet in InventoryPets.Values) { if (pet.DBState == DatabaseUpdateState.NeedsUpdate) { queries.AddParameter(pet.PetId + "name", pet.Name); queries.AddParameter(pet.PetId + "race", pet.Race); queries.AddParameter(pet.PetId + "color", pet.Color); queries.AddQuery("UPDATE user_pets SET room_id = " + pet.RoomId + ", name = @" + pet.PetId + "name, race = @" + pet.PetId + "race, color = @" + pet.PetId + "color, type = " + pet.Type + ", expirience = " + pet.Expirience + ", " + "energy = " + pet.Energy + ", nutrition = " + pet.Nutrition + ", respect = " + pet.Respect + ", createstamp = '" + pet.CreationStamp + "', x = " + pet.X + ", Y = " + pet.Y + ", Z = " + pet.Z + " WHERE id = " + pet.PetId); } pet.DBState = DatabaseUpdateState.Updated; } using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { queries.Execute(dbClient); } } } catch (Exception e) { Logging.LogCacheError("FATAL ERROR DURING USER INVENTORY DB UPDATE: " + e); } }
internal void PurchaseGift() { int PageId = Request.PopWiredInt32(); uint ItemId = Request.PopWiredUInt(); string ExtraData = Request.PopFixedString(); string GiftUser = OtanixEnvironment.FilterInjectionChars(Request.PopFixedString()); string GiftMessage = OtanixEnvironment.FilterInjectionChars(Request.PopFixedString()); int SpriteId = Request.PopWiredInt32(); int Lazo = Request.PopWiredInt32(); int Color = Request.PopWiredInt32(); OtanixEnvironment.GetGame().GetCatalog().BuyAGift(Session, PageId, ItemId, ExtraData, GiftUser, GiftMessage, SpriteId, Lazo, Color); }
internal void UpdateHabboClubAchievement() { UserAchievement ach_basicclub = this.GetAchievementData("ACH_BasicClub"); if (ach_basicclub != null) { if ((DateTime.Now - this.Created).TotalDays > ((ach_basicclub.Progress * 31))) { OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Id, "ACH_BasicClub", 1); OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(this.Id, "ACH_VipHC", 1); } } }
internal void BuyClubDiscount() { int Cost = 45; using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("UPDATE users SET moedas = moedas - " + Cost + " WHERE id = " + Session.GetHabbo().Id); } Session.GetHabbo().Moedas -= Cost; Session.GetHabbo().UpdateCreditsBalance(); Session.GetHabbo().GetClubManager().AddOrExtendSubscription(Session, "club_habbo", 31 * 86400, (uint)Cost, 1); }
internal void ModCloseTicket() { if (!Session.GetHabbo().HasFuse("fuse_mod")) { return; } int Result = Request.PopWiredInt32(); // result, 1 = useless, 2 = abusive, 3 = resolved int Junk = Request.PopWiredInt32(); // ? uint TicketId = Request.PopWiredUInt(); // id OtanixEnvironment.GetGame().GetModerationTool().CloseTicket(Session, TicketId, Result); }
public void EndGame(Team winners, Room Room) { foreach (RoomItem Item in banzaiTiles) { if (Item.team == Team.none) { Item.ExtraData = "0"; Item.UpdateState(); } else if (Item.team == winners) { Item.interactionCount = 0; Item.interactionCountHelper = 0; Item.UpdateNeeded = true; } } if (winners != Team.none) { foreach (RoomUser user in Room.GetRoomUserManager().GetRoomUsers()) { if (user == null || user.team == Team.none || user.GetClient() == null || user.GetClient().GetHabbo() == null || user.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent() == null) { continue; } if (winners == user.team) { var Action = new ServerMessage(Outgoing.Action); Action.AppendInt32(user.VirtualId); Action.AppendInt32(1); Room.SendMessage(Action); if (user != null && user.GetClient() != null && user.GetClient().GetHabbo() != null) { OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(user.GetClient().GetHabbo().Id, "ACH_GamePlayerExperience", user.BanzaiPoints); OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(user.GetClient().GetHabbo().Id, "ACH_BattleBallWinner", Room.GetGameManager().GetTeamPoints((int)winners)); } } if (user != null && user.GetClient() != null && user.GetClient().GetHabbo() != null) { OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(user.GetClient().GetHabbo().Id, "ACH_BattleBallTilesLocked", user.BanzaiPoints); OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(user.GetClient().GetHabbo().Id, "ACH_BattleBallPlayer", 1); } user.classPoints = 0; user.BanzaiPoints = 0; } } }
private void PickUpPowerUp(RoomItem item, RoomUser user) { Room Room = OtanixEnvironment.GetGame().GetRoomManager().GetRoom(user.RoomId); if (Room == null) { return; } switch (item.freezePowerUp) { case FreezePowerUp.Heart: { if (user.FreezeLives < 3) { user.FreezeLives++; Room.GetGameManager().AddPointsToTeam(user.team, 10, user); } ServerMessage message = new ServerMessage(Outgoing.UpdateFreezeLives); message.AppendInt32(user.InternalRoomID); message.AppendInt32(user.FreezeLives); user.GetClient().SendMessage(message); break; } case FreezePowerUp.Shield: { ActivateShield(user); break; } case FreezePowerUp.BlueArrow: case FreezePowerUp.GreenArrow: case FreezePowerUp.OrangeSnowball: { user.banzaiPowerUp = item.freezePowerUp; break; } } item.freezePowerUp = FreezePowerUp.None; item.ExtraData = "1" + item.ExtraData; item.UpdateState(false, true); if (user != null && user.GetClient() != null && user.GetClient().GetHabbo() != null) { OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(user.GetClient().GetHabbo().Id, "ACH_FreezePowerUp", 1); } }
internal void Serialize(int Rank, ServerMessage Message) { Message.AppendBoolean(Visible); // Visible Message.AppendInt32(IconImage); // Icon Message.AppendInt32(Enabled ? Id : -1); // PageID Message.AppendString(PageName); // PageName Message.AppendString(Caption + (Rank > 5 ? "(" + Id + ")" : "")); // Localization Message.AppendInt32(Items.Count); // Items Count foreach (CatalogItem item in Items.Values) { Message.AppendUInt(item.Id); // ItemID } Message.AppendInt32(OtanixEnvironment.GetGame().GetCatalog().GetTreeSize(Rank, Id)); // SubPages Count }
public PacketsUserLogs() { // Iniciamos la variable que se utilizará como caché. PacketsList = new Dictionary <int, double>(); // Calculamos el tiempo actual. double actualUnix = OtanixEnvironment.GetUnixTimestamp(); // Establecemos valores. foreach (int IncomingId in PacketsCollapsed.PacketsList.Keys) { PacketsList.Add(IncomingId, actualUnix); } }
internal void GetCatalogIndex() { string CatalogType = Request.PopFixedString(); if (CatalogType.Equals("NORMAL")) { Session.SendMessage(OtanixEnvironment.GetGame().GetCatalog().GetIndexMessageForRank(Session.GetHabbo().Rank)); } else if (CatalogType.Equals("BUILDERS_CLUB")) { Session.SendMessage(PremiumManager.SerializePremiumItemsCount(Session.GetHabbo())); Session.SendMessage(OtanixEnvironment.GetGame().GetCatalogPremium().CatalogPagesCache); } }
public Item GetBaseItem(uint BaseId) { Item Return = OtanixEnvironment.GetGame().GetItemManager().GetItem(BaseId); if (Return == null) { if (BaseId != 0) { Console.WriteLine(@"UNKNOWN BaseId: " + BaseId); } } return(Return); }
internal void BuyTargetedOffer() { uint TargetedId = Request.PopWiredUInt(); TargetedOffer to = OtanixEnvironment.GetGame().GetTargetedOfferManager().GetTargetedOffer(TargetedId); if (to == null) { return; } uint Amount = Request.PopWiredUInt(); if (Session.GetHabbo().TargetedOffers.ContainsKey(TargetedId) && Session.GetHabbo().TargetedOffers[TargetedId] + Amount > to.PurchaseLimit) { return; // ya has alcanzado el límite. } if (Session.GetHabbo().Diamonds < to.PriceInDiamonds) { return; // no tienes suficientes diamantes. } if (OtanixEnvironment.GetUnixTimestamp() > to.ExpirationTime) { return; // fecha finalizada. } Session.GetHabbo().Diamonds -= to.PriceInDiamonds; Session.GetHabbo().UpdateExtraMoneyBalance(); if (Session.GetHabbo().TargetedOffers.ContainsKey(TargetedId)) { Session.GetHabbo().TargetedOffers[TargetedId] += Amount; } else { Session.GetHabbo().TargetedOffers.Add(TargetedId, Amount); } foreach (KeyValuePair <uint, uint> Item in to.Items) { Item item = OtanixEnvironment.GetGame().GetItemManager().GetItem(Item.Key); if (item != null) { for (int i = 0; i < Item.Value; i++) { OtanixEnvironment.GetGame().GetCatalog().DeliverItems(Session, item, 1, "", false, 0); } } } Session.GetHabbo().GetInventoryComponent().UpdateItems(false); }