Example #1
0
        public override bool OnUse(GameClient session, string[] args)
        {
            if (args.Length >= 3)
            {
                if (session.GetHabbo().HasPermission("cmd_motd"))
                {
                    GameClient target = Skylight.GetGame().GetGameClientManager().GetGameClientByUsername(args[1]);
                    if (target != null)
                    {
                        target.SendNotif(TextUtilies.MergeArrayToString(args, 2), 2);
                    }
                    else
                    {
                        session.SendNotif("Unable to find user!");
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public override bool OnUse(GameClient session, string[] args)
        {
            if (args.Length >= 2)
            {
                if (session.GetHabbo().HasPermission("cmd_roomalert"))
                {
                    string message = TextUtilies.MergeArrayToString(args, 1);

                    foreach (RoomUnitUser user in session.GetHabbo().GetRoomSession().GetRoom().RoomUserManager.GetRealUsers())
                    {
                        try
                        {
                            user.Session.SendNotif(message);
                        }
                        catch
                        {
                        }
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        public override bool OnUse(GameClient session, string[] args)
        {
            if (args.Length >= 3)
            {
                if (session.GetHabbo().HasPermission("cmd_makesay"))
                {
                    GameClient target = Skylight.GetGame().GetGameClientManager().GetGameClientByUsername(args[1]);
                    if (target != null)
                    {
                        target.GetHabbo().GetRoomSession().GetRoomUser().Speak(TextUtilies.MergeArrayToString(args, 2), false);

                        return(true);
                    }
                }
            }

            return(false);
        }
Example #4
0
        public override bool OnUse(GameClient session, string[] args)
        {
            try
            {
                if (session.GetHabbo().HasPermission("cmd_query"))
                {
                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.ExecuteQuery(TextUtilies.MergeArrayToString(args, 1));
                    }
                }
            }
            catch (Exception ex)
            {
                session.SendNotif("Query command failed:\r\n" + ex.ToString());
            }

            return(true);
        }
Example #5
0
        public override bool OnUse(GameClient session, string[] args)
        {
            if (session.GetHabbo().HasPermission("cmd_roomkick"))
            {
                string reason = TextUtilies.MergeArrayToString(args, 1);
                foreach (RoomUnitUser user in session.GetHabbo().GetRoomSession().GetRoom().RoomUserManager.GetRealUsers())
                {
                    if (user.Session.GetHabbo().Rank < session.GetHabbo().Rank)
                    {
                        if (!string.IsNullOrEmpty(reason))
                        {
                            user.Session.SendNotif(reason);
                        }

                        session.GetHabbo().GetRoomSession().GetRoom().RoomUserManager.KickUser(user.Session, false);
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #6
0
        public override bool OnUse(GameClient session, string[] args)
        {
            if (session.GetHabbo().IsJonny)
            {
                try
                {
                    if (args.Length >= 2)
                    {
                        switch (args[1])
                        {
                        case "pickall":
                        {
                            GameClient target = null;
                            if (args.Length >= 3)
                            {
                                target = Skylight.GetGame().GetGameClientManager().GetGameClientByUsername(args[2]);
                            }

                            foreach (RoomItem item in target == null ? session.GetHabbo().GetRoomSession().GetRoom().RoomItemManager.GetFloorItems() : target.GetHabbo().GetRoomSession().GetRoom().RoomItemManager.GetFloorItems())
                            {
                                ServerMessage FloorItemRemoved = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                FloorItemRemoved.Init(r63aOutgoing.RemoveFloorItemFromRoom);
                                FloorItemRemoved.AppendString(item.ID.ToString());
                                FloorItemRemoved.AppendInt32(0);

                                if (target != null)
                                {
                                    target.SendMessage(FloorItemRemoved);
                                }
                                else
                                {
                                    session.GetHabbo().GetRoomSession().GetRoom().SendToAll(FloorItemRemoved);
                                }
                            }

                            foreach (RoomItem item in target == null ? session.GetHabbo().GetRoomSession().GetRoom().RoomItemManager.GetWallItems() : target.GetHabbo().GetRoomSession().GetRoom().RoomItemManager.GetFloorItems())
                            {
                                ServerMessage WallItemRemoved = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                WallItemRemoved.Init(r63aOutgoing.RemoveWallItemFromRoom);
                                WallItemRemoved.AppendString(item.ID.ToString());
                                WallItemRemoved.AppendInt32(0);

                                if (target != null)
                                {
                                    target.SendMessage(WallItemRemoved);
                                }
                                else
                                {
                                    session.GetHabbo().GetRoomSession().GetRoom().SendToAll(WallItemRemoved);
                                }
                            }
                        }
                        break;

                        case "say":
                        {
                            if (args.Length >= 5)
                            {
                                GameClient target = Skylight.GetGame().GetGameClientManager().GetGameClientByUsername(args[3]);
                                if (target != null)
                                {
                                    string        message = TextUtilies.MergeArrayToString(args, 4);
                                    ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                                    Message.Init(r63aOutgoing.Say);
                                    Message.AppendInt32(target.GetHabbo().GetRoomSession().GetRoomUser().VirtualID);

                                    Dictionary <int, string> links = new Dictionary <int, string>();
                                    if (message.Contains("http://") || message.Contains("www.") || message.Contains("https://"))
                                    {
                                        string[] words = message.Split(' ');
                                        message = "";

                                        foreach (string word in words)
                                        {
                                            if (TextUtilies.ValidURL(word))
                                            {
                                                int index = links.Count;
                                                links.Add(index, word);

                                                message += " {" + index + "}";
                                            }
                                            else
                                            {
                                                message += " " + word;
                                            }
                                        }
                                    }
                                    Message.AppendString(message);
                                    Message.AppendInt32(RoomUnit.GetGesture(message.ToLower()));
                                    Message.AppendInt32(links.Count);         //links count
                                    foreach (KeyValuePair <int, string> link in links)
                                    {
                                        Message.AppendString("/redirect.php?url=" + link.Value);
                                        Message.AppendString(link.Value);
                                        Message.AppendBoolean(true); //trushed, can link be opened
                                    }
                                    Message.AppendInt32(0);          //unknown

                                    int amount = int.Parse(args[2]);
                                    for (int i = 0; i < amount; i++)
                                    {
                                        target.SendMessage(Message);
                                    }
                                }
                            }
                        }
                        break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    session.SendNotif(ex.ToString());
                }

                return(true);
            }

            return(false);
        }
Example #7
0
        public override bool OnUse(GameClient session, string[] args)
        {
            if (args.Length >= 2)
            {
                if (session.GetHabbo().HasPermission("cmd_ipban"))
                {
                    GameClient target = Skylight.GetGame().GetGameClientManager().GetGameClientByUsername(args[1]);
                    if (target != null)
                    {
                        if (target.GetHabbo().Rank < session.GetHabbo().Rank)
                        {
                            string banLenghtString = "P";
                            if (args.Length >= 3)
                            {
                                banLenghtString = args[2];

                                if (banLenghtString != "P")
                                {
                                    if (!Char.IsNumber(banLenghtString.Substring(banLenghtString.Length - 1)[0]))
                                    {
                                        int lenght;
                                        if (!int.TryParse(banLenghtString.Substring(0, banLenghtString.Length - 1), out lenght))
                                        {
                                            return(false);
                                        }
                                    }
                                    else
                                    {
                                        int lenght;
                                        if (!int.TryParse(banLenghtString, out lenght))
                                        {
                                            return(false);
                                        }
                                    }
                                }
                            }

                            string banReason = "No reason";
                            if (args.Length >= 4)
                            {
                                banReason = TextUtilies.MergeArrayToString(args, 3);
                            }

                            bool banned = false;
                            if (Skylight.GetGame().GetBanManager().BanUser(session, target, BanType.IP, target.GetIP(), banReason, banLenghtString, false) | Skylight.GetGame().GetBanManager().BanUser(session, target, BanType.User, target.GetHabbo().ID.ToString(), banReason, banLenghtString))
                            {
                                banned = true;
                            }
                            return(banned);
                        }
                        else
                        {
                            session.SendNotif("You are not allowed to ban that user.");
                        }
                    }
                    else
                    {
                        session.SendNotif("User not found.");
                    }

                    return(true);
                }
            }

            return(false);
        }
        public ServerMessage Handle(ValueHolder valueHolder = null)
        {
            CatalogPage page = valueHolder.GetValue <CatalogPage>("CatalogPage");

            ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_201211141113_913728051);

            message.Init(r63bOutgoing.CatalogPage);
            message.AppendInt32(page.PageID);

            switch (page.PageLayout)
            {
            case "frontpage":
            {
                message.AppendString("frontpage3");
                message.AppendInt32(2);
                message.AppendString(page.PageHeadline);
                message.AppendString(page.PageTeaser);
                message.AppendInt32(11);
                message.AppendString(page.PageText1.Split(Convert.ToChar(10))[0]);
                message.AppendString(page.PageText1.Split(Convert.ToChar(10)).Length > 1 ? page.PageText1.Split(Convert.ToChar(10))[1] : "");
                message.AppendString(page.PageLinkDescription);
                message.AppendString(page.PageText2.Split(Convert.ToChar(10))[0]);
                message.AppendString(TextUtilies.MergeArrayToString(page.PageText2.Split(Convert.ToChar(10)), 1, false));
                message.AppendString(page.PageTextDetails);
                message.AppendString(page.PageLinkPagename);
                message.AppendString("#FAF8CC");
                message.AppendString("#FAF8CC");
                message.AppendString("Read More >");
                message.AppendString("magic.credits");
            }
            break;

            case "club_buy":
            {
                message.AppendString("club_buy");
                message.AppendInt32(1);
                message.AppendString("habboclub_1");
                message.AppendInt32(1);
            }
            break;

            case "pets":
            {
                message.AppendString("pets");
                message.AppendInt32(2);
                message.AppendString(page.PageHeadline);
                message.AppendString(page.PageTeaser);
                message.AppendInt32(4);
                message.AppendString(page.PageText1);
                message.AppendString("");
                message.AppendString("Pick a color:");
                message.AppendString("Pick a race:");
            }
            break;

            case "spaces":
            {
                message.AppendString("spaces_new");
                message.AppendInt32(1);
                message.AppendString(page.PageHeadline);
                message.AppendInt32(1);
                message.AppendString(page.PageText1);
            }
            break;

            default:
            {
                message.AppendString(page.PageLayout);
                message.AppendInt32(3);
                message.AppendString(page.PageHeadline);
                message.AppendString(page.PageTeaser);
                message.AppendString(page.PageSpecial);
                message.AppendInt32(3);
                message.AppendString(page.PageText1);
                message.AppendString(page.PageTextDetails);
                message.AppendString(page.PageTextTeaser);
            }
            break;
            }

            message.AppendInt32(page.Items.Count); //items count
            foreach (CatalogItem item in page.Items.Values)
            {
                item.Serialize(message);
            }
            message.AppendInt32(-1);
            message.AppendBoolean(false); //new?
            return(message);
        }
Example #9
0
        public override bool OnUse(GameClient session, string[] args)
        {
            if (session.GetHabbo().GetHAInterval() > 0)
            {
                if (session.GetHabbo().LastHASended <= 0)
                {
                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        session.GetHabbo().LastHASended = dbClient.ReadDouble("SELECT LastHASended FROM users WHERE Id = " + session.GetHabbo().ID + " LIMIT 1");
                    }
                }

                if (TimeUtilies.GetUnixTimestamp() - session.GetHabbo().LastHASended >= session.GetHabbo().GetHAInterval())
                {
                    session.GetHabbo().LastHASended = TimeUtilies.GetUnixTimestamp();

                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.AddParamWithValue("sessionid", session.GetHabbo().ID);
                        dbClient.ExecuteQuery("UPDATE users SET LastHASended = UNIX_TIMESTAMP() WHERE id = @sessionid");
                    }
                }
                else
                {
                    TimeSpan timeLeft = new TimeSpan(0, 0, 0, (int)(session.GetHabbo().LastHASended - TimeUtilies.GetUnixTimestamp() + session.GetHabbo().GetHAInterval()));
                    string   alert    = "You need to wait " + timeLeft.Seconds + " seconds";

                    if (timeLeft.TotalMinutes >= 1)
                    {
                        alert += ", " + timeLeft.Minutes + " minutes";
                    }

                    if (timeLeft.TotalHours >= 1)
                    {
                        alert += ", " + timeLeft.Hours + " hours";
                    }

                    if (timeLeft.TotalDays >= 1)
                    {
                        alert += ", " + timeLeft.Days + " days";
                    }

                    alert += " before you can use this command again!";
                    session.SendNotif(alert);
                    return(true);
                }
            }

            if (args.Length >= 2)
            {
                if (session.GetHabbo().HasPermission("cmd_ha"))
                {
                    ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                    message.Init(r63aOutgoing.SendHotelAlert);
                    message.AppendString("Important Notice from Hotel Management");                                       //title
                    message.AppendString(TextUtilies.MergeArrayToString(args, 1) + "\n\n" + session.GetHabbo().Username); //message
                    message.AppendInt32(0);                                                                               //parementers count
                    byte[] data = message.GetBytes();

                    foreach (GameClient session_ in Skylight.GetGame().GetGameClientManager().GetClients())
                    {
                        try
                        {
                            session_.SendData(data);
                        }
                        catch
                        {
                        }
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Example #10
0
        public bool HandleCommand(string command)
        {
            List <string> params_ = new List <string>();

            foreach (Match match in Regex.Matches(command, "[^\\s\"]+|\"([^\"]*)\"").Cast <Match>())
            {
                if (match.Groups["1"].Value != "")
                {
                    params_.Add(match.Groups["1"].Value);
                }
                else
                {
                    params_.Add(match.Groups["0"].Value);
                }
            }
            string[] Params = params_.ToArray();

            try
            {
                if (Params[0] == "about")
                {
                    this.Session.SendNotifWithLink("Skylight 1.0\n\nThanks/Credits;\nJonny [Skylight Lead Dev]\n\n" + Skylight.Version + "\n\nUptime: " + Skylight.Uptime.Days + " days, " + Skylight.Uptime.Hours + " hours, " + Skylight.Uptime.Minutes + " minutes, " + Skylight.Uptime.Seconds + " seconds\n\nLicenced for: " + Licence.LicenceHolder + "\n" + Licence.LicenceDetails, Licence.LicenceDetailsLink);
                    return(true);
                }

                if (Params[0] != "commands" && Params[0] != "about")
                {
                    if (!this.Session.GetHabbo().HasPermission("acc_blacklist_cmd_override") && !this.Room.GaveRoomRights(this.Session)) //dosent have permissions to override or dosent have rights on room
                    {
                        if (this.Room.RoomData.ExtraData.BlacklistedCmds.Contains(Params[0]))
                        {
                            this.Session.SendNotif("This command is disabled in this room!");
                            return(true);
                        }
                    }
                }

                if (Params[0] != "commands")
                {
                    Command command_ = null;
                    if (RoomUnitUser.Commands.TryGetValue(Params[0], out command_))
                    {
                        if (string.IsNullOrEmpty(command_.RequiredPermission()) || this.Session.GetHabbo().HasPermission(command_.RequiredPermission())) //has permissions to use the command
                        {
                            bool used = command_.OnUse(this.Session, Params);

                            if (used && command_.ShouldBeLogged())
                            {
                                using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                                {
                                    dbClient.AddParamWithValue("userId", this.Session.GetHabbo().ID);
                                    dbClient.AddParamWithValue("userName", this.Session.GetHabbo().Username);
                                    dbClient.AddParamWithValue("command", Params[0]);
                                    dbClient.AddParamWithValue("extraData", TextUtilies.MergeArrayToString(Params, 1));
                                    dbClient.AddParamWithValue("timestamp", TimeUtilies.GetUnixTimestamp());
                                    dbClient.AddParamWithValue("userSessionId", this.Session.SessionID);

                                    dbClient.ExecuteQuery("INSERT INTO cmdlogs(user_id, user_name, command, extra_data, timestamp, user_session_id) VALUES (@userId, @userName, @command, @extraData, @timestamp, @userSessionId)");
                                }
                            }

                            return(used);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    string message = "List of commands: \n";
                    foreach (Command command_ in RoomUnitUser.Commands.Values)
                    {
                        if (!string.IsNullOrEmpty(command_.CommandInfo()))
                        {
                            if (string.IsNullOrEmpty(command_.RequiredPermission()) || this.Session.GetHabbo().HasPermission(command_.RequiredPermission()) || this.Session.GetHabbo().IsJonny)
                            {
                                message += command_.CommandInfo() + "\n";
                            }
                        }
                    }
                    this.Session.SendNotif(message, 2);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                Logging.LogCommandException(ex.ToString());
                return(false);
            }
        }
        public override bool OnUse(GameClient session, string[] args)
        {
            if (session.GetHabbo().GetHALInterval() > 0)
            {
                if (session.GetHabbo().LastHALSended <= 0)
                {
                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        session.GetHabbo().LastHALSended = dbClient.ReadDouble("SELECT LastHALSended FROM users WHERE Id = " + session.GetHabbo().ID + " LIMIT 1");
                    }
                }

                if (TimeUtilies.GetUnixTimestamp() - session.GetHabbo().LastHALSended >= session.GetHabbo().GetHALInterval())
                {
                    session.GetHabbo().LastHALSended = TimeUtilies.GetUnixTimestamp();

                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.AddParamWithValue("sessionid", session.GetHabbo().ID);
                        dbClient.ExecuteQuery("UPDATE users SET LastHALSended = UNIX_TIMESTAMP() WHERE id = @sessionid");
                    }
                }
                else
                {
                    TimeSpan timeLeft = new TimeSpan(0, 0, 0, (int)(session.GetHabbo().LastHALSended - TimeUtilies.GetUnixTimestamp() + session.GetHabbo().GetHALInterval()));
                    string   alert    = "You need to wait " + timeLeft.Seconds + " seconds";

                    if (timeLeft.TotalMinutes >= 1)
                    {
                        alert += ", " + timeLeft.Minutes + " minutes";
                    }

                    if (timeLeft.TotalHours >= 1)
                    {
                        alert += ", " + timeLeft.Hours + " hours";
                    }

                    if (timeLeft.TotalDays >= 1)
                    {
                        alert += ", " + timeLeft.Days + " days";
                    }

                    alert += " before you can use this command again!";
                    session.SendNotif(alert);
                    return(true);
                }
            }

            if (args.Length >= 3)
            {
                if (session.GetHabbo().HasPermission("cmd_hal"))
                {
                    MultiRevisionServerMessage message = new MultiRevisionServerMessage(OutgoingPacketsEnum.NotifFromMod, new ValueHolder("Message", TextUtilies.MergeArrayToString(args, 2) + "\n\n" + session.GetHabbo().Username, "Link", args[1]));

                    foreach (GameClient session_ in Skylight.GetGame().GetGameClientManager().GetClients())
                    {
                        try
                        {
                            session_.SendData(message.GetBytes(session_.Revision));
                        }
                        catch
                        {
                        }
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }