Beispiel #1
0
        public void BanzaiStart()
        {
            if (banzaiStarted)
            {
                return;
            }

            floorMap    = new byte[_room.GetGameMap().Model.MapSizeY, _room.GetGameMap().Model.MapSizeX];
            field       = new GameField(floorMap, true);
            timestarted = CloudServer.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.GroupForumListingsMessageComposer)
        {
            WriteInteger(ViewOrder);
            WriteInteger(StartIndex);
            WriteInteger(StartIndex);

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

            foreach (var Forum in Forums)
            {
                var lastpost = Forum.GetLastPost();
                var isn      = lastpost == null;
                WriteInteger(Forum.Id);                                                            //Maybe ID
                WriteString(Forum.Name);                                                           //Forum name
                WriteString(Forum.Description);                                                    //idk
                WriteString(Forum.Group.Badge);                                                    // Group Badge
                WriteInteger(0);                                                                   //Idk
                WriteInteger(0);                                                                   // Score
                WriteInteger(Forum.MessagesCount);                                                 //Message count
                WriteInteger(Forum.UnreadMessages(Session.GetHabbo().Id));                         //unread message count
                WriteInteger(0);                                                                   //Idk
                WriteInteger(!isn ? lastpost.GetAuthor().Id : 0);                                  // Las user to message id
                WriteString(!isn ? lastpost.GetAuthor().Username : "");                            //Last user to message name
                WriteInteger(!isn ? (int)CloudServer.GetUnixTimestamp() - lastpost.Timestamp : 0); //Last message timestamp
            }
        }
 public PetInformationComposer(Habbo Habbo)
     : base(ServerPacketHeader.PetInformationMessageComposer)
 {
     WriteInteger(Habbo.Id);
     WriteString(Habbo.Username);
     WriteInteger(Habbo.Rank);
     WriteInteger(10);
     WriteInteger(0);
     WriteInteger(0);
     WriteInteger(100);
     WriteInteger(100);
     WriteInteger(100);
     WriteInteger(100);
     WriteInteger(Habbo.GetStats().Respect);
     WriteInteger(Habbo.Id);
     WriteInteger(Convert.ToInt32(Math.Floor((CloudServer.GetUnixTimestamp() - Habbo.AccountCreated) / 86400))); //How?
     WriteString(Habbo.Username);
     WriteInteger(1);                                                                                            //3 on hab
     WriteBoolean(false);
     WriteBoolean(false);
     WriteInteger(0); //5 on hab
     WriteInteger(0); // Anyone can ride horse
     WriteInteger(0);
     WriteInteger(0); //512 on hab
     WriteInteger(0); //1536
     WriteInteger(0); //2560
     WriteInteger(0); //3584
     WriteInteger(0);
     WriteString("");
     WriteBoolean(false);
     WriteInteger(-1);//255 on hab
     WriteInteger(-1);
     WriteInteger(-1);
     WriteBoolean(false);
 }
        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);

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

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

            WriteInteger(Convert.ToInt32(CloudServer.GetUnixTimestamp() - Data.LastOnline)); // Last online
            WriteBoolean(true);                                                              // Show the profile
        }
Beispiel #5
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 = CloudServer.GetUnixTimestamp() + MuteTime;

                ChatSpamCount = 0;
                return(true);
            }
            return(false);
        }
Beispiel #6
0
 public RoomPromotion(string Name, string Desc, int CategoryId)
 {
     _name             = Name;
     _description      = Desc;
     _timestampStarted = CloudServer.GetUnixTimestamp();
     _timestampExpires = (CloudServer.GetUnixTimestamp()) + (Convert.ToInt32(CloudServer.GetGame().GetSettingsManager().TryGetValue("room.promotion.lifespan")) * 60);
     _categoryId       = CategoryId;
 }
Beispiel #7
0
 public HelperCase(GameClient client, string msg, int category)
 {
     Session         = client;
     Message         = msg;
     Type            = (HelpCaseType)category;
     Expire          = (int)CloudServer.GetUnixTimestamp() + HelperToolsManager.ANSWER_CALL_WAIT_TIME;
     DeclinedHelpers = new List <HabboHelper>();
 }
