Beispiel #1
0
        /// <summary>
        /// Ends the jailbreak
        /// </summary>
        public override void Execute()
        {
            try
            {
                if (!JailbreakManager.JailbreakActivated)
                {
                    base.EndTimer();
                    return;
                }

                List <GameClient> CurrentJailbrokenUsers = PlusEnvironment.GetGame().GetClientManager().GetClients.Where(x => x != null && x.GetHabbo() != null && x.GetRoleplay() != null && x.GetRoleplay().Jailbroken).ToList();
                GameClient        UserJailbreaking       = JailbreakManager.UserJailbreaking;

                if (CurrentJailbrokenUsers.Count <= 0)
                {
                    JailbreakManager.JailbreakActivated = false;
                    if (JailbreakManager.FenceBroken)
                    {
                        Room Room = RoleplayManager.GenerateRoom(Convert.ToInt32(RoleplayData.GetData("jail", "outsideroomid")));

                        if (Room != null)
                        {
                            JailbreakManager.GenerateFence(Room);
                        }
                        JailbreakManager.FenceBroken = false;
                    }
                    MessagePoliceOfficers();
                    base.EndTimer();
                    return;
                }

                if (UserJailbreaking != null || UserJailbreaking.GetHabbo().CurrentRoom != null || UserJailbreaking.GetRoomUser() != null)
                {
                    if (UserJailbreaking.GetHabbo().CurrentRoomId != Convert.ToInt32(RoleplayData.GetData("jail", "outsideroomid")))
                    {
                        JailbreakManager.JailbreakActivated = false;
                        if (JailbreakManager.FenceBroken)
                        {
                            Room Room = RoleplayManager.GenerateRoom(Convert.ToInt32(RoleplayData.GetData("jail", "outsideroomid")));

                            if (Room != null)
                            {
                                JailbreakManager.GenerateFence(Room);
                            }
                            JailbreakManager.FenceBroken = false;
                        }

                        foreach (GameClient Client in CurrentJailbrokenUsers)
                        {
                            if (Client == null || Client.GetRoleplay() == null || Client.GetHabbo() == null)
                            {
                                continue;
                            }

                            if (Client.GetRoleplay().Jailbroken&& !JailbreakManager.FenceBroken)
                            {
                                Client.GetRoleplay().Jailbroken = false;
                            }

                            if (Client.GetHabbo().CurrentRoomId == Convert.ToInt32(RoleplayData.GetData("jail", "insideroomid")))
                            {
                                RoleplayManager.GetLookAndMotto(Client);
                                RoleplayManager.SpawnBeds(Client, "bed_silo_one");
                                Client.SendNotification("O processo para fuga da prisão parou, então você voltou para ela!");
                            }
                            else
                            {
                                Client.SendNotification("O processo para fuga da prisão parou, então você voltou para ela!");
                                RoleplayManager.SendUser(Client, Convert.ToInt32(RoleplayData.GetData("jail", "insideroomid")));
                            }
                        }

                        MessagePoliceOfficers();

                        RoleplayManager.Shout(UserJailbreaking, "*Para a fuga*", 4);
                        base.EndTimer();
                        return;
                    }
                }

                TimeCount++;
                TimeLeft -= 1000;

                if (TimeLeft > 0)
                {
                    if (TimeCount == 60)
                    {
                        if (UserJailbreaking != null || UserJailbreaking.GetHabbo().CurrentRoom != null || UserJailbreaking.GetRoomUser() != null)
                        {
                            RoleplayManager.Shout(UserJailbreaking, "*Estou mais perto de terminar a fuga dos prisioneiros [" + (TimeLeft / 60000) + " minutos restantes]*", 4);
                        }

                        TimeCount = 0;
                    }
                    return;
                }

                foreach (GameClient Client in CurrentJailbrokenUsers)
                {
                    if (Client == null || Client.GetRoleplay() == null || Client.GetHabbo() == null)
                    {
                        continue;
                    }

                    RoleplayManager.Shout(Client, "*Escapa completamente da prisão graças a um parceiro*", 4);
                    PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Client, "ACH_Jailbreak", 1);
                    Client.GetRoleplay().Jailbroken = false;
                    Client.GetRoleplay().IsWanted   = false;
                    Client.GetRoleplay().IsJailed   = false;
                    Client.GetHabbo().Poof();
                }

                if (JailbreakManager.FenceBroken)
                {
                    Room Room = RoleplayManager.GenerateRoom(Convert.ToInt32(RoleplayData.GetData("jail", "outsideroomid")));

                    if (Room != null)
                    {
                        JailbreakManager.GenerateFence(Room);
                    }
                    JailbreakManager.FenceBroken = false;
                }
                JailbreakManager.JailbreakActivated = false;
                JailbreakManager.UserJailbreaking   = null;
                base.EndTimer();
                return;
            }
            catch (Exception e)
            {
                Logging.LogRPTimersError("Error in Execute() void: " + e);
                base.EndTimer();
            }
        }
Beispiel #2
0
        public bool Execute(params object[] Params)
        {
            Habbo Player = (Habbo)Params[0];

            if (Player == null || Player.CurrentRoom == null || !Player.InRoom)
            {
                return(false);
            }

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

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

            if ((BoolData && Instance.OwnerId != Player.Id) || string.IsNullOrWhiteSpace(this.StringData))
            {
                return(false);
            }

            IChatCommand ChatCommand = null;

            if (!PlusEnvironment.GetGame().GetChatManager().GetCommands().TryGetCommand(this.StringData.Replace(":", "").ToLower(), out ChatCommand))
            {
                return(false);
            }

            if (Player.IChatCommand == ChatCommand)
            {
                Player.WiredInteraction = true;
                ICollection <IWiredItem> Effects    = Instance.GetWired().GetEffects(this);
                ICollection <IWiredItem> Conditions = Instance.GetWired().GetConditions(this);

                foreach (IWiredItem Condition in Conditions.ToList())
                {
                    if (!Condition.Execute(Player))
                    {
                        return(false);
                    }

                    Instance.GetWired().OnEvent(Condition.Item);
                }

                Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, this.StringData, 0, 0));
                //Check the ICollection to find the random addon effect.
                bool HasRandomEffectAddon = Effects.Where(x => x.Type == WiredBoxType.AddonRandomEffect).ToList().Count() > 0;
                if (HasRandomEffectAddon)
                {
                    //Okay, so we have a random addon effect, now lets get the IWiredItem and attempt to execute it.
                    IWiredItem RandomBox = Effects.FirstOrDefault(x => x.Type == WiredBoxType.AddonRandomEffect);
                    if (!RandomBox.Execute())
                    {
                        return(false);
                    }

                    //Success! Let's get our selected box and continue.
                    IWiredItem SelectedBox = Instance.GetWired().GetRandomEffect(Effects.ToList());
                    if (!SelectedBox.Execute())
                    {
                        return(false);
                    }

                    //Woo! Almost there captain, now lets broadcast the update to the room instance.
                    if (Instance != null)
                    {
                        Instance.GetWired().OnEvent(RandomBox.Item);
                        Instance.GetWired().OnEvent(SelectedBox.Item);
                    }
                }
                else
                {
                    foreach (IWiredItem Effect in Effects.ToList())
                    {
                        if (!Effect.Execute(Player))
                        {
                            return(false);
                        }

                        Instance.GetWired().OnEvent(Effect.Item);
                    }
                }
                return(true);
            }

            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// Saves the chat rooms data to database
        /// </summary>
        public void SaveChatRoomData()
        {
            try
            {
                #region Save owner, password, gang, locked
                using (IQueryAdapter DB = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    DB.SetQuery("UPDATE `rp_chat_rooms` SET `owner_id` = @ownerid, `password` = @password, `gang_id` = @gangid, `locked` = @locked WHERE `name` = @chatname");
                    DB.AddParameter("ownerid", this.ChatOwner);
                    DB.AddParameter("password", this.ChatValues["password"]);
                    DB.AddParameter("gangid", this.ChatValues["gang"]);
                    DB.AddParameter("locked", PlusEnvironment.BoolToEnum(Convert.ToBoolean(this.ChatValues["locked"])));
                    DB.AddParameter("chatname", this.ChatName);
                    DB.RunQuery();
                }
                #endregion

                #region Save admins

                string AdminString = "";

                foreach (int ChatAdmin in this.ChatAdmins)
                {
                    AdminString += ChatAdmin + ",";
                }

                if (AdminString.EndsWith(","))
                {
                    AdminString = AdminString.Remove(AdminString.Length - 1);
                }

                using (IQueryAdapter DB = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    DB.SetQuery("UPDATE `rp_chat_rooms` SET `admins` = @admins WHERE `name` = @chatname");
                    DB.AddParameter("admins", AdminString);
                    DB.AddParameter("chatname", this.ChatName);
                    DB.RunQuery();
                }

                #endregion

                #region Save banned users
                foreach (KeyValuePair <int, double> BannedUser in this.BannedUsers)
                {
                    using (IQueryAdapter DB = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        DataRow ExistingRow = null;
                        DB.SetQuery("SELECT NULL FROM `rp_chat_rooms_data` WHERE `chat_name` = @chatname AND `data_type` = 'ban' AND `data_value` = @value");
                        DB.AddParameter("chatname", this.ChatName);
                        DB.AddParameter("value", BannedUser.Key);

                        ExistingRow = DB.getRow();

                        if (ExistingRow != null)
                        {
                            DB.SetQuery("UPDATE `rp_chat_rooms_data` SET `data_timestamp_expire` = @expire WHERE `chat_name` = @chatname AND `data_type` = 'ban' AND `data_value` = @value");
                            DB.AddParameter("chatname", this.ChatName);
                            DB.AddParameter("expire", BannedUser.Value);
                            DB.AddParameter("value", BannedUser.Key);
                            DB.RunQuery();

                            continue;
                        }

                        DB.RunQuery("INSERT INTO `rp_chat_rooms_data` (`chat_name`,`data_type`,`data_value`,`data_timestamp_expire`) VALUES ('" + this.ChatName + "', 'ban', '" + BannedUser.Key + "', '" + BannedUser.Value + "')");
                    }
                }

                foreach (KeyValuePair <int, int> UnbannedUser in this.UnbannedUsers)
                {
                    int UsersID = UnbannedUser.Key;
                    using (IQueryAdapter DB = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        DB.SetQuery("DELETE FROM `rp_chat_rooms_data` WHERE `chat_name` = @chatname AND `data_type` = 'ban' AND `data_value` = @data");
                        DB.AddParameter("chatname", this.ChatName);
                        DB.AddParameter("data", UsersID);
                        DB.RunQuery();
                    }
                }
                #endregion

                #region Save muted users
                foreach (KeyValuePair <int, double> MutedUser in this.MutedUsers)
                {
                    using (IQueryAdapter DB = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        DataRow ExistingRow = null;
                        DB.SetQuery("SELECT NULL FROM `rp_chat_rooms_data` WHERE `chat_name` = @chatname AND `data_type` = 'mute' AND `data_value` = @value");
                        DB.AddParameter("chatname", this.ChatName);
                        DB.AddParameter("value", MutedUser.Key);

                        ExistingRow = DB.getRow();

                        if (ExistingRow != null)
                        {
                            DB.SetQuery("UPDATE `rp_chat_rooms_data` SET `data_timestamp_expire` = @expire WHERE `chat_name` = @chatname");
                            DB.AddParameter("chatname", this.ChatName);
                            DB.AddParameter("expire", MutedUser.Value);
                            DB.RunQuery();
                            continue;
                        }

                        DB.SetQuery("INSERT INTO `rp_chat_rooms_data` (`chat_name`, `data_type`, `data_value`, `data_timestamp_expire`) VALUES (@chatname, 'mute', @value, @expire)");
                        DB.AddParameter("chatname", this.ChatName);
                        DB.AddParameter("value", MutedUser.Key);
                        DB.AddParameter("expire", MutedUser.Value);
                        DB.RunQuery();
                    }
                }
                foreach (KeyValuePair <int, int> UnmutedUser in this.UnmutedUsers)
                {
                    int UsersID = UnmutedUser.Key;
                    using (IQueryAdapter DB = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        DB.SetQuery("DELETE FROM `rp_chat_rooms_data` WHERE `chat_name` = @chatname AND `data_type` = 'mute' AND `data_value` = @data");
                        DB.AddParameter("chatname", this.ChatName);
                        DB.AddParameter("data", UsersID);
                        DB.RunQuery();
                    }
                }
                #endregion

                this.SaveChatLogs();
            }
            catch (Exception e)
            {
            }
        }
