예제 #1
0
        internal void SaveWardrobe()
        {
            uint SlotId = Request.ReadUInt32();

            string Look   = Request.ReadString();
            string Gender = Request.ReadString();

            //if (!AntiMutant.ValidateLook(Look, Gender))
            //{
            //    return;
            //}

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT null FROM user_wardrobe WHERE user_id = " + Session.GetHabbo().Id + " AND slot_id = " + SlotId + "");
                dbClient.addParameter("look", Look);
                dbClient.addParameter("gender", Gender.ToUpper());

                if (dbClient.getRow() != null)
                {
                    dbClient.setQuery("UPDATE user_wardrobe SET look = @look, gender = @gender WHERE user_id = " + Session.GetHabbo().Id + " AND slot_id = " + SlotId + ";");
                    dbClient.addParameter("look", Look);
                    dbClient.addParameter("gender", Gender.ToUpper());
                    dbClient.runQuery();
                }
                else
                {
                    dbClient.setQuery("INSERT INTO user_wardrobe (user_id,slot_id,look,gender) VALUES (" + Session.GetHabbo().Id + "," + SlotId + ",@look,@gender)");
                    dbClient.addParameter("look", Look);
                    dbClient.addParameter("gender", Gender.ToUpper());
                    dbClient.runQuery();
                }
            }
        }
예제 #2
0
        internal void DeliverBalloonRandomItem(RoomUser User, Room Room, RoomItem Item)
        {
            if (!Piñatas.ContainsKey(Item.GetBaseItem().ItemId))
            {
                return;
            }

            PiñataItem piñata;

            Piñatas.TryGetValue(Item.GetBaseItem().ItemId, out piñata);
            if (piñata == null)
            {
                return;
            }

            // backup de las variables:
            int X = Item.GetX, Y = Item.GetY;

            // Borramos la piñata.
            Item.ExtraData = "1";
            Item.UpdateState();
            Room.GetRoomItemHandler().RemoveFurniture(User.GetClient(), Item);

            uint itemID = EmuSettings.FIRST_BALLOON_PRESENT_ID + (uint)(new Random().Next(0, (int)(EmuSettings.LAST_BALLOON_PRESENT_ID - EmuSettings.FIRST_BALLOON_PRESENT_ID)));

            uint randomId = piñata.rewards[new Random().Next(0, piñata.rewards.Count - 1)];
            Item rareItem = OtanixEnvironment.GetGame().GetItemManager().GetItem(randomId);

            if (rareItem == null)
            {
                return;
            }

            Item.BaseItem  = itemID;
            Item.ExtraData = Item.OwnerId + ";0;" + Furnidata.GetPublicNameByItemName(rareItem.Name);
            Item.SetState(X, Y);

            using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("UPDATE items SET base_id = '" + itemID + "' WHERE item_id = " + Item.Id);

                dbClient.setQuery("UPDATE items_extradata SET data = @extradata WHERE item_id = " + Item.Id);
                dbClient.addParameter("extradata", rareItem.Name);
                dbClient.runQuery();

                dbClient.setQuery("INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES (" + Item.Id + "," + randomId + "," + 1 + ",@extra_data)");
                dbClient.addParameter("extra_data", "");
                dbClient.runQuery();
            }

            if (!Room.GetRoomItemHandler().SetFloorItem(User.GetClient(), Item, Item.GetX, Item.GetY, Item.Rot, true, false, true, false, true))
            {
                User.GetClient().SendNotif("Ha ocurrido un error al crear la piñata!");
                return;
            }
        }
예제 #3
0
        public static void UpdateInDatabase(IWiredTrigger wiredItem, IQueryAdapter dbClient)
        {
            RemoveFromDatabase(wiredItem, dbClient);

            RoomItem item = wiredItem.GetOriginalWiredItem();
            InteractionType type = item.GetBaseItem().InteractionType;

            if (WiredLoaderObject.HasSettings(type))
            {
                string[] data = (wiredItem as IWiredSettingsTrigger).GetSettings();
                dbClient.setQuery("INSERT INTO `wired_data` (`wired_id`, `data_one`, `data_two`, `data_three`, `data_four`) VALUES (@id, @data1, @data2, @data3, @data4) ");
                dbClient.addParameter("id", item.Id);
                dbClient.addParameter("data1", data.Length >= 1 ? data[0] : "");
                dbClient.addParameter("data2", data.Length >= 2 ? data[1] : "");
                dbClient.addParameter("data3", data.Length >= 3 ? data[2] : "");
                dbClient.addParameter("data4", data.Length >= 4 ? data[3] : "");
                dbClient.runQuery();
            }
            if (WiredLoaderObject.HasOriginalItemLocations(type))
            {
                Dictionary<uint, OriginalItemLocation> originalLoc = (wiredItem as IWiredOriginalItemTrigger).GetOriginalItemLocation();

                foreach (OriginalItemLocation itemLoc in originalLoc.Values)
                {
                    dbClient.setQuery("INSERT INTO `wired_original_item_locations` (`wired_id`,`item_id`, `original_x`, `original_y`, `rotation`, `extradata`, `height`) VALUES (@wid, @id, @orx, @ory, @orrot, @data, @height)");
                    dbClient.addParameter("wid", item.Id);
                    dbClient.addParameter("id", itemLoc.itemID);
                    dbClient.addParameter("orx", itemLoc.X);
                    dbClient.addParameter("ory", itemLoc.Y);
                    dbClient.addParameter("orrot", itemLoc.Rot);
                    dbClient.addParameter("data", itemLoc.ExtraData);
                    dbClient.addParameter("height", itemLoc.Height);

                    dbClient.runQuery();
                }
            }
            if (WiredLoaderObject.NeedsFurnitures(type))
            {
                List<RoomItem> items = (wiredItem as IWiredFurniTrigger).getAffectedItemList();
                foreach (RoomItem rItem in items)
                {
                    dbClient.setQuery("INSERT INTO `wired_to_item` (`wired_id`, `trigger_item`) VALUES (@id, @triggeritem)");
                    dbClient.addParameter("id", item.Id);
                    dbClient.addParameter("triggeritem", rItem.Id);
                    dbClient.runQuery();
                }
            }

        }
예제 #4
0
 internal static void SaveTrigger(IQueryAdapter dbClient, int itemID, int triggetItemID)
 {
     dbClient.setQuery("INSERT INTO trigger_in_place (original_trigger,triggers_item) VALUES (@my_id,@trigger_item)");
     dbClient.addParameter("my_id", itemID);
     dbClient.addParameter("trigger_item", triggetItemID);
     dbClient.runQuery();
 }
예제 #5
0
        internal void AddOrExtendSubscription(GameClient Session, string SubscriptionId, int DurationSeconds, uint Cost, int MonthProgress)
        {
            SubscriptionId = SubscriptionId.ToLower();

            var clientByUserId = OtanixEnvironment.GetGame().GetClientManager().GetClientByUserID(UserID);

            if (clubSubscriptions.ContainsKey(SubscriptionId))
            {
                Club Club = clubSubscriptions[SubscriptionId];

                if (Club.IsValid)
                {
                    Club.ExtendSubscription(DurationSeconds);
                }

                else
                {
                    Club.SetEndTime(OtanixEnvironment.GetUnixTimestamp() + DurationSeconds);
                }

                using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE user_subscriptions SET timestamp_expire = timestamp_expire + " + DurationSeconds + " WHERE user_id = " + UserID + " AND subscription_id = '" + Club.SubscriptionId + "'");
                }
                OtanixEnvironment.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(clientByUserId, MonthProgress);
            }

            else
            {
                int TimestampActivated = OtanixEnvironment.GetUnixTimestamp();
                int TimestampExpire    = OtanixEnvironment.GetUnixTimestamp() + DurationSeconds;

                using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("INSERT INTO user_subscriptions (subscription_id, user_id, timestamp_activated, timestamp_expire) VALUES (@subscription_id, @user_id, @timestamp_activated, @timestamp_expire)");
                    dbClient.addParameter("user_id", UserID);
                    dbClient.addParameter("subscription_id", SubscriptionId);
                    dbClient.addParameter("timestamp_activated", TimestampActivated);
                    dbClient.addParameter("timestamp_expire", TimestampExpire);
                    dbClient.runQuery();

                    dbClient.runFastQuery("UPDATE users SET spent_credits = spent_credits + " + Cost + " WHERE id = " + Session.GetHabbo().Id);
                }

                clubSubscriptions.Add(SubscriptionId, new Club(SubscriptionId, TimestampActivated, TimestampExpire, false));

                Session.GetHabbo().SpentCredits += Cost;

                var fuse = new ServerMessage(Outgoing.Fuserights);
                fuse.AppendInt32(Session.GetHabbo().GetClubManager().UserHasSubscription("club_habbo") ? 2 : 1); // normal|hc|vip
                fuse.AppendUInt(Session.GetHabbo().Rank);
                fuse.AppendBoolean(Session.GetHabbo().HasFuse("fuse_ambassador"));                               // embajador ?
                // fuserights.AppendInt32(0); // New Identity (1 == 1 min and Alert!)
                Session.SendMessage(fuse);

                OtanixEnvironment.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(clientByUserId, MonthProgress);
            }
            Session.GetHabbo().UpdateHabboClubStatus();
            Session.GetMessageHandler().ClubCenterData();
        }