Beispiel #8
0
        public void TryProgressHabboClubAchievements(GameClient Session)
        {
            if (Session.GetHabbo() == null || !Session.GetHabbo().GetClubManager().HasSubscription("habbo_vip"))
            {
                return;
            }

            UserAchievement ClubACH = Session.GetHabbo().GetAchievementData("ACH_VipHC");

            if (ClubACH == null)
            {
                ProgressAchievement(Session, "ACH_VipHC", 1, true);
                ProgressAchievement(Session, "ACH_BasicClub", 1, true);
                return;
            }

            if (ClubACH.Level == 5)
            {
                return;
            }

            var    Subscription    = Session.GetHabbo().GetClubManager().GetSubscription("habbo_vip");
            Double SinceActivation = CloudServer.GetUnixTimestamp() - Subscription.ExpireTime;

            if (SinceActivation < 31556926)
            {
                return;
            }
            if (SinceActivation >= 31556926)
            {
                ProgressAchievement(Session, "ACH_VipHC", 1, false);
                ProgressAchievement(Session, "ACH_BasicClub", 1, false);
            }
            if (SinceActivation >= 63113851)
            {
                ProgressAchievement(Session, "ACH_VipHC", 1, false);
                ProgressAchievement(Session, "ACH_BasicClub", 1, false);
            }
            if (SinceActivation >= 94670777)
            {
                ProgressAchievement(Session, "ACH_VipHC", 1, false);
                ProgressAchievement(Session, "ACH_BasicClub", 1, false);
            }
            if (SinceActivation >= 126227704)
            {
                ProgressAchievement(Session, "ACH_VipHC", 1, false);
                ProgressAchievement(Session, "ACH_BasicClub", 1, false);
            }
            if (SinceActivation >= 157784630)
            {
                ProgressAchievement(Session, "ACH_VipHC", 1, false);
                ProgressAchievement(Session, "ACH_BasicClub", 1, false);
            }
        }
Beispiel #9
0
 public void PlayPlaylist()
 {
     if (Playlist.Count == 0)
     {
         return;
     }
     StartedPlayTimestamp = (int)CloudServer.GetUnixTimestamp();
     SelectedDiscItem     = null;
     IsPlaying            = true;
     //Room.SendMessage(new SetJukeboxNowPlayingComposer(Room));
     SetJukeboxesState();
 }
Beispiel #10
0
 public void AddChatlog(int Id, string Message)
 {
     using (IQueryAdapter dbClient = CloudServer.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", CloudServer.GetUnixTimestamp());
         dbClient.RunQuery();
     }
 }
Beispiel #11
0
        public void AddBan(int pId, long Time)
        {
            if (!Bans.ContainsKey(Convert.ToInt32(pId)))
            {
                Bans.Add(pId, CloudServer.GetUnixTimestamp() + Time);
            }

            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("REPLACE INTO `room_bans` VALUES (" + pId + ", " + Id + ", " + (CloudServer.GetUnixTimestamp() + Time) + ")");
            }
        }
Beispiel #12
0
 public void LogCommandStaff(int UserId, string Data, string MachineId, string Username)
 {
     using (IQueryAdapter dbClient = CloudServer.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", CloudServer.GetUnixTimestamp());
         dbClient.RunQuery();
     }
 }
Beispiel #13
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(CloudServer.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] < CloudServer.GetUnixTimestamp())
                {
                    Room.MutedUsers.Remove(UserId);
                }
                else
                {
                    return;
                }
            }

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

            Target.GetClient().SendWhisper("O proprietário da sala silenciou por " + Time + " minutos!");
            CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModMuteSeen", 1);
        }
        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 = (CloudServer.GetUnixTimestamp() + (Days * 86400));

            Habbo Habbo = CloudServer.GetHabboById(UserId);

            if (Habbo == null)
            {
                Session.SendWhisper("Ocorreu um erro em encontrar esse usuário no banco de dados.");
                return;
            }

            if (Habbo.GetPermissions().HasRight("mod_trade_lock") && !Session.GetHabbo().GetPermissions().HasRight("mod_trade_lock_any"))
            {
                Session.SendWhisper("Ops, você não pode bloquear outro usuário avaliado em 5 ou superior.");
                return;
            }

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

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

            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.runFastQuery("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("Suas trocas foram proibidas! " + Days + " día(s)!\r\rRazão:\r\r" + Message);
            }
        }
Beispiel #15
0
        public bool HasBanExpired(int pId)
        {
            if (!UserIsBanned(pId))
            {
                return(true);
            }

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

            return(false);
        }
Beispiel #16
0
 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 >= CloudServer.GetUnixTimestamp() && TimeLock > 0) ? true : false;
 }
Beispiel #17
0
        public GroupForumThread(GroupForum parent, int id, int userid, int timestamp, string caption, bool pinned, bool locked, int deletedlevel, int deleterid)
        {
            CloudServer.GetGame().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)CloudServer.GetUnixTimestamp();

            DataTable table;

            using (var adap = CloudServer.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 = CloudServer.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"])));
            }
        }