Beispiel #4
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length != 3)
            {
                Session.SendWhisper("Você deve digitar o nome de usuário e classificação que você deseja dar a eles.", 1);
                return;
            }

            var TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);

            if (TargetClient == null)
            {
                Session.SendWhisper("Este usuário não foi encontrado! Talvez ele esteja offline.", 1);
                return;
            }

            if (TargetClient.GetHabbo() == null || TargetClient.GetRoomUser() == null)
            {
                Session.SendWhisper("Este usuário não foi encontrado! Talvez ele esteja offline.", 1);
                return;
            }

            int Rank;

            if (int.TryParse(Params[2], out Rank))
            {
                int OldRank = TargetClient.GetHabbo().Rank;

                if (Rank <= 0 || Rank > 9)
                {
                    Session.SendWhisper("Desculpe esta posição não existe!", 1);
                    return;
                }

                if (OldRank == Rank)
                {
                    Session.SendWhisper("Este usuário já tem [Cargo ID: " + Rank + "]", 1);
                    return;
                }

                TargetClient.GetHabbo().Rank = Rank;
                TargetClient.GetHabbo().InitPermissions();

                using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    dbClient.RunQuery("UPDATE `users` SET `rank` = '" + Rank + "' WHERE `id` = '" + TargetClient.GetHabbo().Id + "'");

                if (TargetClient.GetHabbo().GetPermissions().HasRight("mod_tickets"))
                {
                    TargetClient.SendMessage(new ModeratorInitComposer(
                                                 PlusEnvironment.GetGame().GetModerationManager().UserMessagePresets,
                                                 PlusEnvironment.GetGame().GetModerationManager().RoomMessagePresets,
                                                 PlusEnvironment.GetGame().GetModerationManager().UserActionPresets,
                                                 PlusEnvironment.GetGame().GetModerationTool().GetTickets));
                }

                if (OldRank > 1 && Rank == 1)
                {
                    TargetClient.SendNotification("Você foi rebaixado, você não tem mais acesso às Ferramentas de Modificação.\n\nPor favor recarregue para se livrar da caixa irritante.");
                }
                else if (OldRank > Rank)
                {
                    TargetClient.SendNotification("Desculpe...\n\nVocê foi rebaixado para [Rank ID: " + Rank + "] por " + Session.GetHabbo().Username + ".\n\nNão há necessidade de recarregar como suas permissões foram alteradas automaticamente.");
                }
                else
                {
                    TargetClient.SendNotification("Parabéns e bem-vindo à Equipe do HabboRPG!\n\nVocê foi promovido a [Cargo ID: " + Rank + "] por " + Session.GetHabbo().Username + "\n\nNão há necessidade de recarregar como todas as suas permissões foram ativadas!");
                }

                Session.Shout("*Altera imediatamente o cargo " + TargetClient.GetHabbo().Username + " para [Cargo ID: " + Rank + "]*", 23);
            }
            else
            {
                Session.SendWhisper("Por favor insira um número válido!", 1);
            }
        }
Beispiel #5
0
 private void manager_connectionEvent(ConnectionInformation connection)
 {
     connection.connectionChanged += connectionChanged;
     PlusEnvironment.GetGame().GetClientManager().CreateAndStartClient(Convert.ToInt32(connection.GetConnectionID()), connection);
 }
Beispiel #6
0
        public void Execute(GameClient session, Room room, string[] Params)
        {
            if (Params.Length == 1)
            {
                session.SendWhisper("Oops, you must choose a room option to disable.");
                return;
            }

            if (!room.CheckRights(session, true))
            {
                session.SendWhisper("Oops, only the room owner or staff can use this command.");
                return;
            }

            var option = Params[1];

            switch (option)
            {
            case "list":
            {
                var list = new StringBuilder("");
                list.AppendLine("Room Command List");
                list.AppendLine("-------------------------");
                list.AppendLine("Pet Morphs: " + (room.PetMorphsAllowed ? "enabled" : "disabled"));
                list.AppendLine("Pull: " + (room.PullEnabled ? "enabled" : "disabled"));
                list.AppendLine("Push: " + (room.PushEnabled ? "enabled" : "disabled"));
                list.AppendLine("Super Pull: " + (room.SPullEnabled ? "enabled" : "disabled"));
                list.AppendLine("Super Push: " + (room.SPushEnabled ? "enabled" : "disabled"));
                list.AppendLine("Respect: " + (room.RespectNotificationsEnabled ? "enabled" : "disabled"));
                list.AppendLine("Enables: " + (room.EnablesEnabled ? "enabled" : "disabled"));
                session.SendNotification(list.ToString());
                break;
            }

            case "push":
            {
                room.PushEnabled = !room.PushEnabled;
                using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `push_enabled` = @PushEnabled WHERE `id` = '" + room.Id +
                                      "' LIMIT 1");
                    dbClient.AddParameter("PushEnabled", PlusEnvironment.BoolToEnum(room.PushEnabled));
                    dbClient.RunQuery();
                }
                session.SendWhisper("Push mode is now " + (room.PushEnabled ? "enabled!" : "disabled!"));
                break;
            }

            case "spush":
            {
                room.SPushEnabled = !room.SPushEnabled;
                using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `spush_enabled` = @PushEnabled WHERE `id` = '" + room.Id +
                                      "' LIMIT 1");
                    dbClient.AddParameter("PushEnabled", PlusEnvironment.BoolToEnum(room.SPushEnabled));
                    dbClient.RunQuery();
                }
                session.SendWhisper("Super Push mode is now " + (room.SPushEnabled ? "enabled!" : "disabled!"));
                break;
            }

            case "spull":
            {
                room.SPullEnabled = !room.SPullEnabled;
                using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `spull_enabled` = @PullEnabled WHERE `id` = '" + room.Id +
                                      "' LIMIT 1");
                    dbClient.AddParameter("PullEnabled", PlusEnvironment.BoolToEnum(room.SPullEnabled));
                    dbClient.RunQuery();
                }
                session.SendWhisper("Super Pull mode is now " + (room.SPullEnabled ? "enabled!" : "disabled!"));
                break;
            }

            case "pull":
            {
                room.PullEnabled = !room.PullEnabled;
                using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `pull_enabled` = @PullEnabled WHERE `id` = '" + room.Id +
                                      "' LIMIT 1");
                    dbClient.AddParameter("PullEnabled", PlusEnvironment.BoolToEnum(room.PullEnabled));
                    dbClient.RunQuery();
                }
                session.SendWhisper("Pull mode is now " + (room.PullEnabled ? "enabled!" : "disabled!"));
                break;
            }

            case "enable":
            case "enables":
            {
                room.EnablesEnabled = !room.EnablesEnabled;
                using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `enables_enabled` = @EnablesEnabled WHERE `id` = '" + room.Id +
                                      "' LIMIT 1");
                    dbClient.AddParameter("EnablesEnabled", PlusEnvironment.BoolToEnum(room.EnablesEnabled));
                    dbClient.RunQuery();
                }
                session.SendWhisper("Enables mode set to " + (room.EnablesEnabled ? "enabled!" : "disabled!"));
                break;
            }

            case "respect":
            {
                room.RespectNotificationsEnabled = !room.RespectNotificationsEnabled;
                using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery(
                        "UPDATE `rooms` SET `respect_notifications_enabled` = @RespectNotificationsEnabled WHERE `id` = '" +
                        room.Id +
                        "' LIMIT 1");
                    dbClient.AddParameter("RespectNotificationsEnabled",
                                          PlusEnvironment.BoolToEnum(room.RespectNotificationsEnabled));
                    dbClient.RunQuery();
                }
                session.SendWhisper("Respect notifications mode set to " +
                                    (room.RespectNotificationsEnabled ? "enabled!" : "disabled!"));
                break;
            }

            case "pets":
            case "morphs":
            {
                room.PetMorphsAllowed = !room.PetMorphsAllowed;
                using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `pet_morphs_allowed` = @PetMorphsAllowed WHERE `id` = '" + room.Id +
                                      "' LIMIT 1");
                    dbClient.AddParameter("PetMorphsAllowed", PlusEnvironment.BoolToEnum(room.PetMorphsAllowed));
                    dbClient.RunQuery();
                }
                session.SendWhisper("Human pet morphs notifications mode set to " +
                                    (room.PetMorphsAllowed ? "enabled!" : "disabled!"));
                if (!room.PetMorphsAllowed)
                {
                    foreach (var user in room.GetRoomUserManager().GetRoomUsers())
                    {
                        if (user == null || user.GetClient() == null || user.GetClient().GetHabbo() == null)
                        {
                            continue;
                        }

                        user.GetClient()
                        .SendWhisper("The room owner has disabled the ability to use a pet morph in this room.");
                        if (user.GetClient().GetHabbo().PetId > 0)
                        {
                            //Tell the user what is going on.
                            user.GetClient()
                            .SendWhisper("Oops, the room owner has just disabled pet-morphs, un-morphing you.");

                            //Change the users Pet Id.
                            user.GetClient().GetHabbo().PetId = 0;

                            //Quickly remove the old user instance.
                            room.SendPacket(new UserRemoveComposer(user.VirtualId));

                            //Add the new one, they won't even notice a thing!!11 8-)
                            room.SendPacket(new UsersComposer(user));
                        }
                    }
                }

                break;
            }
            }
        }
Beispiel #7
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("You must inculde a thing to update, e.g. :update catalog");
                return;
            }

            string UpdateVariable = Params[1];

            switch (UpdateVariable.ToLower())
            {
            case "cata":
            case "catalog":
            case "catalogue":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_catalog"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_catalog' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetCatalog().Init(PlusEnvironment.GetGame().GetItemManager());
                PlusEnvironment.GetGame().GetClientManager().SendMessage(new CatalogUpdatedComposer());
                Session.SendWhisper("Catalogue successfully updated.");
                break;
            }

            case "items":
            case "furni":
            case "furniture":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_furni"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_furni' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetItemManager().Init();
                Session.SendWhisper("Items successfully updated.");
                break;
            }

            case "models":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_models"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_models' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetRoomManager().LoadModels();
                Session.SendWhisper("Room models successfully updated.");
                break;
            }

            case "promotions":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_promotions"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_promotions' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetLandingManager().LoadPromotions();
                Session.SendWhisper("Landing view promotions successfully updated.");
                break;
            }

            case "youtube":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_youtube"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_youtube' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetTelevisionManager().Init();
                Session.SendWhisper("Youtube televisions playlist successfully updated.");
                break;
            }

            case "filter":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_filter"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_filter' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetChatManager().GetFilter().Init();
                Session.SendWhisper("Filter definitions successfully updated.");
                break;
            }

            case "navigator":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_navigator"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_navigator' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetNavigator().Init();
                Session.SendWhisper("Navigator items successfully updated.");
                break;
            }

            case "ranks":
            case "rights":
            case "permissions":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_rights"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_rights' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetPermissionManager().Init();

                foreach (GameClient Client in PlusEnvironment.GetGame().GetClientManager().GetClients.ToList())
                {
                    if (Client == null || Client.GetHabbo() == null || Client.GetHabbo().GetPermissions() == null)
                    {
                        continue;
                    }

                    Client.GetHabbo().GetPermissions().Init(Client.GetHabbo());
                }

                Session.SendWhisper("Rank definitions successfully updated.");
                break;
            }

            case "config":
            case "settings":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_configuration"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_configuration' permission.");
                    break;
                }

                PlusEnvironment.ConfigData = new ConfigData();
                Session.SendWhisper("Server configuration successfully updated.");
                break;
            }

            case "bans":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_bans"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_bans' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetModerationManager().ReCacheBans();
                Session.SendWhisper("Ban cache re-loaded.");
                break;
            }

            case "quests":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_quests"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_quests' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetQuestManager().Init();
                Session.SendWhisper("Quest definitions successfully updated.");
                break;
            }

            case "achievements":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_achievements"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_achievements' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetAchievementManager().LoadAchievements();
                Session.SendWhisper("Achievement definitions bans successfully updated.");
                break;
            }

            case "moderation":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_moderation"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_moderation' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetModerationManager().Init();
                PlusEnvironment.GetGame().GetClientManager().ModAlert("Moderation presets have been updated. Please reload the client to view the new presets.");

                Session.SendWhisper("Moderation configuration successfully updated.");
                break;
            }

            case "tickets":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_tickets"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_tickets' permission.");
                    break;
                }

                if (PlusEnvironment.GetGame().GetModerationTool().Tickets.Count > 0)
                {
                    PlusEnvironment.GetGame().GetModerationTool().Tickets.Clear();
                }

                PlusEnvironment.GetGame().GetClientManager().ModAlert("Tickets have been purged. Please reload the client.");
                Session.SendWhisper("Tickets successfully purged.");
                break;
            }

            case "vouchers":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_vouchers"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_vouchers' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetCatalog().GetVoucherManager().Init();
                Session.SendWhisper("Catalogue vouche cache successfully updated.");
                break;
            }

            case "gc":
            case "games":
            case "gamecenter":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_game_center"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_game_center' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetGameDataManager().Init();
                Session.SendWhisper("Game Center cache successfully updated.");
                break;
            }

            case "pet_locale":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_pet_locale"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_pet_locale' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetChatManager().GetPetLocale().Init();
                Session.SendWhisper("Pet locale cache successfully updated.");
                break;
            }

            case "locale":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_locale"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_locale' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetLanguageLocale().Init();
                Session.SendWhisper("Locale cache successfully updated.");
                break;
            }

            case "mutant":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_anti_mutant"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_anti_mutant' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetAntiMutant().Init();
                Session.SendWhisper("Anti mutant successfully reloaded.");
                break;
            }

            case "bots":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_bots"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_bots' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetBotManager().Init();
                Session.SendWhisper("Bot managaer successfully reloaded.");
                break;
            }

            case "rewards":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_rewards"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_rewards' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetRewardManager().Reload();
                Session.SendWhisper("Rewards managaer successfully reloaded.");
                break;
            }

            case "chat_styles":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_chat_styles"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_chat_styles' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetChatManager().GetChatStyles().Init();
                Session.SendWhisper("Chat Styles successfully reloaded.");
                break;
            }

            case "badge_definitions":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_badge_definitions"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_badge_definitions' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetBadgeManager().Init();
                Session.SendWhisper("Badge definitions successfully reloaded.");
                break;
            }

            default:
                Session.SendWhisper("'" + UpdateVariable + "' is not a valid thing to reload.");
                break;
            }
        }
Beispiel #8
0
 public RoomPromotion(string name, string description, int categoryId)
 {
     this._name             = name;
     this._description      = description;
     this._timestampStarted = PlusEnvironment.GetUnixTimestamp();
     this._timestampExpires = (PlusEnvironment.GetUnixTimestamp()) + (Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.promotion.lifespan")) * 60);
     this._categoryId       = categoryId;
 }
Beispiel #9
0
        /// <summary>
        /// Blows up the dynamite
        /// </summary>
        public override void Execute()
        {
            try
            {
                GameClient Session  = (GameClient)Params[1];
                Poll       Poll     = (Poll)Params[2];
                bool       RoomOnly = (bool)Params[3];

                Room            Room  = Session.GetHabbo().CurrentRoom;
                List <RoomUser> Users = Room.GetRoomUserManager().GetRoomUsers();

                if (Poll == null || Room == null || Poll.Type != PollType.Matching)
                {
                    base.EndTimer();
                    return;
                }

                System.Threading.Thread.Sleep(3000);
                TimeLeft -= 1000;

                if (TimeLeft > 0)
                {
                    if (RoomOnly)
                    {
                        lock (Users)
                        {
                            foreach (RoomUser User in Room.GetRoomUserManager().GetRoomUsers())
                            {
                                Habbo RoomUser = PlusEnvironment.GetHabboById(User.UserId);

                                if (RoomUser == null)
                                {
                                    continue;
                                }

                                if (RoomUser.AnsweredMatchingPoll)
                                {
                                    RoomUser.GetClient().SendMessage(new MatchingPollResultMessageComposer(Poll));
                                }
                            }
                        }
                        return;
                    }
                    else
                    {
                        lock (PlusEnvironment.GetGame().GetClientManager().GetClients)
                        {
                            foreach (GameClient client in PlusEnvironment.GetGame().GetClientManager().GetClients)
                            {
                                if (client == null || client.GetHabbo() == null || client.GetRoomUser() == null)
                                {
                                    continue;
                                }

                                if (client.GetHabbo().AnsweredMatchingPoll)
                                {
                                    client.SendMessage(new MatchingPollResultMessageComposer(Poll));
                                }
                            }
                        }
                    }
                    return;
                }

                if (RoomOnly)
                {
                    lock (Users)
                    {
                        foreach (RoomUser User in Room.GetRoomUserManager().GetRoomUsers())
                        {
                            Habbo RoomUser = PlusEnvironment.GetHabboById(User.UserId);

                            if (RoomUser == null)
                            {
                                continue;
                            }

                            RoomUser.AnsweredMatchingPoll = false;
                        }
                    }
                    return;
                }
                else
                {
                    lock (PlusEnvironment.GetGame().GetClientManager().GetClients)
                    {
                        foreach (GameClient client in PlusEnvironment.GetGame().GetClientManager().GetClients)
                        {
                            if (client == null || client.GetHabbo() == null || client.GetRoomUser() == null)
                            {
                                continue;
                            }

                            client.GetHabbo().AnsweredMatchingPoll = false;
                        }
                    }
                }

                base.EndTimer();
                return;
            }
            catch (Exception e)
            {
                Logging.LogRPTimersError("Error in Execute() void: " + e);
                base.EndTimer();
            }
        }
Beispiel #10
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (session == null || session.GetHabbo() == null || session.GetHabbo().GetMessenger() == null)
            {
                return;
            }

            int user = packet.PopInt();
            int type = packet.PopInt();

            if (!session.GetHabbo().GetMessenger().FriendshipExists(user))
            {
                session.SendPacket(new BroadcastMessageAlertComposer("Oops, you can only set a relationship where a friendship exists."));
                return;
            }

            if (type < 0 || type > 3)
            {
                session.SendPacket(new BroadcastMessageAlertComposer("Oops, you've chosen an invalid relationship type."));
                return;
            }

            if (session.GetHabbo().Relationships.Count > 2000)
            {
                session.SendPacket(new BroadcastMessageAlertComposer("Sorry, you're limited to a total of 2000 relationships."));
                return;
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                if (type == 0)
                {
                    dbClient.SetQuery("SELECT `id` FROM `user_relationships` WHERE `user_id` = '" + session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", user);

                    dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", user);
                    dbClient.RunQuery();

                    if (session.GetHabbo().Relationships.ContainsKey(user))
                    {
                        session.GetHabbo().Relationships.Remove(user);
                    }
                }
                else
                {
                    dbClient.SetQuery("SELECT `id` FROM `user_relationships` WHERE `user_id` = '" + session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                    dbClient.AddParameter("target", user);
                    int id = dbClient.GetInteger();

                    if (id > 0)
                    {
                        dbClient.SetQuery("DELETE FROM `user_relationships` WHERE `user_id` = '" + session.GetHabbo().Id + "' AND `target` = @target LIMIT 1");
                        dbClient.AddParameter("target", user);
                        dbClient.RunQuery();

                        if (session.GetHabbo().Relationships.ContainsKey(id))
                        {
                            session.GetHabbo().Relationships.Remove(id);
                        }
                    }

                    dbClient.SetQuery("INSERT INTO `user_relationships` (`user_id`,`target`,`type`) VALUES ('" + session.GetHabbo().Id + "', @target, @type)");
                    dbClient.AddParameter("target", user);
                    dbClient.AddParameter("type", type);
                    int newId = Convert.ToInt32(dbClient.InsertQuery());

                    if (!session.GetHabbo().Relationships.ContainsKey(user))
                    {
                        session.GetHabbo().Relationships.Add(user, new Relationship(newId, user, type));
                    }
                }

                GameClient client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserId(user);
                if (client != null)
                {
                    session.GetHabbo().GetMessenger().UpdateFriend(user, client, true);
                }
                else
                {
                    Habbo habbo = PlusEnvironment.GetHabboById(user);
                    if (habbo != null)
                    {
                        if (session.GetHabbo().GetMessenger().TryGetFriend(user, out MessengerBuddy buddy))
                        {
                            session.SendPacket(new FriendListUpdateComposer(session, buddy));
                        }
                    }
                }
            }
        }
Beispiel #11
0
        public static void GenerateExtradata(Item Item, ServerPacket Message)
        {
            switch (Item.GetBaseItem().InteractionType)
            {
            default:
                Message.WriteInteger(1);
                Message.WriteInteger(0);
                Message.WriteString(Item.GetBaseItem().InteractionType != InteractionType.FOOTBALL_GATE ? Item.ExtraData : string.Empty);
                break;

            case InteractionType.GNOME_BOX:
                Message.WriteInteger(0);
                Message.WriteInteger(0);
                Message.WriteString("");
                break;

            case InteractionType.PET_BREEDING_BOX:
            case InteractionType.PURCHASABLE_CLOTHING:
                Message.WriteInteger(0);
                Message.WriteInteger(0);
                Message.WriteString("0");
                break;

            case InteractionType.STACKTOOL:
                Message.WriteInteger(0);
                Message.WriteInteger(0);
                Message.WriteString("");
                break;

            case InteractionType.WALLPAPER:
                Message.WriteInteger(2);
                Message.WriteInteger(0);
                Message.WriteString(Item.ExtraData);

                break;

            case InteractionType.FLOOR:
                Message.WriteInteger(3);
                Message.WriteInteger(0);
                Message.WriteString(Item.ExtraData);
                break;

            case InteractionType.LANDSCAPE:
                Message.WriteInteger(4);
                Message.WriteInteger(0);
                Message.WriteString(Item.ExtraData);
                break;

            case InteractionType.GUILD_ITEM:
            case InteractionType.GUILD_GATE:
            case InteractionType.GUILD_FORUM:
                Group Group = null;
                if (Item.GroupId < 1000)
                {
                    Group = GroupManager.GetJob(Item.GroupId);
                }
                else
                {
                    Group = GroupManager.GetGang(Item.GroupId);
                }
                if (Group == null)
                {
                    Message.WriteInteger(1);
                    Message.WriteInteger(0);
                    Message.WriteString(Item.ExtraData);
                }
                else
                {
                    Message.WriteInteger(0);
                    Message.WriteInteger(2);
                    Message.WriteInteger(5);
                    Message.WriteString(Item.ExtraData);
                    Message.WriteString(Group.Id.ToString());
                    Message.WriteString(Group.Badge);
                    Message.WriteString(PlusEnvironment.GetGame().GetGroupManager().GetGroupColour(Group.Colour1, true));     // Group Colour 1
                    Message.WriteString(PlusEnvironment.GetGame().GetGroupManager().GetGroupColour(Group.Colour2, false));    // Group Colour 2
                }
                break;

            case InteractionType.BACKGROUND:
            case InteractionType.INFORMATION_TERMINAL:
                Message.WriteInteger(0);
                Message.WriteInteger(1);
                if (!String.IsNullOrEmpty(Item.ExtraData))
                {
                    Message.WriteInteger(Item.ExtraData.Split(Convert.ToChar(9)).Length / 2);

                    for (int i = 0; i <= Item.ExtraData.Split(Convert.ToChar(9)).Length - 1; i++)
                    {
                        Message.WriteString(Item.ExtraData.Split(Convert.ToChar(9))[i]);
                    }
                }
                else
                {
                    Message.WriteInteger(0);
                }
                break;

            case InteractionType.GIFT:
            {
                string[] ExtraData = Item.ExtraData.Split(Convert.ToChar(5));
                if (ExtraData.Length != 7)
                {
                    Message.WriteInteger(0);
                    Message.WriteInteger(0);
                    Message.WriteString(Item.ExtraData);
                }
                else
                {
                    int Style = int.Parse(ExtraData[6]) * 1000 + int.Parse(ExtraData[6]);

                    using (UserCache Purchaser = PlusEnvironment.GetGame().GetCacheManager().GenerateUser(Convert.ToInt32(ExtraData[2])))
                    {
                        if (Purchaser == null)
                        {
                            Message.WriteInteger(0);
                            Message.WriteInteger(0);
                            Message.WriteString(Item.ExtraData);
                        }
                        else
                        {
                            Message.WriteInteger(Style);
                            Message.WriteInteger(1);
                            Message.WriteInteger(6);
                            Message.WriteString("EXTRA_PARAM");
                            Message.WriteString("");
                            Message.WriteString("MESSAGE");
                            Message.WriteString(ExtraData[1]);
                            Message.WriteString("PURCHASER_NAME");
                            Message.WriteString(Purchaser.Username);
                            Message.WriteString("PURCHASER_FIGURE");
                            Message.WriteString(Purchaser.Look);
                            Message.WriteString("PRODUCT_CODE");
                            Message.WriteString("A1 KUMIANKKA");
                            Message.WriteString("state");
                            Message.WriteString(Item.MagicRemove == true ? "1" : "0");
                        }
                    }
                }
            }
            break;


            case InteractionType.FARMING:
                Message.WriteInteger(0);
                int cracks     = 0;
                int cracks_max = 4;

                int.TryParse(Item.ExtraData, out cracks);

                string state = "0";

                if (cracks >= 4)
                {
                    state = "8";
                }
                else if (cracks >= 3)
                {
                    state = "6";
                }
                else if (cracks >= 2)
                {
                    state = "4";
                }
                else if (cracks >= 1)
                {
                    state = "2";
                }

                Message.WriteInteger(7);
                Message.WriteString(state);
                Message.WriteInteger(cracks);
                Message.WriteInteger(cracks_max);
                break;

            case InteractionType.CRACKABLE_EGG:
                Message.WriteInteger(0);
                Message.WriteInteger(7);
                Message.WriteString("8");
                Message.WriteInteger(9);
                Message.WriteInteger(12);
                break;

            case InteractionType.MANNEQUIN:
                Message.WriteInteger(0);
                Message.WriteInteger(1);
                Message.WriteInteger(3);
                if (Item.ExtraData.Contains(Convert.ToChar(5).ToString()))
                {
                    string[] Stuff = Item.ExtraData.Split(Convert.ToChar(5));
                    Message.WriteString("GENDER");
                    Message.WriteString(Stuff[0]);
                    Message.WriteString("FIGURE");
                    Message.WriteString(Stuff[1]);
                    Message.WriteString("OUTFIT_NAME");
                    Message.WriteString(Stuff[2]);
                }
                else
                {
                    Message.WriteString("GENDER");
                    Message.WriteString("");
                    Message.WriteString("FIGURE");
                    Message.WriteString("");
                    Message.WriteString("OUTFIT_NAME");
                    Message.WriteString("");
                }
                break;

            case InteractionType.TONER:
                if (Item.RoomId != 0)
                {
                    if (Item.GetRoom().TonerData == null)
                    {
                        Item.GetRoom().TonerData = new TonerData(Item.Id);
                    }

                    Message.WriteInteger(0);
                    Message.WriteInteger(5);
                    Message.WriteInteger(4);
                    Message.WriteInteger(Item.GetRoom().TonerData.Enabled);
                    Message.WriteInteger(Item.GetRoom().TonerData.Hue);
                    Message.WriteInteger(Item.GetRoom().TonerData.Saturation);
                    Message.WriteInteger(Item.GetRoom().TonerData.Lightness);
                }
                else
                {
                    Message.WriteInteger(0);
                    Message.WriteInteger(0);
                    Message.WriteString(string.Empty);
                }
                break;

            case InteractionType.BADGE_DISPLAY:
                Message.WriteInteger(0);
                Message.WriteInteger(2);
                Message.WriteInteger(4);

                string[] BadgeData = Item.ExtraData.Split(Convert.ToChar(9));
                if (Item.ExtraData.Contains(Convert.ToChar(9).ToString()))
                {
                    Message.WriteString("0");          //No idea
                    Message.WriteString(BadgeData[0]); //Badge name
                    Message.WriteString(BadgeData[1]); //Owner
                    Message.WriteString(BadgeData[2]); //Date
                }
                else
                {
                    Message.WriteString("0");          //No idea
                    Message.WriteString("DEV");        //Badge name
                    Message.WriteString("Sledmore");   //Owner
                    Message.WriteString("13-13-1337"); //Date
                }
                break;

            case InteractionType.TELEVISION:
                Message.WriteInteger(0);
                Message.WriteInteger(1);
                Message.WriteInteger(1);

                Message.WriteString("THUMBNAIL_URL");
                Message.WriteString("http://img.youtube.com/vi/" + PlusEnvironment.GetGame().GetTelevisionManager().TelevisionList.OrderBy(x => Guid.NewGuid()).FirstOrDefault().YouTubeId + "/3.jpg");
                Message.WriteString("");
                break;

            case InteractionType.LOVELOCK:
                if (Item.ExtraData.Contains(Convert.ToChar(5).ToString()))
                {
                    var EData = Item.ExtraData.Split((char)5);
                    int I     = 0;
                    Message.WriteInteger(0);
                    Message.WriteInteger(2);
                    Message.WriteInteger(EData.Length);
                    while (I < EData.Length)
                    {
                        Message.WriteString(EData[I]);
                        I++;
                    }
                }
                else
                {
                    Message.WriteInteger(0);
                    Message.WriteInteger(0);
                    Message.WriteString("0");
                }
                break;

            case InteractionType.MONSTERPLANT_SEED:
                Message.WriteInteger(0);
                Message.WriteInteger(1);
                Message.WriteInteger(1);

                Message.WriteString("rarity");
                Message.WriteString("1");    // Should really be a random generated rarity.
                break;
            }
        }
Beispiel #12
0
        public void Fill(DataRow Row)
        {
            Id          = Convert.ToInt32(Row["id"]);
            Name        = Convert.ToString(Row["caption"]);
            Description = Convert.ToString(Row["description"]);
            Type        = Convert.ToString(Row["roomtype"]);
            OwnerId     = Convert.ToInt32(Row["owner"]);

            OwnerName = "";
            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `username` FROM `users` WHERE `id` = @owner LIMIT 1");
                dbClient.AddParameter("owner", OwnerId);
                string result = dbClient.getString();
                if (!String.IsNullOrEmpty(result))
                {
                    OwnerName = result;
                }
            }

            this.Access = RoomAccessUtility.ToRoomAccess(Row["state"].ToString().ToLower());

            Category = Convert.ToInt32(Row["category"]);
            if (!string.IsNullOrEmpty(Row["users_now"].ToString()))
            {
                UsersNow = Convert.ToInt32(Row["users_now"]);
            }
            else
            {
                UsersNow = 0;
            }
            UsersMax            = Convert.ToInt32(Row["users_max"]);
            ModelName           = Convert.ToString(Row["model_name"]);
            Score               = Convert.ToInt32(Row["score"]);
            Tags                = new List <string>();
            AllowPets           = Convert.ToInt32(Row["allow_pets"].ToString());
            AllowPetsEating     = Convert.ToInt32(Row["allow_pets_eat"].ToString());
            RoomBlockingEnabled = Convert.ToInt32(Row["room_blocking_disabled"].ToString());
            Hidewall            = Convert.ToInt32(Row["allow_hidewall"].ToString());
            Password            = Convert.ToString(Row["password"]);
            Wallpaper           = Convert.ToString(Row["wallpaper"]);
            Floor               = Convert.ToString(Row["floor"]);
            Landscape           = Convert.ToString(Row["landscape"]);
            FloorThickness      = Convert.ToInt32(Row["floorthick"]);
            WallThickness       = Convert.ToInt32(Row["wallthick"]);
            WhoCanMute          = Convert.ToInt32(Row["mute_settings"]);
            WhoCanKick          = Convert.ToInt32(Row["kick_settings"]);
            WhoCanBan           = Convert.ToInt32(Row["ban_settings"]);
            chatMode            = Convert.ToInt32(Row["chat_mode"]);
            chatSpeed           = Convert.ToInt32(Row["chat_speed"]);
            chatSize            = Convert.ToInt32(Row["chat_size"]);
            TradeSettings       = Convert.ToInt32(Row["trade_settings"]);

            Group G = null;

            if (PlusEnvironment.GetGame().GetGroupManager().TryGetGroup(Convert.ToInt32(Row["group_id"]), out G))
            {
                Group = G;
            }
            else
            {
                Group = null;
            }

            foreach (string Tag in Row["tags"].ToString().Split(','))
            {
                Tags.Add(Tag);
            }

            mModel = PlusEnvironment.GetGame().GetRoomManager().GetModel(ModelName);

            this.PushEnabled    = PlusEnvironment.EnumToBool(Row["push_enabled"].ToString());
            this.PullEnabled    = PlusEnvironment.EnumToBool(Row["pull_enabled"].ToString());
            this.SPushEnabled   = PlusEnvironment.EnumToBool(Row["spush_enabled"].ToString());
            this.SPullEnabled   = PlusEnvironment.EnumToBool(Row["spull_enabled"].ToString());
            this.EnablesEnabled = PlusEnvironment.EnumToBool(Row["enables_enabled"].ToString());
            this.RespectNotificationsEnabled = PlusEnvironment.EnumToBool(Row["respect_notifications_enabled"].ToString());
            this.PetMorphsAllowed            = PlusEnvironment.EnumToBool(Row["pet_morphs_allowed"].ToString());
        }
Beispiel #13
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null)
            {
                return;
            }

            int    PageId     = Packet.PopInt();
            int    ItemId     = Packet.PopInt();
            int    RoomId     = Packet.PopInt();
            string Name       = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(Packet.PopString());
            bool   junk3      = Packet.PopBoolean();
            string Desc       = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(Packet.PopString());
            int    CategoryId = Packet.PopInt();

            RoomData Data = null;

            if (!RoomFactory.TryGetData(RoomId, out Data))
            {
                return;
            }

            if (Data.OwnerId != Session.GetHabbo().Id)
            {
                return;
            }

            if (Data.Promotion == null)
            {
                Data.Promotion = new RoomPromotion(Name, Desc, CategoryId);
            }
            else
            {
                Data.Promotion.Name              = Name;
                Data.Promotion.Description       = Desc;
                Data.Promotion.TimestampExpires += 7200;
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("REPLACE INTO `room_promotions` (`room_id`,`title`,`description`,`timestamp_start`,`timestamp_expire`,`category_id`) VALUES (@room_id, @title, @description, @start, @expires, @CategoryId)");
                dbClient.AddParameter("room_id", RoomId);
                dbClient.AddParameter("title", Name);
                dbClient.AddParameter("description", Desc);
                dbClient.AddParameter("start", Data.Promotion.TimestampStarted);
                dbClient.AddParameter("expires", Data.Promotion.TimestampExpires);
                dbClient.AddParameter("CategoryId", CategoryId);
                dbClient.RunQuery();
            }

            if (!Session.GetHabbo().GetBadgeComponent().HasBadge("RADZZ"))
            {
                Session.GetHabbo().GetBadgeComponent().GiveBadge("RADZZ", true, Session);
            }

            Session.SendPacket(new PurchaseOKComposer());
            if (Session.GetHabbo().InRoom&& Session.GetHabbo().CurrentRoomId == RoomId)
            {
                Session.GetHabbo().CurrentRoom.SendPacket(new RoomEventComposer(Data, Data.Promotion));
            }

            Session.GetHabbo().GetMessenger().BroadcastAchievement(Session.GetHabbo().Id, HabboHotel.Users.Messenger.MessengerEventTypes.EventStarted, Name);
        }
        public void Init()
        {
            if (_games.Count > 0)
            {
                _games.Clear();
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                DataTable GetData = null;
                dbClient.SetQuery("SELECT `id`,`name`,`colour_one`,`colour_two`,`resource_path`,`string_three`,`game_swf`,`game_assets`,`game_server_host`,`game_server_port`,`socket_policy_port`,`game_enabled` FROM `games_config`");
                GetData = dbClient.getTable();

                if (GetData != null)
                {
                    foreach (DataRow Row in GetData.Rows)
                    {
                        this._games.Add(Convert.ToInt32(Row["id"]), new GameData(Convert.ToInt32(Row["id"]), Convert.ToString(Row["name"]), Convert.ToString(Row["colour_one"]), Convert.ToString(Row["colour_two"]), Convert.ToString(Row["resource_path"]), Convert.ToString(Row["string_three"]), Convert.ToString(Row["game_swf"]), Convert.ToString(Row["game_assets"]), Convert.ToString(Row["game_server_host"]), Convert.ToString(Row["game_server_port"]), Convert.ToString(Row["socket_policy_port"]), PlusEnvironment.EnumToBool(Row["game_enabled"].ToString())));
                    }
                }
            }

            log.Info("Game Data Manager -> LOADED");
        }
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (session == null || session.Habbo == null)
            {
                return;
            }

            Room room = session.Habbo.CurrentRoom;

            if (room == null)
            {
                return;
            }

            if (session.Habbo.InRoom)
            {
                if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(session.Habbo.CurrentRoomId, out Room oldRoom))
                {
                    return;
                }

                if (oldRoom.GetRoomUserManager() != null)
                {
                    oldRoom.GetRoomUserManager().RemoveUserFromRoom(session, false);
                }
            }

            if (!room.GetRoomUserManager().AddAvatarToRoom(session))
            {
                room.GetRoomUserManager().RemoveUserFromRoom(session, false);
                return;//TODO: Remove?
            }

            room.SendObjects(session);

            if (session.Habbo.GetMessenger() != null)
            {
                session.Habbo.GetMessenger().OnStatusChanged(true);
            }

            if (session.Habbo.GetStats().QuestId > 0)
            {
                PlusEnvironment.GetGame().GetQuestManager().QuestReminder(session, session.Habbo.GetStats().QuestId);
            }

            session.SendPacket(new RoomEntryInfoComposer(room.RoomId, room.CheckRights(session, true)));
            session.SendPacket(new RoomVisualizationSettingsComposer(room.WallThickness, room.FloorThickness, PlusEnvironment.EnumToBool(room.Hidewall.ToString())));

            RoomUser user = room.GetRoomUserManager().GetRoomUserByHabbo(session.Habbo.Username);

            if (user != null && session.Habbo.PetId == 0)
            {
                room.SendPacket(new UserChangeComposer(user, false));
            }

            session.SendPacket(new RoomEventComposer(room, room.Promotion));

            if (room.GetWired() != null)
            {
                room.GetWired().TriggerEvent(WiredBoxType.TriggerRoomEnter, session.Habbo);
            }

            if (PlusEnvironment.GetUnixTimestamp() < session.Habbo.FloodTime && session.Habbo.FloodTime != 0)
            {
                session.SendPacket(new FloodControlComposer((int)session.Habbo.FloodTime - (int)PlusEnvironment.GetUnixTimestamp()));
            }
        }