예제 #6
0
        public void SaveToDatabase(IQueryAdapter dbClient)
        {
            WiredUtillity.SaveTriggerItem(dbClient, (int)itemID, "integer", string.Empty, delay.ToString(), false);

            if (dbClient.dbType == Pici.Storage.Database.DatabaseType.MSSQL)
            {
                dbClient.runFastQuery("DELETE FROM trigger_rotation WHERE item_id = " + itemID);
                dbClient.setQuery("INSERT INTO trigger_rotation(item_id,rotation_status,movement_status) VALUES (@id,@rot_id,@mov_id)");
            }
            else
            {
                dbClient.setQuery("REPLACE INTO trigger_rotation SET item_id = @id, rotation_status = @rot_id,  movement_status = @mov_id");
            }
            dbClient.addParameter("id", (int)itemID);
            dbClient.addParameter("rot_id", (int)this.rotation);
            dbClient.addParameter("mov_id", (int)this.movement);
            dbClient.runQuery();

            lock (items)
            {
                dbClient.runFastQuery("DELETE FROM trigger_in_place WHERE original_trigger = '" + this.itemID + "'");
                foreach (RoomItem i in items)
                {
                    WiredUtillity.SaveTrigger(dbClient, (int)itemID, (int)i.Id);
                }
            }
        }
예제 #7
0
        internal static void Save()
        {
            if (!enabled)
            {
                return;
            }

            lock (loggedMessages.SyncRoot)
            {
                int totalMessages = loggedMessages.Count;

                if (loggedMessages.Count > 0)
                {
                    DatabaseManager dbManager = new DatabaseManager(300, 5, 1, DatabaseType.MySQL);
                    //To-do: Init dbManager from configuration file

                    using (IQueryAdapter dbClient = dbManager.getQueryreactor())
                    {
                        while (loggedMessages.Count > 0)
                        {
                            Message message = (Message)loggedMessages.Dequeue();

                            dbClient.setQuery("INSERT INTO system_packetlog (connectionid, timestamp, data) VALUES @connectionid @timestamp, @data");
                            dbClient.addParameter("connectionid", message.ConnectionID);
                            dbClient.addParameter("timestamp", message.GetTimestamp);
                            dbClient.addParameter("data", message.GetData);

                            dbClient.runQuery();
                        }
                    }
                }
            }
        }
예제 #8
0
 internal void GiveBadge(string Badge, bool InDatabase, GameClient Session, bool WiredReward = false)
 {
     if (WiredReward)
     {
         Session.SendMessage(this.SerializeBadgeReward(!this.HasBadge(Badge)));
     }
     if (this.HasBadge(Badge))
     {
         return;
     }
     if (InDatabase)
     {
         using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
         {
             queryreactor.setQuery(string.Concat(new object[]
             {
                 "INSERT INTO user_badges (user_id,badge_id,badge_slot) VALUES (",
                 this.UserId,
                 ",@badge,",
                 0,
                 ")"
             }));
             queryreactor.addParameter("badge", Badge);
             queryreactor.runQuery();
         }
     }
     this.Badges.Add(Badge, new Badge(Badge, 0));
     Session.SendMessage(this.SerializeBadge(Badge));
     Session.SendMessage(this.Update(Badge));
 }
예제 #9
0
 internal static void SaveTrigger(IQueryAdapter dbClient, int itemID, int triggetItemID)
 {
     dbClient.setQuery("INSERT INTO trigger_in_place (original_trigger,triggers_item) VALUES (@my_id,@trigger_item)");
     dbClient.addParameter("my_id", itemID);
     dbClient.addParameter("trigger_item", triggetItemID);
     dbClient.runQuery();
 }
예제 #10
0
 internal static void Save()
 {
     if (!MessageLoggerManager.enabled)
     {
         return;
     }
     lock (MessageLoggerManager.loggedMessages.SyncRoot)
     {
         int arg_28_0 = MessageLoggerManager.loggedMessages.Count;
         if (MessageLoggerManager.loggedMessages.Count > 0)
         {
             DatabaseManager databaseManager = new DatabaseManager(1u, 1u);
             using (IQueryAdapter queryreactor = databaseManager.getQueryreactor())
             {
                 while (MessageLoggerManager.loggedMessages.Count > 0)
                 {
                     Message message = (Message)MessageLoggerManager.loggedMessages.Dequeue();
                     queryreactor.setQuery("INSERT INTO system_packetlog (connectionid, timestamp, data) VALUES @connectionid @timestamp, @data");
                     queryreactor.addParameter("connectionid", message.ConnectionID);
                     queryreactor.addParameter("timestamp", message.GetTimestamp);
                     queryreactor.addParameter("data", message.GetData);
                     queryreactor.runQuery();
                 }
             }
         }
     }
 }
