private bool CanChangeName(Habbo Habbo)
        {
            if (Habbo.Rank == 1 && Habbo.VIPRank == 0 && Habbo.LastNameChange == 0)
            {
                return(true);
            }
            if (Habbo.Rank == 1 && Habbo.VIPRank == 1 &&
                (Habbo.LastNameChange == 0 || (QuasarEnvironment.GetUnixTimestamp() + 604800) > Habbo.LastNameChange))
            {
                return(true);
            }
            if (Habbo.Rank == 1 && Habbo.VIPRank == 2 &&
                (Habbo.LastNameChange == 0 || (QuasarEnvironment.GetUnixTimestamp() + 86400) > Habbo.LastNameChange))
            {
                return(true);
            }
            if (Habbo.Rank == 1 && Habbo.VIPRank == 3)
            {
                return(true);
            }
            if (Habbo.GetPermissions().HasRight("mod_tool"))
            {
                return(true);
            }

            return(false);
        }
 public PetInformationComposer(Habbo Habbo)
     : base(ServerPacketHeader.PetInformationMessageComposer)
 {
     base.WriteInteger(Habbo.Id);
     base.WriteString(Habbo.Username);
     base.WriteInteger(Habbo.Rank);
     base.WriteInteger(10);
     base.WriteInteger(0);
     base.WriteInteger(0);
     base.WriteInteger(100);
     base.WriteInteger(100);
     base.WriteInteger(100);
     base.WriteInteger(100);
     base.WriteInteger(Habbo.GetStats().Respect);
     base.WriteInteger(Habbo.Id);
     base.WriteInteger(Convert.ToInt32(Math.Floor((QuasarEnvironment.GetUnixTimestamp() - Habbo.AccountCreated) / 86400))); //How?
     base.WriteString(Habbo.Username);
     base.WriteInteger(1);                                                                                                  //3 on hab
     base.WriteBoolean(false);
     base.WriteBoolean(false);
     base.WriteInteger(0); //5 on hab
     base.WriteInteger(0); // Anyone can ride horse
     base.WriteInteger(0);
     base.WriteInteger(0); //512 on hab
     base.WriteInteger(0); //1536
     base.WriteInteger(0); //2560
     base.WriteInteger(0); //3584
     base.WriteInteger(0);
     base.WriteString("");
     base.WriteBoolean(false);
     base.WriteInteger(-1);//255 on hab
     base.WriteInteger(-1);
     base.WriteInteger(-1);
     base.WriteBoolean(false);
 }
Exemple #3
0
        public ProfileInformationComposer(Habbo Data, GameClient Session, List <Group> Groups, int friendCount)
            : base(ServerPacketHeader.ProfileInformationMessageComposer)
        {
            DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Data.AccountCreated);

            base.WriteInteger(Data.Id);
            base.WriteString(Data.Username);
            base.WriteString(Data.Look);
            base.WriteString(Data.Motto);
            base.WriteString(origin.ToString("dd/MM/yyyy"));
            base.WriteInteger(Data.GetStats().AchievementPoints);
            base.WriteInteger(friendCount);                                                                                                                                                 // Friend Count
            base.WriteBoolean(Data.Id != Session.GetHabbo().Id&& Session.GetHabbo().GetMessenger().FriendshipExists(Data.Id));                                                              //  Is friend
            base.WriteBoolean(Data.Id != Session.GetHabbo().Id&& !Session.GetHabbo().GetMessenger().FriendshipExists(Data.Id) && Session.GetHabbo().GetMessenger().RequestExists(Data.Id)); // Sent friend request
            base.WriteBoolean((QuasarEnvironment.GetGame().GetClientManager().GetClientByUserID(Data.Id)) != null);

            base.WriteInteger(Groups.Count);
            foreach (Group Group in Groups)
            {
                base.WriteInteger(Group.Id);
                base.WriteString(Group.Name);
                base.WriteString(Group.Badge);
                base.WriteString(QuasarEnvironment.GetGame().GetGroupManager().GetGroupColour(Group.Colour1, true));
                base.WriteString(QuasarEnvironment.GetGame().GetGroupManager().GetGroupColour(Group.Colour2, false));
                base.WriteBoolean(Data.GetStats().FavouriteGroupId == Group.Id); // todo favs
                base.WriteInteger(0);                                            //what the f**k
                base.WriteBoolean(Group != null ? Group.ForumEnabled : true);    //HabboTalk
            }

            base.WriteInteger(Convert.ToInt32(QuasarEnvironment.GetUnixTimestamp() - Data.LastOnline)); // Last online
            base.WriteBoolean(true);                                                                    // Show the profile
        }
        public void BanzaiStart()
        {
            if (banzaiStarted)
            {
                return;
            }

            floorMap    = new byte[_room.GetGameMap().Model.MapSizeY, _room.GetGameMap().Model.MapSizeX];
            field       = new GameField(floorMap, true);
            timestarted = QuasarEnvironment.GetUnixTimestamp();
            _room.GetGameManager().LockGates();
            for (int i = 1; i < 5; i++)
            {
                _room.GetGameManager().Points[i] = 0;
            }

            foreach (Item tile in _banzaiTiles.Values)
            {
                tile.ExtraData = "1";
                tile.value     = 0;
                tile.team      = TEAM.NONE;
                tile.UpdateState();
            }

            this.ResetTiles();
            banzaiStarted = true;

            _room.GetWired().TriggerEvent(WiredBoxType.TriggerGameStarts, null);

            foreach (RoomUser user in _room.GetRoomUserManager().GetRoomUsers())
            {
                user.LockedTilesCount = 0;
            }
        }
        public ForumsListDataComposer(ICollection <GroupForum> Forums, GameClient Session, int ViewOrder = 0, int StartIndex = 0, int MaxLength = 20)
            : base(ServerPacketHeader.ForumsListDataMessageComposer)
        {
            base.WriteInteger(ViewOrder);
            base.WriteInteger(StartIndex);
            base.WriteInteger(StartIndex);

            base.WriteInteger(Forums.Count); // Forum List Count

            foreach (var Forum in Forums)
            {
                var lastpost = Forum.GetLastPost();
                var isn      = lastpost == null;
                base.WriteInteger(Forum.Id);                                                                  //Maybe ID
                base.WriteString(Forum.Name);                                                                 //Forum name
                base.WriteString(Forum.Description);                                                          //idk
                base.WriteString(Forum.Group.Badge);                                                          // Group Badge
                base.WriteInteger(0);                                                                         //Idk
                base.WriteInteger(0);                                                                         // Score
                base.WriteInteger(Forum.MessagesCount);                                                       //Message count
                base.WriteInteger(Forum.UnreadMessages(Session.GetHabbo().Id));                               //unread message count
                base.WriteInteger(0);                                                                         //Idk
                base.WriteInteger(!isn ? lastpost.GetAuthor().Id : 0);                                        // Las user to message id
                base.WriteString(!isn ? lastpost.GetAuthor().Username : "");                                  //Last user to message name
                base.WriteInteger(!isn ? (int)QuasarEnvironment.GetUnixTimestamp() - lastpost.Timestamp : 0); //Last message timestamp
            }
        }
Exemple #6
0
 public ModeratorSupportTicketComposer(SupportTicket Ticket)
     : base(ServerPacketHeader.ModeratorSupportTicketMessageComposer)
 {
     base.WriteInteger(Ticket.Id);
     base.WriteInteger(Ticket.TabId);
     base.WriteInteger(1);   // Type
     base.WriteInteger(114); // Category
     base.WriteInteger(((int)QuasarEnvironment.GetUnixTimestamp() - (int)Ticket.Timestamp) * 1000);
     base.WriteInteger(Ticket.Score);
     base.WriteInteger(0);
     base.WriteInteger(Ticket.SenderId);
     base.WriteString(Ticket.SenderName);
     base.WriteInteger(Ticket.ReportedId);
     base.WriteString(Ticket.ReportedName);
     base.WriteInteger((Ticket.Status == TicketStatus.PICKED) ? Ticket.ModeratorId : 0);
     base.WriteString(Ticket.ModName);
     base.WriteString(Ticket.Message);
     base.WriteInteger(0); //No idea?
     base.WriteInteger(0); //String, int, int - this is the "matched to" a string
     {
         base.WriteString("fresh-hotel.org");
         base.WriteInteger(-1);
         base.WriteInteger(-1);
     }
 }