Beispiel #16
0
        /// <summary>
        /// Executes this type of combat
        /// </summary>
        public void Execute(GameClient Client, GameClient TargetClient, bool HitClosest = false)
        {
            if (!CanCombat(Client, TargetClient))
            {
                return;
            }

            #region Variables

            RoomUser RoomUser        = Client.GetRoomUser();
            RoomUser TargetRoomUser  = TargetClient.GetRoomUser();
            int      Damage          = GetDamage(Client, TargetClient);
            Weapon   Weapon          = Client.GetRoleplay().EquippedWeapon;
            Point    ClientPos       = RoomUser.Coordinate;
            Point    TargetClientPos = TargetRoomUser.Coordinate;

            #endregion

            #region Ammo Check
            if (Client.GetRoleplay().GunShots >= Weapon.ClipSize)
            {
                Weapon.Reload(Client, TargetClient);
                Client.GetRoleplay().CooldownManager.CreateCooldown("reload", 1000, Weapon.ReloadTime);
                return;
            }
            #endregion

            #region Distance Check
            double Distance = RoleplayManager.GetDistanceBetweenPoints2D(ClientPos, TargetClientPos);
            if (Distance > Weapon.Range)
            {
                RoleplayManager.Shout(Client, "*Tenta acertar o tiro em " + TargetClient.GetHabbo().Username + ", mas erra o alvo*", 4);
                Client.GetRoleplay().GunShots++;

                if (Client.GetRoleplay().Game == null)
                {
                    Client.GetRoleplay().Bullets--;
                }
                return;
            }
            #endregion

            #region Target Death Procedure
            if (TargetClient.GetRoleplay().CurHealth - Damage <= 0)
            {
                Client.GetRoleplay().ClearWebSocketDialogue();

                string Text    = Weapon.FiringText.Split(':')[1];
                string GunName = Weapon.PublicName;

                RoleplayManager.Shout(Client, FormatFiringText(Text, GunName, TargetClient.GetHabbo().Username, Damage, Weapon.Energy), 6);


                lock (PlusEnvironment.GetGame().GetClientManager().GetClients)
                {
                    foreach (var client in PlusEnvironment.GetGame().GetClientManager().GetClients.ToList())
                    {
                        if (client == null || client.GetHabbo() == null)
                        {
                            continue;
                        }

                        client.SendMessage(new RoomNotificationComposer("staff_notice", "message", "[Notícia Urgente] " + Client.GetHabbo().Username + " matou com tiros o cidadão " + TargetClient.GetHabbo().Username + ", tome cuidado pelas ruas!"));
                    }
                }

                if (Client.GetRoleplay().LastKilled != TargetClient.GetHabbo().Id&& TargetClient.GetRoleplay().Game == null)
                {
                    PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Client, QuestType.KILL_USER);
                    PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Client, "ACH_Kills", 1);
                    PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(TargetClient, "ACH_Death", 1);

                    #region Player Stats
                    Client.GetRoleplay().LastKilled = TargetClient.GetHabbo().Id;
                    Client.GetRoleplay().Kills++;
                    Client.GetRoleplay().GunKills++;

                    if (GroupManager.HasJobCommand(TargetClient, "guide") && TargetClient.GetRoleplay().IsWorking)
                    {
                        TargetClient.GetRoleplay().CopDeaths++;
                    }
                    else
                    {
                        TargetClient.GetRoleplay().Deaths++;
                    }

                    if (!Client.GetRoleplay().WantedFor.Contains("cometer assassinato"))
                    {
                        Client.GetRoleplay().WantedFor = Client.GetRoleplay().WantedFor + "cometer assassinato, ";
                    }
                    #endregion

                    #region Exp Calculator
                    CryptoRandom Random     = new CryptoRandom();
                    int          Multiplier = 1;

                    int Chance = Random.Next(1, 101);

                    if (Chance <= 16)
                    {
                        if (Chance <= 8)
                        {
                            Multiplier = 3;
                        }
                        else
                        {
                            Multiplier = 2;
                        }
                    }

                    LevelManager.AddLevelEXP(Client, GetEXP(Client, TargetClient) * Multiplier);
                    #endregion

                    #region Gang Stats
                    Group Gang       = GroupManager.GetGang(Client.GetRoleplay().GangId);
                    Group TarGetGang = GroupManager.GetGang(TargetClient.GetRoleplay().GangId);

                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        if (Gang != null)
                        {
                            if (Gang.Id > 1000)
                            {
                                int ScoreIncrease = Random.Next(1, 11);

                                Gang.GangKills++;
                                Gang.GangScore += ScoreIncrease;

                                dbClient.RunQuery("UPDATE `rp_gangs` SET `gang_kills` = '" + Gang.GangKills + "', `gang_score` = '" + Gang.GangScore + "' WHERE `id` = '" + Gang.Id + "'");
                            }
                        }
                        if (TarGetGang != null)
                        {
                            if (TarGetGang.Id > 1000)
                            {
                                TarGetGang.GangDeaths++;

                                dbClient.RunQuery("UPDATE `rp_gangs` SET `gang_deaths` = '" + TarGetGang.GangDeaths + "' WHERE `id` = '" + TarGetGang.Id + "'");
                            }
                        }
                    }
                    #endregion

                    BountyManager.CheckBounty(Client, TargetClient.GetHabbo().Id);

                    if ((TargetClient.GetRoleplay().CurHealth - Damage) <= 0)
                    {
                        TargetClient.GetRoleplay().CurHealth = 0;
                    }
                }
            }
            #endregion

            #region Target Damage Procedure (Did not die)
            else
            {
                string Text    = Weapon.FiringText.Split(':')[0];
                string GunName = Weapon.PublicName;
                Client.GetRoleplay().OpenUsersDialogue(TargetClient);
                TargetClient.GetRoleplay().OpenUsersDialogue(Client);

                PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Client, QuestType.SHOOT_USER);
                RoleplayManager.Shout(Client, FormatFiringText(Text, GunName, TargetClient.GetHabbo().Username, Damage, Weapon.Energy), 6);
            }
            #endregion

            TargetClient.GetRoleplay().CurHealth -= Damage;

            if (Client.GetRoleplay().Game == null)
            {
                Client.GetRoleplay().Bullets--;
            }

            if (Client.GetRoleplay().Game == null)
            {
                Client.GetRoleplay().CurEnergy -= Weapon.Energy;
            }

            Client.GetRoleplay().GunShots++;

            if (!Client.GetRoleplay().WantedFor.Contains("tentativa de assaltSo + tentativa/assassinato"))
            {
                Client.GetRoleplay().WantedFor = Client.GetRoleplay().WantedFor + "tentativa de assalto + tentativa/assassinato ";
            }
        }