Beispiel #18
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, (CloudServer.GetUnixTimestamp() + (Time * 60)));
                }
                else
                {
                    Instance.MutedUsers.Remove(Player.Id);
                    Instance.MutedUsers.Add(Player.Id, (CloudServer.GetUnixTimestamp() + (Time * 60)));
                }
            }

            return(true);
        }
Beispiel #19
0
        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, CloudServer.GetUnixTimestamp(), 0, 0, 0.0, 0, 0, 0, -1, "-1");

            using (IQueryAdapter dbClient = CloudServer.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);
        }
Beispiel #20
0
        public GroupForumThread CreateThread(int Creator, string Caption)
        {
            var timestamp = (int)CloudServer.GetUnixTimestamp();
            var Thread    = new GroupForumThread(this, 0, Creator, (int)timestamp, Caption, false, false, 0, 0);

            using (var adap = CloudServer.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);
        }
Beispiel #21
0
        public void LoadPromotions()
        {
            DataRow GetPromotion = null;

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

                if (GetPromotion != null)
                {
                    if (Convert.ToDouble(GetPromotion["timestamp_expire"]) > CloudServer.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"]));
                    }
                }
            }
        }
Beispiel #22
0
        public GroupForumThreadPost CreatePost(int userid, string message)
        {
            var now  = (int)CloudServer.GetUnixTimestamp();
            var Post = new GroupForumThreadPost(this, 0, userid, now, message, 0, 0);

            using (var adap = CloudServer.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);
        }
Beispiel #23
0
        internal void AddOrExtendSubscription(string SubscriptionId, int DurationSeconds, GameClient Session)
        {
            SubscriptionId = SubscriptionId.ToLower();

            var clientByUserId = CloudServer.GetGame().GetClientManager().GetClientByUserID(UserId);

            if (Subscriptions.ContainsKey(SubscriptionId))
            {
                Subscription subscription = Subscriptions[SubscriptionId];

                if (subscription.IsValid())
                {
                    subscription.ExtendSubscription(DurationSeconds);
                }
                else
                {
                    subscription.SetEndTime((int)CloudServer.GetUnixTimestamp() + DurationSeconds);
                }

                using (IQueryAdapter adapter = CloudServer.GetDatabaseManager().GetQueryReactor())
                {
                    adapter.SetQuery(string.Concat(new object[] { "UPDATE user_subscriptions SET timestamp_expire = ", subscription.ExpireTime, " WHERE user_id = ", this.UserId, " AND subscription_id = '", subscription.SubscriptionId, "'" }));
                    adapter.RunQuery();
                }
                CloudServer.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(clientByUserId);
            }
            else
            {
                int          unixTimestamp    = (int)CloudServer.GetUnixTimestamp();
                int          timeExpire       = (int)CloudServer.GetUnixTimestamp() + DurationSeconds;
                string       SubscriptionType = SubscriptionId;
                Subscription subscription2    = new Subscription(SubscriptionId, timeExpire, unixTimestamp);

                using (IQueryAdapter adapter = CloudServer.GetDatabaseManager().GetQueryReactor())
                {
                    adapter.SetQuery(string.Concat(new object[] { "INSERT INTO user_subscriptions (user_id,subscription_id,timestamp_activated,timestamp_expire) VALUES (", this.UserId, ",'", SubscriptionType, "',", unixTimestamp, ",", timeExpire, ")" }));
                    adapter.RunQuery();
                }

                Subscriptions.Add(subscription2.SubscriptionId.ToLower(), subscription2);
                CloudServer.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(clientByUserId);
            }
        }
Beispiel #24
0
        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)(CloudServer.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
        }
Beispiel #25
0
        public void ReCacheBans()
        {
            if (this._bans.Count > 0)
                this._bans.Clear();

            using (IQueryAdapter dbClient = CloudServer.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 > CloudServer.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();
                            }
                        }
                    }
                }
            }

            log.Info("Cached " + this._bans.Count + " username and machine bans.");
        }
Beispiel #26
0
        public void TryProgressLoginAchievements(GameClient Session)
        {
            if (Session.GetHabbo() == null)
            {
                return;
            }
            UserAchievement loginACH = Session.GetHabbo().GetAchievementData("ACH_Login");

            if (loginACH == null)
            {
                ProgressAchievement(Session, "ACH_Login", 1, true);
                return;
            }

            Double daysBtwLastLogin = CloudServer.GetUnixTimestamp() - Session.GetHabbo().LastOnline;

            if (daysBtwLastLogin >= 51840 && daysBtwLastLogin <= 112320)
            {
                ProgressAchievement(Session, "ACH_Login", 1, true);
            }
        }