예제 #11
0
 public void OnPlace(GameClient Session, RoomItem Item)
 {
     checked
     {
         Item.GetRoom().GetRoomItemHandler().HopperCount++;
         using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
         {
             queryreactor.setQuery("INSERT INTO items_hopper (hopper_id, room_id) VALUES (@hopperid, @roomid);");
             queryreactor.addParameter("hopperid", Item.Id);
             queryreactor.addParameter("roomid", Item.RoomId);
             queryreactor.runQuery();
         }
         if (Item.InteractingUser != 0u)
         {
             RoomUser roomUserByHabbo = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Item.InteractingUser);
             if (roomUserByHabbo != null)
             {
                 roomUserByHabbo.ClearMovement(true);
                 roomUserByHabbo.AllowOverride = false;
                 roomUserByHabbo.CanWalk       = true;
             }
             Item.InteractingUser = 0u;
         }
     }
 }
예제 #12
0
        internal static void Save()
        {
            if (!enabled)
            {
                return;
            }

            lock (loggedMessages.SyncRoot)
            {
                int totalMessages = loggedMessages.Count;

                if (loggedMessages.Count > 0)
                {
                    using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        while (loggedMessages.Count > 0)
                        {
                            Message message = (Message)loggedMessages.Dequeue();

                            dbClient.setQuery("INSERT INTO system_packetlog (connectionid, timestamp, data) VALUES @connectionid @timestamp, @data");
                            dbClient.addParameter("connectionid", message.ConnectionID);
                            dbClient.addParameter("timestamp", message.GetTimestamp);
                            dbClient.addParameter("data", message.GetData);

                            dbClient.runQuery();
                        }
                    }
                }
            }
        }
예제 #13
0
        //Update by Account Id
        public static bool UpdateAccountData_byID(int AccountId, string Username, string Password, string Email, int AccessLevel, string Membership, bool isGM, long LastOnlineUtc, int Coins, string Ip, string Settings, bool IsOnline, bool IsBanned, long UnBanDate)
        {
            if (DbQuerys.UserExists(Username))
            {
                Logger.WriteLine(LogState.Exception, "UpdateAccountData Failure: " + Username + ", already Exists, please choose another!");
                return(false);
            }

            using (IQueryAdapter dbClient = LoginServer.dbManager.getQueryreactor())
            {
                string UpdateAccountQuery = "UPDATE accounts SET Username='******',Password='******',Email='" + Email + "',AccessLevel='" + AccessLevel + "',Membership='" + Membership + "',isGM=" + isGM + ",LastOnlineUtc='" + LastOnlineUtc + "',Coins='" + Coins + "',Ip='" + Ip + "',Settings='" + Settings + "',IsOnline=" + IsOnline + ",IsBanned=" + IsBanned + ",UnBanDate='" + UnBanDate + "' WHERE Id=" + AccountId + ";";
                dbClient.setQuery(UpdateAccountQuery);
                dbClient.addParameter("Username", Username);
                dbClient.addParameter("Password", Password);
                dbClient.addParameter("Email", Email);
                dbClient.addParameter("AccessLevel", AccessLevel);
                dbClient.addParameter("Membership", Membership);
                dbClient.addParameter("isGM", isGM);
                dbClient.addParameter("LastOnlineUtc", LastOnlineUtc);
                dbClient.addParameter("Coins", Coins);
                dbClient.addParameter("Ip", Ip.ToString());
                dbClient.addParameter("Settings", Settings);
                dbClient.addParameter("IsOnline", IsOnline);
                dbClient.addParameter("IsBanned", IsBanned);
                dbClient.addParameter("UnBanDate", UnBanDate);

                dbClient.runQuery();

                Logger.WriteLine(LogState.Info, "Updated AccountId: {0} as {1}.)", AccountId, Username);
                return(true);
            }
        }
예제 #14
0
        //Insert New Account Data
        public static bool InsertAccountData(string Username, string Password, string Email, int AccessLevel, string Membership, bool isGM, long LastOnlineUtc, int Coins, string Ip, string Settings, bool IsOnline, bool IsBanned, long UnBanDate, long RegisterDate)
        {
            if (DbQuerys.UserExists(Username))
            {
                Logger.WriteLine(LogState.Exception, "InsertAccount Failure: " + Username + ", already Exists, please choose another!");
                return(false);
            }
            using (IQueryAdapter dbClient = LoginServer.dbManager.getQueryreactor())
            {
                string AddAccount = "INSERT INTO accounts VALUES(NULL, @Username,@Password,@Email,@AccessLevel,@Membership,@isGM,@LastOnlineUtc,@Coins,@Ip,@Settings,@IsOnline,@IsBanned,@UnBanDate,@RegisterDate)";
                dbClient.setQuery(AddAccount);
                dbClient.addParameter("@Username", Username);
                dbClient.addParameter("@Password", Crypt.StringToMD5(Password));
                dbClient.addParameter("@Email", Email);
                dbClient.addParameter("@AccessLevel", AccessLevel);
                dbClient.addParameter("@Membership", Membership);
                dbClient.addParameter("@isGM", isGM);
                dbClient.addParameter("@LastOnlineUtc", LastOnlineUtc);
                dbClient.addParameter("@Coins", Coins);
                dbClient.addParameter("@Ip", Ip);
                dbClient.addParameter("@Settings", Settings);
                dbClient.addParameter("@IsOnline", IsOnline);
                dbClient.addParameter("@IsBanned", IsBanned);
                dbClient.addParameter("@UnBanDate", UnBanDate);
                dbClient.addParameter("@RegisterDate", RegisterDate);
                dbClient.runQuery();

                Logger.WriteLine(LogState.Info, "Inserted Account: {0} successfully.)", Username);
                return(true);
            }
        }