Beispiel #17
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            int    pageId      = packet.PopInt();
            int    itemId      = packet.PopInt();
            string data        = packet.PopString();
            string giftUser    = StringCharFilter.Escape(packet.PopString());
            string giftMessage = StringCharFilter.Escape(packet.PopString().Replace(Convert.ToChar(5), ' '));
            int    spriteId    = packet.PopInt();
            int    ribbon      = packet.PopInt();
            int    colour      = packet.PopInt();

            packet.PopBoolean();

            if (PlusEnvironment.GetSettingsManager().TryGetValue("room.item.gifts.enabled") != "1")
            {
                session.SendNotification("The hotel managers have disabled gifting");
                return;
            }

            if (!PlusEnvironment.GetGame().GetCatalog().TryGetPage(pageId, out CatalogPage page))
            {
                return;
            }

            if (!page.Enabled || !page.Visible || page.MinimumRank > session.GetHabbo().Rank || page.MinimumVIP > session.GetHabbo().VIPRank&& session.GetHabbo().Rank == 1)
            {
                return;
            }

            if (!page.Items.TryGetValue(itemId, out CatalogItem item))
            {
                if (page.ItemOffers.ContainsKey(itemId))
                {
                    item = page.ItemOffers[itemId];
                    if (item == null)
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            if (!ItemUtility.CanGiftItem(item))
            {
                return;
            }

            if (!PlusEnvironment.GetGame().GetItemManager().GetGift(spriteId, out ItemData presentData) || presentData.InteractionType != InteractionType.GIFT)
            {
                return;
            }

            if (session.GetHabbo().Credits < item.CostCredits)
            {
                session.SendPacket(new PresentDeliverErrorMessageComposer(true, false));
                return;
            }

            if (session.GetHabbo().Duckets < item.CostPixels)
            {
                session.SendPacket(new PresentDeliverErrorMessageComposer(false, true));
                return;
            }

            Habbo habbo = PlusEnvironment.GetHabboByUsername(giftUser);

            if (habbo == null)
            {
                session.SendPacket(new GiftWrappingErrorComposer());
                return;
            }

            if (!habbo.AllowGifts)
            {
                session.SendNotification("Oops, this user doesn't allow gifts to be sent to them!");
                return;
            }

            if ((DateTime.Now - session.GetHabbo().LastGiftPurchaseTime).TotalSeconds <= 15.0)
            {
                session.SendNotification("You're purchasing gifts too fast! Please wait 15 seconds!");

                session.GetHabbo().GiftPurchasingWarnings += 1;
                if (session.GetHabbo().GiftPurchasingWarnings >= 25)
                {
                    session.GetHabbo().SessionGiftBlocked = true;
                }
                return;
            }

            if (session.GetHabbo().SessionGiftBlocked)
            {
                return;
            }


            string ed = giftUser + Convert.ToChar(5) + giftMessage + Convert.ToChar(5) + session.GetHabbo().Id + Convert.ToChar(5) + item.Data.Id + Convert.ToChar(5) + spriteId + Convert.ToChar(5) + ribbon + Convert.ToChar(5) + colour;

            int newItemId;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                //Insert the dummy item.
                dbClient.SetQuery("INSERT INTO `items` (`base_item`,`user_id`,`extra_data`) VALUES (@baseId, @habboId, @extra_data)");
                dbClient.AddParameter("baseId", presentData.Id);
                dbClient.AddParameter("habboId", habbo.Id);
                dbClient.AddParameter("extra_data", ed);
                newItemId = Convert.ToInt32(dbClient.InsertQuery());

                string itemExtraData = null;
                switch (item.Data.InteractionType)
                {
                case InteractionType.NONE:
                    itemExtraData = "";
                    break;

                    #region Pet handling

                case InteractionType.PET:

                    try
                    {
                        string[] bits    = data.Split('\n');
                        string   petName = bits[0];
                        string   race    = bits[1];
                        string   color   = bits[2];

                        if (PetUtility.CheckPetName(petName))
                        {
                            return;
                        }

                        if (race.Length > 2)
                        {
                            return;
                        }

                        if (color.Length != 6)
                        {
                            return;
                        }

                        PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_PetLover", 1);
                    }
                    catch
                    {
                        return;
                    }

                    break;

                    #endregion

                case InteractionType.FLOOR:
                case InteractionType.WALLPAPER:
                case InteractionType.LANDSCAPE:

                    double number = 0;
                    try
                    {
                        number = string.IsNullOrEmpty(data) ? 0 : double.Parse(data, PlusEnvironment.CultureInfo);
                    }
                    catch
                    {
                        //ignored
                    }

                    itemExtraData = number.ToString(CultureInfo.CurrentCulture).Replace(',', '.');
                    break;     // maintain extra data // todo: validate

                case InteractionType.POSTIT:
                    itemExtraData = "FFFF33";
                    break;

                case InteractionType.MOODLIGHT:
                    itemExtraData = "1,1,1,#000000,255";
                    break;

                case InteractionType.TROPHY:
                    itemExtraData = session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + Convert.ToChar(9) + data;
                    break;

                case InteractionType.MANNEQUIN:
                    itemExtraData = "m" + Convert.ToChar(5) + ".ch-210-1321.lg-285-92" + Convert.ToChar(5) + "Default Mannequin";
                    break;

                case InteractionType.BADGE_DISPLAY:
                    if (!session.GetHabbo().GetBadgeComponent().HasBadge(data))
                    {
                        session.SendPacket(new BroadcastMessageAlertComposer("Oops, it appears that you do not own this badge."));
                        return;
                    }

                    itemExtraData = data + Convert.ToChar(9) + session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year;
                    break;

                default:
                    itemExtraData = data;
                    break;
                }

                //Insert the present, forever.
                dbClient.SetQuery("INSERT INTO `user_presents` (`item_id`,`base_id`,`extra_data`) VALUES (@itemId, @baseId, @extra_data)");
                dbClient.AddParameter("itemId", newItemId);
                dbClient.AddParameter("baseId", item.Data.Id);
                dbClient.AddParameter("extra_data", string.IsNullOrEmpty(itemExtraData) ? "" : itemExtraData);
                dbClient.RunQuery();

                //Here we're clearing up a record, this is dumb, but okay.
                dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @deleteId LIMIT 1");
                dbClient.AddParameter("deleteId", newItemId);
                dbClient.RunQuery();
            }


            Item giveItem = ItemFactory.CreateGiftItem(presentData, habbo, ed, ed, newItemId);
            if (giveItem != null)
            {
                GameClient receiver = PlusEnvironment.GetGame().GetClientManager().GetClientByUserId(habbo.Id);
                if (receiver != null)
                {
                    receiver.GetHabbo().GetInventoryComponent().TryAddItem(giveItem);
                    receiver.SendPacket(new FurniListNotificationComposer(giveItem.Id, 1));
                    receiver.SendPacket(new PurchaseOKComposer());
                    receiver.SendPacket(new FurniListAddComposer(giveItem));
                    receiver.SendPacket(new FurniListUpdateComposer());
                }

                if (habbo.Id != session.GetHabbo().Id&& !string.IsNullOrWhiteSpace(giftMessage))
                {
                    PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_GiftGiver", 1);
                    if (receiver != null)
                    {
                        PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(receiver, "ACH_GiftReceiver", 1);
                    }
                    PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(session, QuestType.GiftOthers);
                }
            }

            session.SendPacket(new PurchaseOKComposer(item, presentData));

            if (item.CostCredits > 0)
            {
                session.GetHabbo().Credits -= item.CostCredits;
                session.SendPacket(new CreditBalanceComposer(session.GetHabbo().Credits));
            }

            if (item.CostPixels > 0)
            {
                session.GetHabbo().Duckets -= item.CostPixels;
                session.SendPacket(new HabboActivityPointNotificationComposer(session.GetHabbo().Duckets, session.GetHabbo().Duckets));
            }

            session.GetHabbo().LastGiftPurchaseTime = DateTime.Now;
        }