Exemple #7
0
        internal ServerPacket Serialize()
        {
            var message = new ServerPacket(ServerPacketHeader.openBoxTargetedOffert);

            message.WriteInteger(Open ? 4 : 1);
            message.WriteInteger(Id);
            message.WriteString(Code);
            message.WriteString(Code);
            message.WriteInteger(int.Parse(Price[0]));
            message.WriteInteger(int.Parse(Price[1]));
            message.WriteInteger(MoneyCode(MoneyType));
            message.WriteInteger(Limit);
            message.WriteInteger(Time - QuasarEnvironment.GetUnixTimestamp());
            message.WriteString(Title);
            message.WriteString(Description);
            message.WriteString(Image);
            message.WriteString(Icon);
            message.WriteInteger(0);
            message.WriteInteger(Products.Count);
            foreach (var product in Products)
            {
                message.WriteString(string.Empty);
            }
            return(message);
        }
Exemple #8
0
        public bool IncrementAndCheckFlood(out int MuteTime)
        {
            MuteTime = 0;

            ChatSpamCount++;
            if (ChatSpamTicks == -1)
            {
                ChatSpamTicks = 8;
            }
            else if (ChatSpamCount >= 6)
            {
                if (GetClient().GetHabbo().GetPermissions().HasRight("events_staff"))
                {
                    MuteTime = 3;
                }
                else if (GetClient().GetHabbo().GetPermissions().HasRight("gold_vip"))
                {
                    MuteTime = 1;
                }
                else if (GetClient().GetHabbo().GetPermissions().HasRight("silver_vip"))
                {
                    MuteTime = 1;
                }
                else
                {
                    MuteTime = 20;
                }

                GetClient().GetHabbo().FloodTime = QuasarEnvironment.GetUnixTimestamp() + MuteTime;

                ChatSpamCount = 0;
                return(true);
            }
            return(false);
        }
Exemple #9
0
 public HelperCase(GameClient client, string msg, int category)
 {
     Session         = client;
     Message         = msg;
     Type            = (HelpCaseType)category;
     Expire          = (int)QuasarEnvironment.GetUnixTimestamp() + HelperToolsManager.ANSWER_CALL_WAIT_TIME;
     DeclinedHelpers = new List <HabboHelper>();
 }
 public RoomPromotion(string Name, string Desc, int CategoryId)
 {
     this._name             = Name;
     this._description      = Desc;
     this._timestampStarted = QuasarEnvironment.GetUnixTimestamp();
     this._timestampExpires = (QuasarEnvironment.GetUnixTimestamp()) + (QuasarStaticGameSettings.RoomPromotionLifeTime * 60);
     this._categoryId       = CategoryId;
 }
 public void AddChatlog(int Id, string Message)
 {
     using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
     {
         dbClient.SetQuery("INSERT INTO `chatlogs` (user_id, room_id, message, timestamp) VALUES (@user, @room, @message, @time)");
         dbClient.AddParameter("user", Id);
         dbClient.AddParameter("room", RoomId);
         dbClient.AddParameter("message", Message);
         dbClient.AddParameter("time", QuasarEnvironment.GetUnixTimestamp());
         dbClient.RunQuery();
     }
 }
        public void PlayPlaylist()
        {
            bool flag = this.Playlist.Count == 0;

            if (!flag)
            {
                this.StartedPlayTimestamp = checked ((int)QuasarEnvironment.GetUnixTimestamp());
                this.SelectedDiscItem     = null;
                this.IsPlaying            = true;
                this.SetJukeboxesState();
            }
        }
        public void AddBan(int pId, long Time)
        {
            if (!Bans.ContainsKey(Convert.ToInt32(pId)))
            {
                Bans.Add(pId, QuasarEnvironment.GetUnixTimestamp() + Time);
            }

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("REPLACE INTO `room_bans` VALUES (" + pId + ", " + Id + ", " + (QuasarEnvironment.GetUnixTimestamp() + Time) + ")");
            }
        }
 public void LogCommand(int UserId, string Data, string MachineId)
 {
     using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
     {
         dbClient.SetQuery("INSERT INTO `logs_client_staff` (`user_id`,`data_string`,`machine_id`, `timestamp`) VALUES (@UserId,@Data,@MachineId,@Timestamp)");
         dbClient.AddParameter("UserId", UserId);
         dbClient.AddParameter("Data", Data);
         dbClient.AddParameter("MachineId", MachineId);
         dbClient.AddParameter("Timestamp", QuasarEnvironment.GetUnixTimestamp());
         dbClient.RunQuery();
     }
 }