예제 #15
0
        internal void RecycleItem()
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            int ItemsCount = Request.PopWiredInt32(); // 5

            for (int i = 0; i < ItemsCount; i++)
            {
                uint ItemId = Request.PopWiredUInt();

                if (!Session.GetHabbo().GetInventoryComponent().ContainsItem(ItemId))
                {
                    return;
                }

                Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId, true);
            }

            uint          newItemId;
            EcotronReward Reward = OtanixEnvironment.GetGame().GetCatalog().GetRandomEcotronReward();

            if (Reward == null)
            {
                return;
            }

            using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("INSERT INTO items (base_id) VALUES (" + EmuSettings.FURNIMATIC_BOX_ITEMID + ")");
                newItemId = (uint)dbClient.insertQuery();

                dbClient.runFastQuery("INSERT INTO items_users VALUES (" + newItemId + "," + Session.GetHabbo().Id + ")");

                dbClient.setQuery("INSERT INTO items_extradata VALUES (" + newItemId + ",@data)");
                dbClient.addParameter("data", DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day);
                dbClient.runQuery();

                dbClient.runFastQuery("INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES (" + newItemId + "," + Reward.BaseId + ",1,'')");
            }

            UserItem u = Session.GetHabbo().GetInventoryComponent().AddNewItem(newItemId, (uint)EmuSettings.FURNIMATIC_BOX_ITEMID, DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day, false, false, false, Reward.GetBaseItem().Name, Session.GetHabbo().Id, 0);

            Session.GetMessageHandler().GetResponse().Init(Outgoing.SendPurchaseAlert);
            Session.GetMessageHandler().GetResponse().AppendInt32(1); // items
            Session.GetMessageHandler().GetResponse().AppendInt32(1); // type (gift) == s
            Session.GetMessageHandler().GetResponse().AppendInt32(1);
            Session.GetMessageHandler().GetResponse().AppendUInt(u.Id);
            Session.GetMessageHandler().SendResponse();

            Session.GetHabbo().GetInventoryComponent().UpdateItems(false);

            Response.Init(Outgoing.FurniMaticReceiveItem);
            Response.AppendInt32(1);
            Response.AppendUInt(newItemId);
            SendResponse();
        }
예제 #16
0
        public void SaveToDatabase(IQueryAdapter dbClient)
        {
            dbClient.setQuery("REPLACE INTO trigger_item SET trigger_id = @id, trigger_input = 'integer',  trigger_data = @trigger_data , all_user_triggerable = 0");

            dbClient.addParameter("id", (int)this.item.Id);
            dbClient.addParameter("trigger_data", timeout);
            dbClient.runQuery();
        }
예제 #17
0
		internal static void SaveMessage(IQueryAdapter dbClient, uint ToId, uint FromId, string Message)
		{
			dbClient.setQuery("INSERT INTO messenger_offline_messages (to_id, from_id, message, timestamp) VALUES (@tid, @fid, @msg, UNIX_TIMESTAMP())");
			dbClient.addParameter("tid", ToId);
			dbClient.addParameter("fid", FromId);
			dbClient.addParameter("msg", Message);
			dbClient.runQuery();
		}
예제 #18
0
 internal static void SaveMessage(IQueryAdapter dbClient, uint ToId, uint FromId, string Message)
 {
     dbClient.setQuery("INSERT INTO messenger_offline_messages (to_id, from_id, message, timestamp) VALUES (@tid, @fid, @msg, UNIX_TIMESTAMP())");
     dbClient.addParameter("tid", ToId);
     dbClient.addParameter("fid", FromId);
     dbClient.addParameter("msg", Message);
     dbClient.runQuery();
 }
예제 #19
0
        public void SaveToDatabase(IQueryAdapter dbClient)
        {
            dbClient.setQuery("REPLACE INTO trigger_item SET trigger_id = @id, trigger_input = 'integer',  trigger_data = @trigger_data , all_user_triggerable = 0");

            dbClient.addParameter("id", (int)this.item.Id);
            dbClient.addParameter("trigger_data", timeout);
            dbClient.runQuery();
        }