Beispiel #18
0
        public bool TryExecute(string[] parameters)
        {
            if (!int.TryParse(parameters[0], out int userId))
            {
                return(false);
            }

            GameClient client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserId(userId);

            if (client == null || client.GetHabbo() == null)
            {
                return(false);
            }

            // Validate the currency type
            if (string.IsNullOrEmpty(Convert.ToString(parameters[1])))
            {
                return(false);
            }

            string currency = Convert.ToString(parameters[1]);

            switch (currency)
            {
            default:
                return(false);

            case "coins":
            case "credits":
            {
                int credits;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `credits` FROM `users` WHERE `id` = @id LIMIT 1");
                    dbClient.AddParameter("id", userId);
                    credits = dbClient.GetInteger();
                }

                client.GetHabbo().Credits = credits;
                client.SendPacket(new CreditBalanceComposer(client.GetHabbo().Credits));
                break;
            }

            case "pixels":
            case "duckets":
            {
                int duckets;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `activity_points` FROM `users` WHERE `id` = @id LIMIT 1");
                    dbClient.AddParameter("id", userId);
                    duckets = dbClient.GetInteger();
                }

                client.GetHabbo().Duckets = duckets;
                client.SendPacket(new HabboActivityPointNotificationComposer(client.GetHabbo().Duckets, duckets));
                break;
            }

            case "diamonds":
            {
                int diamonds;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `vip_points` FROM `users` WHERE `id` = @id LIMIT 1");
                    dbClient.AddParameter("id", userId);
                    diamonds = dbClient.GetInteger();
                }

                client.GetHabbo().Diamonds = diamonds;
                client.SendPacket(new HabboActivityPointNotificationComposer(diamonds, 0, 5));
                break;
            }

            case "gotw":
            {
                int gotw;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `gotw_points` FROM `users` WHERE `id` = @id LIMIT 1");
                    dbClient.AddParameter("id", userId);
                    gotw = dbClient.GetInteger();
                }

                client.GetHabbo().GOTWPoints = gotw;
                client.SendPacket(new HabboActivityPointNotificationComposer(gotw, 0, 103));
                break;
            }
            }
            return(true);
        }
Beispiel #19
0
        public void OnTrigger(GameClient Session, Item Item, int Request, bool HasRights)
        {
            if (Session == null)
            {
                return;
            }

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

            if (Item.InteractingUser2 != User.UserId)
            {
                Item.InteractingUser2 = User.UserId;
            }

            if (User == null)
            {
                return;
            }
            if (Item.GetBaseItem().InteractionType == InteractionType.ONE_WAY_GATE)
            {
                if (User.Coordinate != Item.SquareInFront && User.CanWalk)
                {
                    User.MoveTo(Item.SquareInFront);
                    return;
                }
                if (!Item.GetRoom().GetGameMap().ValidTile(Item.SquareBehind.X, Item.SquareBehind.Y) ||
                    !Item.GetRoom().GetGameMap().CanWalk(Item.SquareBehind.X, Item.SquareBehind.Y, false) ||
                    !Item.GetRoom().GetGameMap().SquareIsOpen(Item.SquareBehind.X, Item.SquareBehind.Y, false))
                {
                    return;
                }

                if ((User.LastInteraction - PlusEnvironment.GetUnixTimestamp() < 0) && User.InteractingGate &&
                    User.GateId == Item.Id)
                {
                    User.InteractingGate = false;
                    User.GateId          = 0;
                }


                if (!Item.GetRoom().GetGameMap().CanWalk(Item.SquareBehind.X, Item.SquareBehind.Y, User.AllowOverride))
                {
                    return;
                }

                if (Item.InteractingUser == 0)
                {
                    User.InteractingGate = true;
                    User.GateId          = Item.Id;
                    Item.InteractingUser = User.HabboId;

                    User.CanWalk = false;

                    if (User.IsWalking && (User.GoalX != Item.SquareInFront.X || User.GoalY != Item.SquareInFront.Y))
                    {
                        User.ClearMovement(true);
                    }

                    User.AllowOverride = true;
                    User.MoveTo(Item.Coordinate);

                    Item.RequestUpdate(4, true);
                }
            }
        }
        public void Parse(GameClient session, ClientPacket packet)
        {
            ICollection <Promotion> landingPromotions = PlusEnvironment.GetGame().GetLandingManager().GetPromotionItems();

            session.SendPacket(new PromoArticlesComposer(landingPromotions));
        }
Beispiel #21
0
        public void Run(object state)
        {
            try
            {
                if (_disabled)
                {
                    return;
                }

                if (_timerRunning)
                {
                    _timerLagging = true;
                    Log.Warn("<Player " + _player.Id + "> Server can't keep up, Player timer is lagging behind.");
                    return;
                }

                _resetEvent.Reset();

                if (_player.TimeMuted > 0)
                {
                    _player.TimeMuted -= 60;
                }
                if (_player.MessengerSpamTime > 0)
                {
                    _player.MessengerSpamTime -= 60;
                }
                if (_player.MessengerSpamTime <= 0)
                {
                    _player.MessengerSpamCount = 0;
                }
                _player.TimeAfk += 1;
                if (_player.GetStats().RespectsTimestamp != DateTime.Today.ToString("MM/dd"))
                {
                    _player.GetStats().RespectsTimestamp = DateTime.Today.ToString("MM/dd");
                    using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.RunQuery("UPDATE `user_stats` SET `dailyRespectPoints` = '" +
                                          (_player.Rank == 1 && _player.VipRank == 0 ? 10 : _player.VipRank == 1 ? 15 : 20) +
                                          "', `dailyPetRespectPoints` = '" +
                                          (_player.Rank == 1 && _player.VipRank == 0 ? 10 : _player.VipRank == 1 ? 15 : 20) +
                                          "', `respectsTimestamp` = '" +
                                          DateTime.Today.ToString("MM/dd") +
                                          "' WHERE `id` = '" +
                                          _player.Id +
                                          "' LIMIT 1");
                    }
                    _player.GetStats().DailyRespectPoints =
                        _player.Rank == 1 && _player.VipRank == 0 ? 10 : _player.VipRank == 1 ? 15 : 20;
                    _player.GetStats().DailyPetRespectPoints =
                        _player.Rank == 1 && _player.VipRank == 0 ? 10 : _player.VipRank == 1 ? 15 : 20;
                    if (_player.GetClient() != null)
                    {
                        _player.GetClient().SendPacket(new UserObjectComposer(_player));
                    }
                }
                if (_player.GiftPurchasingWarnings < 15)
                {
                    _player.GiftPurchasingWarnings = 0;
                }
                if (_player.MottoUpdateWarnings < 15)
                {
                    _player.MottoUpdateWarnings = 0;
                }
                if (_player.ClothingUpdateWarnings < 15)
                {
                    _player.ClothingUpdateWarnings = 0;
                }
                if (_player.GetClient() != null)
                {
                    PlusEnvironment.GetGame().GetAchievementManager()
                    .ProgressAchievement(_player.GetClient(), "ACH_AllTimeHotelPresence", 1);
                }
                _player.CheckCreditsTimer();
                _player.Effects().CheckEffectExpiry(_player);

                // END CODE

                // Reset the values
                _timerRunning = false;
                _timerLagging = false;
                _resetEvent.Set();
            }
            catch
            {
            }
        }
Beispiel #22
0
 public Item GetRandomExitTile()
 {
     return(ExitTeleports.Values.ToList()[PlusEnvironment.GetRandomNumber(0, ExitTeleports.Count - 1)]);
 }