Exemple #15
0
        internal void SerializeClub(ServerPacket Message, GameClients.GameClient Session)
        {
            Message.WriteInteger(Id);
            Message.WriteString(Name);
            Message.WriteBoolean(false);
            Message.WriteInteger(CostCredits);
            Message.WriteInteger((CostDiamonds > 0) ? CostDiamonds : CostDiamonds);
            Message.WriteInteger((CostDiamonds > 0) ? 105 : 0);
            Message.WriteBoolean(true); // don't know
            int Days   = 0;
            int Months = 0;

            if (GetBaseItem(ItemId).InteractionType == InteractionType.club_1_month || GetBaseItem(ItemId).InteractionType == InteractionType.club_3_month || GetBaseItem(ItemId).InteractionType == InteractionType.club_6_month)
            {
                switch (GetBaseItem(ItemId).InteractionType)
                {
                case InteractionType.club_1_month:
                    Months = 1;
                    break;

                case InteractionType.club_3_month:
                    Months = 3;
                    break;

                case InteractionType.club_6_month:
                    Months = 6;
                    break;
                }

                Days = 31 * Months;
            }

            DateTime future = DateTime.Now;

            if (Session.GetHabbo().GetClubManager().HasSubscription("habbo_vip"))
            {
                Double Expire        = Session.GetHabbo().GetClubManager().GetSubscription("habbo_vip").ExpireTime;
                Double TimeLeft      = Expire - QuasarEnvironment.GetUnixTimestamp();
                int    TotalDaysLeft = (int)Math.Ceiling(TimeLeft / 86400);
                future = DateTime.Now.AddDays(TotalDaysLeft);
            }

            future = future.AddDays(Days);

            Message.WriteInteger(Months);       // months
            Message.WriteInteger(Days);         // days
            Message.WriteBoolean(true);
            Message.WriteInteger(Days);         // wtf
            Message.WriteInteger(future.Year);  // year
            Message.WriteInteger(future.Month); // month
            Message.WriteInteger(future.Day);   // day
        }
Exemple #16
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            int UserId = Packet.PopInt();
            int RoomId = Packet.PopInt();
            int Time   = Packet.PopInt();

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            if (((Room.WhoCanMute == 0 && !Room.CheckRights(Session, true) && Room.Group == null) || (Room.WhoCanMute == 1 && !Room.CheckRights(Session)) && Room.Group == null) || (Room.Group != null && !Room.CheckRights(Session, false, true)))
            {
                return;
            }

            RoomUser Target = Room.GetRoomUserManager().GetRoomUserByHabbo(QuasarEnvironment.GetUsernameById(UserId));

            if (Target == null)
            {
                return;
            }
            else if (Target.GetClient().GetHabbo().GetPermissions().HasRight("mod_tool"))
            {
                return;
            }

            if (Room.MutedUsers.ContainsKey(UserId))
            {
                if (Room.MutedUsers[UserId] < QuasarEnvironment.GetUnixTimestamp())
                {
                    Room.MutedUsers.Remove(UserId);
                }
                else
                {
                    return;
                }
            }

            Room.MutedUsers.Add(UserId, (QuasarEnvironment.GetUnixTimestamp() + (Time * 60)));

            Target.GetClient().SendWhisper("Je hebt een spreekverbod voor " + Time + " minuten!");
            QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModMuteSeen", 1);
        }
 public Quest(int Id, string Category, int Number, QuestType GoalType, int GoalData, string Name, int Reward, string DataBit, int RewardType, int TimeUnlock, int TimeLock)
 {
     this.Id         = Id;
     this.Category   = Category;
     this.Number     = Number;
     this.GoalType   = GoalType;
     this.GoalData   = GoalData;
     this.Name       = Name;
     this.Reward     = Reward;
     this.DataBit    = DataBit;
     this.RewardType = RewardType;
     this.TimeUnlock = TimeUnlock;
     this.HasEnded   = (TimeLock >= QuasarEnvironment.GetUnixTimestamp() && TimeLock > 0) ? true : false;
 }
        public bool HasBanExpired(int pId)
        {
            if (!UserIsBanned(pId))
            {
                return(true);
            }

            if (Bans[pId] < QuasarEnvironment.GetUnixTimestamp())
            {
                return(true);
            }

            return(false);
        }