예제 #20
0
 internal static void SaveAchievement(Achievement achievement)
 {
     using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
     {
         dbClient.setQuery("UPDATE achievement_info SET level = " + achievement.Level + ", progress = " + achievement.Progress);
         dbClient.runQuery();
     }
 }
예제 #21
0
 internal void LoadAlfaLog(UInt32 UserId, String ReportType, String Text, Int32 VoteValue)
 {
     using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
     {
         dbClient.setQuery("INSERT INTO user_alfas_logs VALUES (NULL,'" + UserId + "','" + ReportType + "',@text,'" + VoteValue + "')");
         dbClient.addParameter("text", Text);
         dbClient.runQuery();
     }
 }
예제 #22
0
 private static void TryDeleteVoucher(string Code)
 {
     using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
     {
         dbClient.setQuery("DELETE FROM credit_vouchers WHERE code = @code");
         dbClient.addParameter("code", Code);
         dbClient.runQuery();
     }
 }
예제 #23
0
        internal void DeliverPiñataRandomItem(RoomUser user, Room room, RoomItem item)
        {
            if (room == null)
            {
                return;
            }

            if (item == null)
            {
                return;
            }

            if (item.GetBaseItem().InteractionType != InteractionType.piñata && item.GetBaseItem().InteractionType != InteractionType.dalia)
            {
                return;
            }

            if (!Piñatas.ContainsKey(item.GetBaseItem().ItemId))
            {
                return;
            }

            PiñataItem piñata;

            Piñatas.TryGetValue(item.GetBaseItem().ItemId, out piñata);
            if (piñata == null)
            {
                return;
            }

            // backup de las variables:
            int X = item.GetX, Y = item.GetY;

            // Borramos la piñata.
            room.GetRoomItemHandler().RemoveFurniture(user.GetClient(), item);

            int randomId = new Random().Next(piñata.rewards.Count - 1);

            item.BaseItem  = piñata.rewards[randomId];
            item.ExtraData = "0";
            item.SetState(X, Y);

            using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("UPDATE items SET base_id = '" + item.BaseItem + "' WHERE item_id = " + item.Id);
                dbClient.setQuery("UPDATE items_extradata SET data = @extradata WHERE item_id = " + item.Id);
                dbClient.addParameter("extradata", item.ExtraData);
                dbClient.runQuery();
            }

            if (!room.GetRoomItemHandler().SetFloorItem(user.GetClient(), item, item.GetX, item.GetY, item.Rot, true, false, true, false, true))
            {
                user.GetClient().SendNotif("Ha ocurrido un error al crear la piñata!");
                return;
            }
        }
예제 #24
0
 internal void DeleteGroup(uint Id)
 {
     using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
     {
         queryreactor.setQuery("DELETE FROM group_memberships WHERE group_id=@id;DELETE FROM group_requests WHERE group_id=@id;DELETE FROM groups WHERE id=@id LIMIT 1;");
         queryreactor.addParameter("id", Id);
         queryreactor.runQuery();
         this.Groups.Remove(Id);
     }
 }
예제 #25
0
        /// <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);
        }
예제 #26
0
 internal void LogStaffEntry(string modName, string target, string type, string description)
 {
     using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
     {
         dbClient.setQuery("INSERT INTO staff_logs (staffuser,target,action_type,description) VALUES (@username,@target,@type,@desc)");
         dbClient.addParameter("username", modName);
         dbClient.addParameter("target", target);
         dbClient.addParameter("type", type);
         dbClient.addParameter("desc", description);
         dbClient.runQuery();
     }
 }
예제 #27
0
 internal void UnbanUser(string usernameOrIP)
 {
     new List <ModerationBan>();
     this.bannedUsernames.Remove(usernameOrIP);
     this.bannedIPs.Remove(usernameOrIP);
     using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
     {
         queryreactor.setQuery("DELETE FROM bans WHERE value = @userorip");
         queryreactor.addParameter("userorip", usernameOrIP);
         queryreactor.runQuery();
     }
 }
예제 #28
0
 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();
         }
     }
 }
예제 #29
0
 internal void Save(uint RoomId)
 {
     using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
     {
         queryreactor.setQuery("REPLACE INTO chatlogs (user_id, room_id, timestamp, message) VALUES (@user, @room, @time, @message)");
         queryreactor.addParameter("user", this.UserId);
         queryreactor.addParameter("room", RoomId);
         queryreactor.addParameter("time", this.Timestamp);
         queryreactor.addParameter("message", this.Message);
         queryreactor.runQuery();
     }
 }