Beispiel #23
0
        /// <summary>
        /// Called for each time the timer ticks.
        /// </summary>
        /// <param name="State"></param>
        public void Run(object State)
        {
            try
            {
                if (this._disabled)
                {
                    return;
                }

                if (this._timerRunning)
                {
                    this._timerLagging = true;
                    log.Warn("<Player " + this._player.Id + "> Server can't keep up, Player timer is lagging behind.");
                    return;
                }

                this._resetEvent.Reset();

                // BEGIN CODE

                #region Muted Checks
                if (this._player.TimeMuted > 0)
                {
                    this._player.TimeMuted -= 60;
                }
                #endregion

                #region Console Checks
                if (this._player.MessengerSpamTime > 0)
                {
                    this._player.MessengerSpamTime -= 60;
                }
                if (this._player.MessengerSpamTime <= 0)
                {
                    this._player.MessengerSpamCount = 0;
                }
                #endregion

                this._player.TimeAFK += 1;

                #region Respect checking
                if (this._player.GetStats().RespectsTimestamp != DateTime.Today.ToString("MM/dd"))
                {
                    this._player.GetStats().RespectsTimestamp = DateTime.Today.ToString("MM/dd");
                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.RunQuery("UPDATE `user_stats` SET `dailyRespectPoints` = '" + (this._player.Rank == 1 && this._player.VIPRank == 0 ? 10 : this._player.VIPRank == 1 ? 15 : 20) + "', `dailyPetRespectPoints` = '" + (this._player.Rank == 1 && this._player.VIPRank == 0 ? 10 : this._player.VIPRank == 1 ? 15 : 20) + "', `respectsTimestamp` = '" + DateTime.Today.ToString("MM/dd") + "' WHERE `id` = '" + this._player.Id + "' LIMIT 1");
                    }

                    this._player.GetStats().DailyRespectPoints    = (this._player.Rank == 1 && this._player.VIPRank == 0 ? 10 : this._player.VIPRank == 1 ? 15 : 20);
                    this._player.GetStats().DailyPetRespectPoints = (this._player.Rank == 1 && this._player.VIPRank == 0 ? 10 : this._player.VIPRank == 1 ? 15 : 20);

                    if (this._player.GetClient() != null)
                    {
                        this._player.GetClient().SendMessage(new UserObjectComposer(this._player));
                    }
                }
                #endregion

                #region Reset Scripting Warnings
                if (this._player.GiftPurchasingWarnings < 15)
                {
                    this._player.GiftPurchasingWarnings = 0;
                }

                if (this._player.MottoUpdateWarnings < 15)
                {
                    this._player.MottoUpdateWarnings = 0;
                }

                if (this._player.ClothingUpdateWarnings < 15)
                {
                    this._player.ClothingUpdateWarnings = 0;
                }
                #endregion


                if (this._player.GetClient() != null)
                {
                    PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(this._player.GetClient(), "ACH_AllTimeHotelPresence", 1);
                }

                this._player.CheckCreditsTimer();
                this._player.Effects().CheckEffectExpiry(this._player);

                // END CODE

                // Reset the values
                this._timerRunning = false;
                this._timerLagging = false;

                this._resetEvent.Set();
            }
            catch { }
        }
Beispiel #24
0
        public override void OnTimerTick()
        {
            if (GetBotData() == null)
            {
                return;
            }

            if (SpeechTimer <= 0)
            {
                if (GetBotData().RandomSpeech.Count > 0)
                {
                    if (GetBotData().AutomaticChat == false)
                    {
                        return;
                    }

                    RandomSpeech Speech = GetBotData().GetRandomSpeech();

                    string String = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(Speech.Message);
                    if (String.Contains("<img src") || String.Contains("<font ") || String.Contains("</font>") || String.Contains("</a>") || String.Contains("<i>"))
                    {
                        String = "I really shouldn't be using HTML within bot speeches.";
                    }
                    GetRoomUser().Chat(String, GetBotData().ChatBubble);
                }
                SpeechTimer = GetBotData().SpeakingInterval;
            }
            else
            {
                SpeechTimer--;
            }

            if (ActionTimer <= 0)
            {
                Point nextCoord;
                switch (GetBotData().WalkingMode.ToLower())
                {
                default:
                case "stand":
                    // (8) Why is my life so boring?
                    break;

                case "freeroam":
                    if (GetBotData().ForcedMovement)
                    {
                        if (GetRoomUser().Coordinate == GetBotData().TargetCoordinate)
                        {
                            GetBotData().ForcedMovement   = false;
                            GetBotData().TargetCoordinate = new Point();

                            GetRoomUser().MoveTo(GetBotData().TargetCoordinate.X, GetBotData().TargetCoordinate.Y);
                        }
                    }
                    else if (GetBotData().ForcedUserTargetMovement > 0)
                    {
                        RoomUser Target = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(GetBotData().ForcedUserTargetMovement);
                        if (Target == null)
                        {
                            GetBotData().ForcedUserTargetMovement = 0;
                            GetRoomUser().ClearMovement(true);
                        }
                        else
                        {
                            var Sq = new Point(Target.X, Target.Y);

                            if (Target.RotBody == 0)
                            {
                                Sq.Y--;
                            }
                            else if (Target.RotBody == 2)
                            {
                                Sq.X++;
                            }
                            else if (Target.RotBody == 4)
                            {
                                Sq.Y++;
                            }
                            else if (Target.RotBody == 6)
                            {
                                Sq.X--;
                            }


                            GetRoomUser().MoveTo(Sq);
                        }
                    }
                    else if (GetBotData().TargetUser == 0)
                    {
                        nextCoord = GetRoom().GetGameMap().GetRandomWalkableSquare();
                        GetRoomUser().MoveTo(nextCoord.X, nextCoord.Y);
                    }
                    break;

                case "specified_range":

                    break;
                }

                ActionTimer = new Random(DateTime.Now.Millisecond + VirtualId ^ 2).Next(5, 15);
            }
            else
            {
                ActionTimer--;
            }
        }
Beispiel #25
0
        public void ProgressUserQuest(GameClient session, QuestType type, int data = 0)
        {
            if (session == null || session.GetHabbo() == null || session.GetHabbo().GetStats().QuestID <= 0)
            {
                return;
            }

            Quest quest = GetQuest(session.GetHabbo().GetStats().QuestID);

            if (quest == null || quest.GoalType != type)
            {
                return;
            }

            int  currentProgress = session.GetHabbo().GetQuestProgress(quest.Id);
            int  totalProgress   = currentProgress;
            bool completeQuest   = false;

            switch (type)
            {
            default:

                totalProgress++;

                if (totalProgress >= quest.GoalData)
                {
                    completeQuest = true;
                }

                break;

            case QuestType.ExploreFindItem:

                if (data != quest.GoalData)
                {
                    return;
                }

                totalProgress = Convert.ToInt32(quest.GoalData);
                completeQuest = true;
                break;

            case QuestType.StandOn:

                if (data != quest.GoalData)
                {
                    return;
                }

                totalProgress = Convert.ToInt32(quest.GoalData);
                completeQuest = true;
                break;

            case QuestType.XmasParty:
                totalProgress++;
                if (totalProgress == quest.GoalData)
                {
                    completeQuest = true;
                }
                break;

            case QuestType.GiveItem:

                if (data != quest.GoalData)
                {
                    return;
                }

                totalProgress = Convert.ToInt32(quest.GoalData);
                completeQuest = true;
                break;
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("UPDATE `user_quests` SET `progress` = '" + totalProgress + "' WHERE `user_id` = '" + session.GetHabbo().Id + "' AND `quest_id` = '" + quest.Id + "' LIMIT 1");

                if (completeQuest)
                {
                    dbClient.RunQuery("UPDATE `user_stats` SET `quest_id` = '0' WHERE `id` = '" + session.GetHabbo().Id + "' LIMIT 1");
                }
            }

            session.GetHabbo().quests[session.GetHabbo().GetStats().QuestID] = totalProgress;
            session.SendPacket(new QuestStartedComposer(session, quest));

            if (completeQuest)
            {
                session.GetHabbo().GetMessenger().BroadcastAchievement(session.GetHabbo().Id, Users.Messenger.MessengerEventTypes.QuestCompleted, quest.Category + "." + quest.Name);

                session.GetHabbo().GetStats().QuestID = 0;
                session.GetHabbo().QuestLastCompleted = quest.Id;
                session.SendPacket(new QuestCompletedComposer(session, quest));
                session.GetHabbo().Duckets += quest.Reward;
                session.SendPacket(new HabboActivityPointNotificationComposer(session.GetHabbo().Duckets, quest.Reward));
                GetList(session, null);
            }
        }
Beispiel #26
0
        public void LoadFurniture()
        {
            if (_floorItems.Count > 0)
            {
                _floorItems.Clear();
            }
            if (_wallItems.Count > 0)
            {
                _wallItems.Clear();
            }

            List <Item> Items = ItemLoader.GetItemsForRoom(_room.Id, _room);

            foreach (Item Item in Items.ToList())
            {
                if (Item == null)
                {
                    continue;
                }

                if (Item.UserID == 0)
                {
                    using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("UPDATE `items` SET `user_id` = @UserId WHERE `id` = @ItemId LIMIT 1");
                        dbClient.AddParameter("ItemId", Item.Id);
                        dbClient.AddParameter("UserId", _room.OwnerId);
                        dbClient.RunQuery();
                    }
                }

                if (Item.IsFloorItem)
                {
                    if (!_room.GetGameMap().ValidTile(Item.GetX, Item.GetY))
                    {
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunQuery("UPDATE `items` SET `room_id` = '0' WHERE `id` = '" + Item.Id + "' LIMIT 1");
                        }

                        GameClient Client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserId(Item.UserID);
                        if (Client != null)
                        {
                            Client.Habbo.GetInventoryComponent().AddNewItem(Item.Id, Item.BaseItem, Item.ExtraData, Item.GroupId, true, true, Item.LimitedNo, Item.LimitedTot);
                            Client.Habbo.GetInventoryComponent().UpdateItems(false);
                        }
                        continue;
                    }

                    if (!_floorItems.ContainsKey(Item.Id))
                    {
                        _floorItems.TryAdd(Item.Id, Item);
                    }
                }
                else if (Item.IsWallItem)
                {
                    if (string.IsNullOrWhiteSpace(Item.wallCoord))
                    {
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("UPDATE `items` SET `wall_pos` = @WallPosition WHERE `id` = '" + Item.Id + "' LIMIT 1");
                            dbClient.AddParameter("WallPosition", ":w=0,2 l=11,53 l");
                            dbClient.RunQuery();
                        }

                        Item.wallCoord = ":w=0,2 l=11,53 l";
                    }

                    try
                    {
                        Item.wallCoord = WallPositionCheck(":" + Item.wallCoord.Split(':')[1]);
                    }
                    catch
                    {
                        using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("UPDATE `items` SET `wall_pos` = @WallPosition WHERE `id` = '" + Item.Id + "' LIMIT 1");
                            dbClient.AddParameter("WallPosition", ":w=0,2 l=11,53 l");
                            dbClient.RunQuery();
                        }

                        Item.wallCoord = ":w=0,2 l=11,53 l";
                    }

                    if (!_wallItems.ContainsKey(Item.Id))
                    {
                        _wallItems.TryAdd(Item.Id, Item);
                    }
                }
            }

            foreach (Item Item in _floorItems.Values.ToList())
            {
                if (Item.IsRoller)
                {
                    mGotRollers = true;
                }
                else if (Item.GetBaseItem().InteractionType == InteractionType.MOODLIGHT)
                {
                    if (_room.MoodlightData == null)
                    {
                        _room.MoodlightData = new MoodlightData(Item.Id);
                    }
                }
                else if (Item.GetBaseItem().InteractionType == InteractionType.TONER)
                {
                    if (_room.TonerData == null)
                    {
                        _room.TonerData = new TonerData(Item.Id);
                    }
                }
                else if (Item.IsWired)
                {
                    if (_room == null)
                    {
                        continue;
                    }

                    if (_room.GetWired() == null)
                    {
                        continue;
                    }

                    _room.GetWired().LoadWiredBox(Item);
                }
                else if (Item.GetBaseItem().InteractionType == InteractionType.HOPPER)
                {
                    HopperCount++;
                }
            }
        }
Beispiel #27
0
 /// <summary>
 /// Add chatlog to the chat dictionary
 /// </summary>
 /// <param name="User">User who sent message</param>
 /// <param name="Message">Message user sent</param>
 public void AddChatLog(GameClient User, string Message)
 {
     this.ChatLogs.TryAdd(this.ChatLogs.Count + 1, new Dictionary <string, string>()
     {
         { "chat_name", this.ChatName }, { "user_id", Convert.ToString(User.GetHabbo().Id) }, { "chat_message", Message }, { "timestamp", Convert.ToString(PlusEnvironment.GetUnixTimestamp()) }
     });
 }