Exemple #19
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().GetPermissions().HasRight("mod_trade_lock"))
            {
                return;
            }

            int    UserId   = Packet.PopInt();
            string Message  = Packet.PopString();
            double Days     = (Packet.PopInt() / 1440);
            string Unknown1 = Packet.PopString();
            string Unknown2 = Packet.PopString();

            double Length = (QuasarEnvironment.GetUnixTimestamp() + (Days * 86400));

            Habbo Habbo = QuasarEnvironment.GetHabboById(UserId);

            if (Habbo == null)
            {
                Session.SendWhisper("Oeps! Deze gebruiker kan niet worden gevonden.");
                return;
            }

            if (Habbo.GetPermissions().HasRight("mod_trade_lock") && !Session.GetHabbo().GetPermissions().HasRight("mod_trade_lock_any"))
            {
                Session.SendWhisper("Oeps! Je hebt niet de bevoegdheid om deze gebruiker een ruil blokkering op te leggen.");
                return;
            }

            if (Days < 1)
            {
                Days = 1;
            }

            if (Days > 365)
            {
                Days = 365;
            }

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("UPDATE `user_info` SET `trading_locked` = '" + Length + "', `trading_locks_count` = `trading_locks_count` + '1' WHERE `user_id` = '" + Habbo.Id + "' LIMIT 1");
            }

            if (Habbo.GetClient() != null)
            {
                Habbo.TradingLockExpiry = Length;
                Habbo.GetClient().SendNotification("Je hebt een ruilban voor " + Days + " dag(en)!\r\rReden:\r\r" + Message);
            }
        }
 public RoomTraxManager(Room room)
 {
     this.Room                 = room;
     room.OnFurnisLoad        += new Room.FurnitureLoad(this.Room_OnFurnisLoad);
     this.IsPlaying            = false;
     this.StartedPlayTimestamp = checked ((int)QuasarEnvironment.GetUnixTimestamp());
     this.Playlist             = new List <Item>();
     this.SelectedDiscItem     = null;
     using (IQueryAdapter queryReactor = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
     {
         queryReactor.RunQuery("SELECT * FROM room_jukebox_songs WHERE room_id = '" + this.Room.Id + "'");
         this.dataTable = queryReactor.getTable();
     }
 }
Exemple #21
0
        public GroupForumThread(GroupForum parent, int id, int userid, int timestamp, string caption, bool pinned, bool locked, int deletedlevel, int deleterid)
        {
            //Game.GetClientManager().OnClientDisconnect += GroupForumThread_OnClientDisconnect;
            Views         = new List <GroupForumThreadPostView>();;
            UsersOnThread = new List <GameClient>();
            ParentForum   = parent;

            Id        = id;
            UserId    = userid;
            Timestamp = timestamp;
            Caption   = caption;
            Posts     = new List <GroupForumThreadPost>();

            Pinned           = pinned;
            Locked           = locked;
            DeletedLevel     = deletedlevel;
            DeleterUserId    = deleterid;
            DeletedTimestamp = (int)QuasarEnvironment.GetUnixTimestamp();

            DataTable table;

            using (var adap = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                adap.SetQuery("SELECT * FROM group_forums_thread_posts WHERE thread_id = @id");
                adap.AddParameter("id", this.Id);
                table = adap.getTable();
            }

            foreach (DataRow Row in table.Rows)
            {
                Posts.Add(new GroupForumThreadPost(this, Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["user_id"]), Convert.ToInt32(Row["timestamp"]), Row["message"].ToString(), Convert.ToInt32(Row["deleted_level"]), Convert.ToInt32(Row["deleter_user_id"])));
            }


            //DataTable table;
            using (var Adap = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                Adap.SetQuery("SELECT * FROM group_forums_thread_views WHERE thread_id = @id");
                Adap.AddParameter("id", Id);
                table = Adap.getTable();
            }


            foreach (DataRow Row in table.Rows)
            {
                Views.Add(new GroupForumThreadPostView(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["user_id"]), Convert.ToInt32(Row["count"])));
            }
        }
        public static Pet CreatePet(int UserId, string Name, int Type, string Race, string Color)
        {
            Pet pet = new Pet(0, UserId, 0, Name, Type, Race, Color, 0, 100, 100, 0, QuasarEnvironment.GetUnixTimestamp(), 0, 0, 0.0, 0, 0, 0, -1, "-1");

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("INSERT INTO bots (user_id,name, ai_type) VALUES (" + pet.OwnerId + ",@" + pet.PetId + "name, 'pet')");
                dbClient.AddParameter(pet.PetId + "name", pet.Name);
                pet.PetId = Convert.ToInt32(dbClient.InsertQuery());

                dbClient.SetQuery("INSERT INTO bots_petdata (id,type,race,color,experience,energy,createstamp) VALUES (" + pet.PetId + ", " + pet.Type + ",@" + pet.PetId + "race,@" + pet.PetId + "color,0,100,UNIX_TIMESTAMP())");
                dbClient.AddParameter(pet.PetId + "race", pet.Race);
                dbClient.AddParameter(pet.PetId + "color", pet.Color);
                dbClient.RunQuery();
            }
            return(pet);
        }