예제 #30
0
        internal void ChangeMotto()
        {
            string Motto = FirewindEnvironment.FilterInjectionChars(Request.ReadString());

            if (Motto.Length == 0 || Motto == Session.GetHabbo().Motto) // Prevents spam?
            {
                return;
            }

            //if (Motto.Length < 0)
            //{
            //    return; // trying to fk the client :D
            //} Congratulations. The string length can not hold calue < 0. Stupid -_-"

            Session.GetHabbo().Motto = Motto;


            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("UPDATE users SET motto = @motto WHERE id = '" + Session.GetHabbo().Id + "'");
                dbClient.addParameter("motto", Motto);
                dbClient.runQuery();
            }

            FirewindEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, HabboHotel.Quests.QuestType.PROFILE_CHANGE_MOTTO);

            if (Session.GetHabbo().InRoom)
            {
                Room Room = Session.GetHabbo().CurrentRoom;

                if (Room == null)
                {
                    return;
                }

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

                if (User == null)
                {
                    return;
                }

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

            FirewindEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_Motto", 1);
        }
예제 #31
0
        internal static void SaveTriggerItem(IQueryAdapter dbClient, int triggerID, string triggerInput, string triggerData2, string triggerData, bool allUsertriggerable)
        {
            dbClient.runFastQuery("DELETE FROM trigger_item WHERE trigger_id = " + triggerID);
            dbClient.setQuery("INSERT INTO trigger_item (trigger_id,trigger_input,trigger_data,trigger_data_2,all_user_triggerable) VALUES (@id,@triggerinput,@trigger_data,@trigger_data_2,@triggerable)");

            dbClient.addParameter("id", triggerID);
            dbClient.addParameter("triggerinput", triggerInput);
            dbClient.addParameter("trigger_data", triggerData);
            dbClient.addParameter("trigger_data_2", triggerData2);
            dbClient.addParameter("triggerable", allUsertriggerable ? 1 : 0);

            dbClient.runQuery();
        }
예제 #32
0
        internal static void SaveTriggerItem(IQueryAdapter dbClient, int triggerID, string triggerInput, string triggerData2, string triggerData, bool allUsertriggerable)
        {
            dbClient.runFastQuery("DELETE FROM trigger_item WHERE trigger_id = " + triggerID);
            dbClient.setQuery("INSERT INTO trigger_item (trigger_id,trigger_input,trigger_data,trigger_data_2,all_user_triggerable) VALUES (@id,@triggerinput,@trigger_data,@trigger_data_2,@triggerable)");

            dbClient.addParameter("id", triggerID);
            dbClient.addParameter("triggerinput", triggerInput);
            dbClient.addParameter("trigger_data", triggerData);
            dbClient.addParameter("trigger_data_2", triggerData2);
            dbClient.addParameter("triggerable", allUsertriggerable ? 1 : 0);

            dbClient.runQuery();
        }
예제 #33
0
 internal void Execute(IQueryAdapter dbClient)
 {
     if (this.queryCount == 0)
     {
         return;
     }
     this.queries = this.queries.Remove(checked (this.queries.Length - 1), 1);
     dbClient.setQuery(this.queries.ToString());
     foreach (KeyValuePair <string, object> current in this.parameters)
     {
         dbClient.addParameter(current.Key, current.Value);
     }
     dbClient.runQuery();
 }
예제 #34
0
		internal void Execute(IQueryAdapter dbClient)
		{
			if (this.queryCount == 0)
			{
				return;
			}
			this.queries = this.queries.Remove(checked(this.queries.Length - 1), 1);
			dbClient.setQuery(this.queries.ToString());
			foreach (KeyValuePair<string, object> current in this.parameters)
			{
				dbClient.addParameter(current.Key, current.Value);
			}
			dbClient.runQuery();
		}
예제 #35
0
        internal void UnbanUser(string usernameOrIP)
        {
            List <ModerationBan> toRemove = new List <ModerationBan>();

            bannedUsernames.Remove(usernameOrIP);
            bannedIPs.Remove(usernameOrIP);

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("DELETE FROM bans WHERE value = @userorip");
                dbClient.addParameter("userorip", usernameOrIP);
                dbClient.runQuery();
            }
        }
예제 #36
0
 public static void RemoveFromDatabase(IWiredTrigger wiredItem, IQueryAdapter dbClient)
 {
     RoomItem item = wiredItem.GetOriginalWiredItem();
     InteractionType type = item.GetBaseItem().InteractionType;
     if(WiredLoaderObject.HasSettings(type))
     {
         dbClient.setQuery("DELETE FROM wired_data WHERE wired_id = @id");
         dbClient.addParameter("id", item.Id);
         dbClient.runQuery();
     }
     if (WiredLoaderObject.HasOriginalItemLocations(type))
     {
         dbClient.setQuery("DELETE FROM wired_original_item_locations WHERE wired_id = @id");   
         dbClient.addParameter("id", item.Id);
         dbClient.runQuery();
     }
     if (WiredLoaderObject.NeedsFurnitures(type))
     {
         dbClient.setQuery("DELETE FROM wired_to_item WHERE wired_id = @id");
         dbClient.addParameter("id", item.Id);
         dbClient.runQuery();
     }
 }