Beispiel #28
0
        public bool SetFloorItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage, bool updateRoomUserStatuses = false, double height = -1)
        {
            bool NeedsReAdd = false;

            if (newItem)
            {
                if (Item.IsWired)
                {
                    if (Item.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps && _room.GetRoomItemHandler().GetFloor.Count(x => x.GetBaseItem().WiredType == WiredBoxType.EffectRegenerateMaps) > 0)
                    {
                        return(false);
                    }
                }
            }

            List <Item> ItemsOnTile = GetFurniObjects(newX, newY);

            if (Item.GetBaseItem().InteractionType == InteractionType.ROLLER && ItemsOnTile.Count(x => x.GetBaseItem().InteractionType == InteractionType.ROLLER && x.Id != Item.Id) > 0)
            {
                return(false);
            }

            if (!newItem)
            {
                NeedsReAdd = _room.GetGameMap().RemoveFromMap(Item);
            }

            Dictionary <int, ThreeDCoord> AffectedTiles = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot);

            if (!_room.GetGameMap().ValidTile(newX, newY) || _room.GetGameMap().SquareHasUsers(newX, newY) && !Item.GetBaseItem().IsSeat)
            {
                if (NeedsReAdd)
                {
                    _room.GetGameMap().AddToMap(Item);
                }
                return(false);
            }

            foreach (ThreeDCoord Tile in AffectedTiles.Values)
            {
                if (!_room.GetGameMap().ValidTile(Tile.X, Tile.Y) ||
                    (_room.GetGameMap().SquareHasUsers(Tile.X, Tile.Y) && !Item.GetBaseItem().IsSeat))
                {
                    if (NeedsReAdd)
                    {
                        _room.GetGameMap().AddToMap(Item);
                    }
                    return(false);
                }
            }

            // Start calculating new Z coordinate
            double newZ = _room.GetGameMap().Model.SqFloorHeight[newX, newY];

            if (height == -1)
            {
                if (!OnRoller)
                {
                    // Make sure this tile is open and there are no users here
                    if (_room.GetGameMap().Model.SqState[newX, newY] != SquareState.Open && !Item.GetBaseItem().IsSeat)
                    {
                        return(false);
                    }

                    foreach (ThreeDCoord Tile in AffectedTiles.Values)
                    {
                        if (_room.GetGameMap().Model.SqState[Tile.X, Tile.Y] != SquareState.Open &&
                            !Item.GetBaseItem().IsSeat)
                        {
                            if (NeedsReAdd)
                            {
                                //AddItem(Item);
                                _room.GetGameMap().AddToMap(Item);
                            }
                            return(false);
                        }
                    }

                    // And that we have no users
                    if (!Item.GetBaseItem().IsSeat&& !Item.IsRoller)
                    {
                        foreach (ThreeDCoord Tile in AffectedTiles.Values)
                        {
                            if (_room.GetGameMap().GetRoomUsers(new Point(Tile.X, Tile.Y)).Count > 0)
                            {
                                if (NeedsReAdd)
                                {
                                    _room.GetGameMap().AddToMap(Item);
                                }
                                return(false);
                            }
                        }
                    }
                }

                // Find affected objects
                var ItemsAffected = new List <Item>();
                var ItemsComplete = new List <Item>();

                foreach (ThreeDCoord Tile in AffectedTiles.Values.ToList())
                {
                    List <Item> Temp = GetFurniObjects(Tile.X, Tile.Y);

                    if (Temp != null)
                    {
                        ItemsAffected.AddRange(Temp);
                    }
                }


                ItemsComplete.AddRange(ItemsOnTile);
                ItemsComplete.AddRange(ItemsAffected);

                if (!OnRoller)
                {
                    // Check for items in the stack that do not allow stacking on top of them
                    foreach (Item I in ItemsComplete.ToList())
                    {
                        if (I == null)
                        {
                            continue;
                        }

                        if (I.Id == Item.Id)
                        {
                            continue;
                        }

                        if (I.GetBaseItem() == null)
                        {
                            continue;
                        }

                        if (!I.GetBaseItem().Stackable)
                        {
                            if (NeedsReAdd)
                            {
                                //AddItem(Item);
                                _room.GetGameMap().AddToMap(Item);
                            }
                            return(false);
                        }
                    }
                }

                //if (!Item.IsRoller)
                {
                    // If this is a rotating action, maintain item at current height
                    if (Item.Rotation != newRot && Item.GetX == newX && Item.GetY == newY)
                    {
                        newZ = Item.GetZ;
                    }

                    // Are there any higher objects in the stack!?
                    foreach (Item i in ItemsComplete.ToList())
                    {
                        if (i == null)
                        {
                            continue;
                        }
                        if (i.Id == Item.Id)
                        {
                            continue;
                        }

                        if (i.GetBaseItem().InteractionType == InteractionType.STACKTOOL)
                        {
                            newZ = i.GetZ;
                            break;
                        }
                        if (i.TotalHeight > newZ)
                        {
                            newZ = i.TotalHeight;
                        }
                    }
                }

                // Verify the rotation is correct
                if (newRot != 0 && newRot != 2 && newRot != 4 && newRot != 6 && newRot != 8 && !Item.GetBaseItem().ExtraRot)
                {
                    newRot = 0;
                }
            }
            else
            {
                newZ = height;
            }

            Item.Rotation = newRot;
            int oldX = Item.GetX;
            int oldY = Item.GetY;

            Item.SetState(newX, newY, newZ, AffectedTiles);

            if (!OnRoller && Session != null)
            {
                Item.Interactor.OnPlace(Session, Item);
            }


            if (newItem)
            {
                if (_floorItems.ContainsKey(Item.Id))
                {
                    if (Session != null)
                    {
                        Session.SendNotification(PlusEnvironment.GetLanguageManager().TryGetValue("room.item.already_placed"));
                    }
                    _room.GetGameMap().RemoveFromMap(Item);
                    return(true);
                }

                if (Item.IsFloorItem && !_floorItems.ContainsKey(Item.Id))
                {
                    _floorItems.TryAdd(Item.Id, Item);
                }
                else if (Item.IsWallItem && !_wallItems.ContainsKey(Item.Id))
                {
                    _wallItems.TryAdd(Item.Id, Item);
                }

                if (sendMessage)
                {
                    _room.SendPacket(new ObjectAddComposer(Item));
                }
            }
            else
            {
                UpdateItem(Item);
                if (!OnRoller && sendMessage)
                {
                    _room.SendPacket(new ObjectUpdateComposer(Item, _room.OwnerId));
                }
            }
            _room.GetGameMap().AddToMap(Item);

            if (Item.GetBaseItem().IsSeat)
            {
                updateRoomUserStatuses = true;
            }

            if (updateRoomUserStatuses)
            {
                _room.GetRoomUserManager().UpdateUserStatusses();
            }

            if (Item.GetBaseItem().InteractionType == InteractionType.TENT || Item.GetBaseItem().InteractionType == InteractionType.TENT_SMALL)
            {
                _room.RemoveTent(Item.Id);
                _room.AddTent(Item.Id);
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("UPDATE `items` SET `room_id` = '" + _room.RoomId + "', `x` = '" + Item.GetX + "', `y` = '" + Item.GetY + "', `z` = '" + Item.GetZ + "', `rot` = '" + Item.Rotation + "' WHERE `id` = '" + Item.Id + "' LIMIT 1");
            }
            return(true);
        }
Beispiel #29
0
        /// <summary>
        /// Broadcasts a new chat message entry
        /// </summary>
        /// <param name="User">Broadcasting user source</param>
        /// <param name="Params"></param>
        public void BroadCastNewChat(GameClient User, Dictionary <object, object> Params)
        {
            if (User == null)
            {
                return;
            }

            if (User.LoggingOut)
            {
                return;
            }

            if (User.GetRoleplay().WebSocketConnection == null)
            {
                User.SendWhisper("Sua conexão do websocket está atualmente offline. Entre em contato com um membro da equipe se esse problema persistir", 1);
                return;
            }

            PlusEnvironment.GetGame().GetWebEventManager().SendDataDirect(User, JsonConvert.SerializeObject(new Dictionary <object, object>()
            {
                { "event", "chatManager" },
                { "action", "onsendchat" },
                { "chatname", this.ChatName },
                { "chatmessage", Convert.ToString(Params["chatmessage"]) },
            }));

            this.BroadCastChatData(User, JsonConvert.SerializeObject(new Dictionary <object, object>()
            {
                { "event", "chatManager" },
                { "action", "onchat" },
                { "chatname", this.ChatName },
                { "chatusername", Convert.ToString(Params["chatusername"]) },
                { "chatmessage", Convert.ToString(Params["chatmessage"]) },
                { "chatfigure", User.GetHabbo().Look }
            }));

            #region Text stuff
            foreach (GameClient ChatUser in this.ChatUsers.Keys)
            {
                if (ChatUser == null)
                {
                    continue;
                }

                if (ChatUser == User)
                {
                    continue;
                }

                if (ChatUser.GetRoleplay() == null)
                {
                    continue;
                }

                if (ChatUser.GetRoomUser() == null)
                {
                    continue;
                }

                //ChatUser.SendWhisper("You have received a new text message from the '" + this.ChatName + "' WhatsHolo Group Chat on your " + RoleplayManager.GetPhoneName(ChatUser) + "!", 1);
                //ChatUser.SendMessage(new RoomNotificationComposer("text_message", "message", "Nova mensagem no grupo do WhatsApp '" + this.ChatName + "'!"));
            }
            #endregion
        }
Beispiel #30
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Digite uma mensagem para o policial ver!", 1);
                return;
            }

            if (Session.GetRoleplay().Sent911Call)
            {
                Session.SendWhisper("Seu último pedido de ajuda ainda não foi respondido!", 1);
                return;
            }

            if (Groups.GroupManager.HasJobCommand(Session, "guide") && Session.GetRoleplay().IsWorking)
            {
                Session.SendWhisper("Você não pode enviar uma chamada de ajuda enquanto estiver trabalhando!", 1);
                return;
            }

            if (Room.TurfEnabled)
            {
                Session.SendWhisper("Você não pode enviar uma chamada para ajuda se você estiver dentro de um território!", 1);
                return;
            }

            if (Session.GetRoleplay().Game != null || Session.GetRoleplay().Team != null)
            {
                Session.SendWhisper("Você não pode enviar uma chamada para ajuda se você estiver dentro de um evento!", 1);
                return;
            }

            if (Session.GetRoleplay().IsJailed)
            {
                Session.SendWhisper("Você não pode enviar uma chamada para ajuda se estiver preso!", 1);
                return;
            }

            string            Message       = CommandManager.MergeParams(Params, 1);
            GuideManager      guideManager  = PlusEnvironment.GetGame().GetGuideManager();
            List <GameClient> HandlingCalls = guideManager.HandlingCalls();

            if (Message.Length <= 9)
            {
                Session.SendWhisper("Digite uma mensagem mais descritiva para o policial ver! [10+ Dígitos]", 1);
                return;
            }

            if (HandlingCalls.Count < 1)
            {
                Session.SendMessage(new OnGuideSessionError());
                return;
            }

            CryptoRandom Random       = new CryptoRandom();
            GameClient   RandomPolice = null;

            if (HandlingCalls.Count > 1)
            {
                RandomPolice = HandlingCalls[Random.Next(0, HandlingCalls.Count)];
            }
            else
            {
                RandomPolice = HandlingCalls[0];
            }

            if (RandomPolice == null)
            {
                Session.SendMessage(new OnGuideSessionError());
                return;
            }

            Session.SendWhisper("Seu pedido de socorro foi enviado!", 1);
            RandomPolice.SendMessage(new OnGuideSessionAttachedComposer(Session.GetHabbo().Id, Message, 15));

            Session.GetRoleplay().SentRealCall        = false;
            Session.GetRoleplay().Sent911Call         = true;
            Session.GetRoleplay().CallMessage         = Message;
            Session.GetRoleplay().GuideOtherUser      = RandomPolice;
            RandomPolice.GetRoleplay().GuideOtherUser = Session;
        }