Exemple #23
0
        public bool Execute(params object[] Params)
        {
            if (Params.Length != 1)
            {
                return(false);
            }

            Habbo Player = (Habbo)Params[0];

            if (Player == null)
            {
                return(false);
            }

            RoomUser User = Instance.GetRoomUserManager().GetRoomUserByHabbo(Player.Id);

            if (User == null)
            {
                return(false);
            }

            if (Player.GetPermissions().HasRight("mod_tool") || this.Instance.OwnerId == Player.Id)
            {
                Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "Wired Mute Exception: Unmutable Player", 0, 0));
                return(false);
            }

            int    Time    = (StringData != null ? int.Parse(StringData.Split(';')[0]) : 0);
            string Message = (StringData != null ? (StringData.Split(';')[1]) : "No message!");

            if (Time > 0)
            {
                Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "Wired Mute: Muted for " + Time + "! Message: " + Message, 0, 0));
                if (!Instance.MutedUsers.ContainsKey(Player.Id))
                {
                    Instance.MutedUsers.Add(Player.Id, (QuasarEnvironment.GetUnixTimestamp() + (Time * 60)));
                }
                else
                {
                    Instance.MutedUsers.Remove(Player.Id);
                    Instance.MutedUsers.Add(Player.Id, (QuasarEnvironment.GetUnixTimestamp() + (Time * 60)));
                }
            }

            return(true);
        }
Exemple #24
0
        public void ReCacheBans()
        {
            if (this._bans.Count > 0)
            {
                this._bans.Clear();
            }

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                DataTable GetBans = null;
                dbClient.SetQuery("SELECT `bantype`,`value`,`reason`,`expire` FROM `bans` WHERE `bantype` = 'machine' OR `bantype` = 'user'");
                GetBans = dbClient.getTable();

                if (GetBans != null)
                {
                    foreach (DataRow dRow in GetBans.Rows)
                    {
                        string value   = Convert.ToString(dRow["value"]);
                        string reason  = Convert.ToString(dRow["reason"]);
                        double expires = (double)dRow["expire"];
                        string type    = Convert.ToString(dRow["bantype"]);

                        ModerationBan Ban = new ModerationBan(BanTypeUtility.GetModerationBanType(type), value, reason, expires);
                        if (Ban != null)
                        {
                            if (expires > QuasarEnvironment.GetUnixTimestamp())
                            {
                                if (!this._bans.ContainsKey(value))
                                {
                                    this._bans.Add(value, Ban);
                                }
                            }
                            else
                            {
                                dbClient.SetQuery("DELETE FROM `bans` WHERE `bantype` = '" + BanTypeUtility.FromModerationBanType(Ban.Type) + "' AND `value` = @Key LIMIT 1");
                                dbClient.AddParameter("Key", value);
                                dbClient.RunQuery();
                            }
                        }
                    }
                }
            }

            Console.WriteLine(CurrentTime + "» Cached " + this._bans.Count + " gebruiker en machine bans.");
        }
        public void LoadPromotions()
        {
            DataRow GetPromotion = null;

            using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `room_promotions` WHERE `room_id` = " + this.Id + " LIMIT 1;");
                GetPromotion = dbClient.getRow();

                if (GetPromotion != null)
                {
                    if (Convert.ToDouble(GetPromotion["timestamp_expire"]) > QuasarEnvironment.GetUnixTimestamp())
                    {
                        RoomData._promotion = new RoomPromotion(Convert.ToString(GetPromotion["title"]), Convert.ToString(GetPromotion["description"]), Convert.ToDouble(GetPromotion["timestamp_start"]), Convert.ToDouble(GetPromotion["timestamp_expire"]), Convert.ToInt32(GetPromotion["category_id"]));
                    }
                }
            }
        }