Beispiel #27
0
        public bool CheckMute(GameClient Session)
        {
            if (MutedUsers.ContainsKey(Session.GetHabbo().Id))
            {
                if (MutedUsers[Session.GetHabbo().Id] < CloudServer.GetUnixTimestamp())
                {
                    MutedUsers.Remove(Session.GetHabbo().Id);
                }
                else
                {
                    return(true);
                }
            }

            if (Session.GetHabbo().TimeMuted > 0 || (RoomMuted && Session.GetHabbo().Username != OwnerName))
            {
                return(true);
            }

            return(false);
        }
Beispiel #28
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 = CloudServer.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) - CloudServer.GetUnixTimestamp() < 0)
                {
                    return;
                }

                User.TeleDelay = 2;

                Item.InteractingUser = User.GetClient().GetHabbo().Id;
            }
            else if (User.CanWalk)
            {
                User.MoveTo(Item.SquareInFront);
            }
        }
Beispiel #29
0
        public bool TryCreateGroup(Habbo Player, string Name, string Description, int RoomId, string Badge, int Colour1, int Colour2, out Group Group)
        {
            Group = new Group(0, Name, Description, Badge, RoomId, Player.Id, (int)CloudServer.GetUnixTimestamp(), 0, Colour1, Colour2, 0, false, false);
            if (string.IsNullOrWhiteSpace(Name) || string.IsNullOrWhiteSpace(Badge))
            {
                return(false);
            }

            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("INSERT INTO `groups` (`name`, `desc`, `badge`, `owner_id`, `created`, `room_id`, `state`, `colour1`, `colour2`, `admindeco`) VALUES (@name, @desc, @badge, @owner, UNIX_TIMESTAMP(), @room, '0', @colour1, @colour2, '0')");
                dbClient.AddParameter("name", Group.Name);
                dbClient.AddParameter("desc", Group.Description);
                dbClient.AddParameter("owner", Group.CreatorId);
                dbClient.AddParameter("badge", Group.Badge);
                dbClient.AddParameter("room", Group.RoomId);
                dbClient.AddParameter("colour1", Group.Colour1);
                dbClient.AddParameter("colour2", Group.Colour2);
                Group.Id = Convert.ToInt32(dbClient.InsertQuery());

                Group.AddMember(Player.Id);
                Group.MakeAdmin(Player.Id);

                if (!this._groups.TryAdd(Group.Id, Group))
                {
                    return(false);
                }
                else
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `group_id` = @gid WHERE `id` = @rid LIMIT 1");
                    dbClient.AddParameter("gid", Group.Id);
                    dbClient.AddParameter("rid", Group.RoomId);
                    dbClient.RunQuery();

                    dbClient.runFastQuery("DELETE FROM `room_rights` WHERE `room_id` = '" + RoomId + "'");
                }
            }
            return(true);
        }
        public ScrSendUserInfoComposer(Habbo habbo)
            : base(ServerPacketHeader.ScrSendUserInfoMessageComposer)
        {
            WriteString("habbo_club");

            if (habbo.GetClubManager().HasSubscription("habbo_vip"))
            {
                Double Expire        = habbo.GetClubManager().GetSubscription("habbo_vip").ExpireTime;
                Double TimeLeft      = Expire - CloudServer.GetUnixTimestamp();
                int    TotalDaysLeft = (int)Math.Ceiling(TimeLeft / 86400);
                int    MonthsLeft    = TotalDaysLeft / 31;

                if (MonthsLeft >= 1)
                {
                    MonthsLeft--;
                }
                base.WriteInteger(TotalDaysLeft - (MonthsLeft * 31));
                base.WriteInteger(2); // ??
                base.WriteInteger(MonthsLeft);
                base.WriteInteger(1); // type
                base.WriteBoolean(true);
                base.WriteBoolean(true);
                base.WriteInteger(0);
                base.WriteInteger(Convert.ToInt32(TimeLeft)); // days i have on hc
                base.WriteInteger(Convert.ToInt32(TimeLeft)); // days i have on vip
            }
            else
            {
                base.WriteInteger(0);
                base.WriteInteger(0); // ??
                base.WriteInteger(0);
                base.WriteInteger(0); // type
                base.WriteBoolean(false);
                base.WriteBoolean(true);
                base.WriteInteger(0);
                base.WriteInteger(100); // days i have on hc
                base.WriteInteger(100); // days i have on vip
            }
        }