예제 #37
0
파일: QueryChunk.cs 프로젝트: BjkGkh/R106
        internal void Execute(IQueryAdapter dbClient)
        {
            if (queryCount == 0)
                return;

            queries = queries.Remove(queries.Length - 1, 1);
            dbClient.setQuery(queries.ToString());

            foreach (KeyValuePair<string, object> parameter in parameters)
            {
                dbClient.addParameter(parameter.Key, parameter.Value);
            }

            dbClient.runQuery();
        }
예제 #38
0
 internal void RemoveBadge(string Badge, GameClient Session)
 {
     if (!this.HasBadge(Badge))
     {
         return;
     }
     using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
     {
         queryreactor.setQuery("DELETE FROM user_badges WHERE badge_id = @badge AND user_id = " + this.UserId + " LIMIT 1");
         queryreactor.addParameter("badge", Badge);
         queryreactor.runQuery();
     }
     this.Badges.Remove(this.GetBadge(Badge));
     Session.SendMessage(this.Serialize());
 }
예제 #39
0
파일: MoveRotate.cs 프로젝트: habb0/Bfly
        public void SaveToDatabase(IQueryAdapter dbClient)
        {
            WiredUtillity.SaveTriggerItem(dbClient, (int)itemID, "integer", string.Empty, delay.ToString(), false);

            if (dbClient.dbType == Database_Manager.Database.DatabaseType.MSSQL)
            {
                dbClient.runFastQuery("DELETE FROM trigger_rotation WHERE item_id = " + itemID);
                dbClient.setQuery("INSERT INTO trigger_rotation(item_id,rotation_status,movement_status) VALUES (@id,@rot_id,@mov_id)");
            }
            else
                dbClient.setQuery("REPLACE INTO trigger_rotation SET item_id = @id, rotation_status = @rot_id,  movement_status = @mov_id");
            dbClient.addParameter("id", (int)itemID);
            dbClient.addParameter("rot_id", (int)this.rotation);
            dbClient.addParameter("mov_id", (int)this.movement);
            dbClient.runQuery();

            lock (items)
            {
                dbClient.runFastQuery("DELETE FROM trigger_in_place WHERE original_trigger = '" + this.itemID + "'");
                foreach (RoomItem i in items)
                {
                    WiredUtillity.SaveTrigger(dbClient, (int)itemID, (int)i.Id);
                }
            }
        }
예제 #40
0
        public void SaveToDatabase(IQueryAdapter dbClient)
        {
            WiredUtillity.SaveTriggerItem(dbClient, (int)itemID, "integer", string.Empty, "0", false);
            lock (items)
            {
                dbClient.runFastQuery("DELETE FROM trigger_in_place WHERE original_trigger = '" + this.itemID + "'");
                State.Clear();
                Pos.Clear();
                Rot.Clear();
                foreach (RoomItem i in items)
                {
                    if (i != null)
                    {
                        if (WiredUtillity.TypeIsWired(i.GetBaseItem().InteractionType))
                            MatchState = 0;
                        dbClient.setQuery("INSERT INTO trigger_in_place (original_trigger,triggers_item, extradata) VALUES (@my_id,@trigger_item,@extra)");
                        dbClient.addParameter("my_id", itemID);
                        dbClient.addParameter("trigger_item", i.Id);
                        dbClient.addParameter("extra", MatchState + "-" + i.ExtraData + ";" + MatchRot + "-" + i.Rot + ";" + MatchPos + "-" + i.GetX + "," + i.GetY);
                        dbClient.runQuery();

                        if (MatchPos == 1)
                        {
                            Pos.Add(i, new Point(i.GetX, i.GetY));
                        }
                        if (MatchRot == 1)
                        {
                            Rot.Add(i, i.Rot);
                        }
                        if (MatchState == 1)
                        {
                            State.Add(i, i.ExtraData);
                        }
                    }
                }
            }
        }
예제 #41
0
        public void SaveToDatabase(IQueryAdapter dbClient)
        {
            if (dbClient.dbType == Pici.Storage.Database.DatabaseType.MSSQL)
            {
                dbClient.runFastQuery("DELETE FROM trigger_item WHERE trigger_id = " + item.Id);
                dbClient.setQuery("REPLACE INTO trigger_item SET trigger_id = @id, trigger_input = 'integer',  trigger_data = @trigger_data , all_user_triggerable = 0");
            }
            else
                dbClient.setQuery("REPLACE INTO trigger_item SET trigger_id = @id, trigger_input = 'integer',  trigger_data = @trigger_data , all_user_triggerable = 0");

            dbClient.addParameter("id", (int)this.item.Id);
            dbClient.addParameter("trigger_data", timeout);
            dbClient.runQuery();
        }