Exemple #26
0
        internal void Initialize(IQueryAdapter dbClient)
        {
            TargetedOffer = null;

            dbClient.SetQuery("SELECT * FROM targeted_offers WHERE active = 'true' LIMIT 1;");
            var row = dbClient.getRow();


            if (row == null)
            {
                return;
            }
            // Changed : row["open] > (string)row ["open"] & (string)row["active]" for warning? Still works?
            TargetedOffer = new TargetedOffers((int)row["id"], (int)row["limit"], (QuasarEnvironment.GetUnixTimestamp() +
                                                                                   (((int)row["time"] + 10) * 1)), row["open"] == "show", row["active"] == "true", (string)row["code"],
                                               (string)row["title"], (string)row["description"], (string)row["image"], (string)row["icon"],
                                               (string)row["money_type"], (string)row["items"], (string)row["price"]);
        }
Exemple #27
0
        public GroupForumThreadPost CreatePost(int userid, string message)
        {
            var now  = (int)QuasarEnvironment.GetUnixTimestamp();
            var Post = new GroupForumThreadPost(this, 0, userid, now, message, 0, 0);

            using (var adap = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                adap.SetQuery("INSERT INTO group_forums_thread_posts (thread_id, user_id, message, timestamp) VALUES (@a, @b, @c, @d)");
                adap.AddParameter("a", this.Id);
                adap.AddParameter("b", userid);
                adap.AddParameter("c", message);
                adap.AddParameter("d", now);
                Post.Id = (int)adap.InsertQuery();
            }

            Posts.Add(Post);
            return(Post);
        }
        public GroupForumThread CreateThread(int Creator, string Caption)
        {
            var timestamp = (int)QuasarEnvironment.GetUnixTimestamp();
            var Thread    = new GroupForumThread(this, 0, Creator, (int)timestamp, Caption, false, false, 0, 0);

            using (var adap = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                adap.SetQuery("INSERT INTO group_forums_threads (forum_id, user_id, caption, timestamp) VALUES (@a, @b, @c, @d)");
                adap.AddParameter("a", this.Id);
                adap.AddParameter("b", Creator);
                adap.AddParameter("c", Caption);
                adap.AddParameter("d", timestamp);
                Thread.Id = (int)adap.InsertQuery();
            }

            this.Threads.Add(Thread);
            return(Thread);
        }
        public void SerializeData(ServerPacket Packet)
        {
            var User        = GetAuthor();
            var oculterData = GetDeleter();

            Packet.WriteInteger(Id);                                                      //Post Id
            Packet.WriteInteger(ParentThread.Posts.IndexOf(this));                        //Post Index

            Packet.WriteInteger(User.Id);                                                 //User id
            Packet.WriteString(User.Username);                                            //Username
            Packet.WriteString(User.Look);                                                //User look

            Packet.WriteInteger((int)(QuasarEnvironment.GetUnixTimestamp() - Timestamp)); //User message timestamp
            Packet.WriteString(Message);                                                  // Message text
            Packet.WriteByte(DeletedLevel * 10);                                          // User message oculted by - level
            Packet.WriteInteger(oculterData != null ? oculterData.Id : 0);                // User that oculted message ID
            Packet.WriteString(oculterData != null ? oculterData.Username : "******");   //Oculted message user name
            Packet.WriteInteger(242342340);
            Packet.WriteInteger(ParentThread.GetUserPosts(User.Id).Count);                //User messages count
        }
Exemple #30
0
        public void OnTrigger(GameClient Session, Item Item, int Request, bool HasRights)
        {
            if (Item == null || Item.GetRoom() == null || Session == null || Session.GetHabbo() == null)
            {
                return;
            }

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

            if (User == null)
            {
                return;
            }

            User.LastInteraction = QuasarEnvironment.GetUnixTimestamp();

            // Alright. But is this user in the right position?
            if (User.Coordinate == Item.Coordinate || User.Coordinate == Item.SquareInFront)
            {
                // Fine. But is this tele even free?
                if (Item.InteractingUser != 0)
                {
                    return;
                }

                if (!User.CanWalk || Session.GetHabbo().IsTeleporting || Session.GetHabbo().TeleporterId != 0 ||
                    (User.LastInteraction + 2) - QuasarEnvironment.GetUnixTimestamp() < 0)
                {
                    return;
                }

                User.TeleDelay = 1;

                Item.InteractingUser = User.GetClient().GetHabbo().Id;
                QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_ExploreTeleporter", 1);
            }
            else if (User.CanWalk)
            {
                User.MoveTo(Item.SquareInFront);
            }
        }