Exemple #1
0
 public static string GetOwnId(string cookie)
 {
     return(HttpHelpers.Get($"https://www.roblox.com/game/GetCurrentUser.ashx", cookie));
 }
Exemple #2
0
 public static Place FindFirstPlace(string searchTerm)
 {
     return(JsonConvert.DeserializeObject <List <Place> >(HttpHelpers.Get($"https://www.roblox.com/games/list-json?MaxRows=1&Keyword={searchTerm.Trim()}"))[0]);
 }
Exemple #3
0
 public static PlaceInstances GetPlaceInstances(string placeId, int page, string cookie)
 {
     return(JsonConvert.DeserializeObject <PlaceInstances>(HttpHelpers.Get($"https://www.roblox.com/games/getgameinstancesjson?placeId={placeId.Trim()}&startindex={page * 10}", cookie)));
 }
Exemple #4
0
 public static string GetAvatarHeadshotUrl(string userid, int size = 48)
 {
     return(HttpHelpers.GetRedirectLocation($"https://www.roblox.com/headshot-thumbnail/image?userId={userid.Trim()}&width={size}&height={size}&format=png"));
 }
        static void Main(string[] args)
        {
            Parser.Default.ParseArguments <Options>(args).WithParsed <Options>(o =>
            {
                string cookie  = null;
                string placeid = null;
                string userid  = null;
                string avatar  = null;
                string ownid   = null;
                int totalPages = 0;

                Console.WriteLine();
                if (o.Cookie != null)
                {
                    cookie = ".ROBLOSECURITY=" + o.Cookie.Trim();
                }
                else
                {
                    Console.WriteLine("No .ROBLOSECURITY cookie specified. You may also use \"rbxcookie\" environment variable.");
                    Environment.Exit(1);
                }

                Console.Write("Getting your ID to check if cookie is valid... ");
                try
                {
                    ownid = Roblox.GetOwnId(cookie);
                }
                catch (Exception e) { CatchException(e); }
                Console.WriteLine(ownid);

                Console.Write("Getting target user ID... ");
                if (o.UserId != null)
                {
                    userid = o.UserId;
                }
                else
                {
                    if (o.UserName != null)
                    {
                        try
                        {
                            userid = JsonConvert.DeserializeObject <GetByUsername>(HttpHelpers.Get($"https://api.roblox.com/users/get-by-username?username={o.UserName.Trim()}")).Id.ToString();
                        }
                        catch (Exception e) { CatchException(e); }
                    }
                    else
                    {
                        Console.WriteLine("No user specified.");
                        Console.WriteLine();
                        Environment.Exit(1);
                    }
                }
                Console.WriteLine(userid);

                Console.Write("Getting target user avatar url... ");
                try
                {
                    avatar = Roblox.GetAvatarHeadshotUrl(userid);
                }
                catch (Exception e) { CatchException(e); }
                Console.WriteLine(avatar);

                Console.Write("Getting place ID... ");
                if (o.PlaceId != null)
                {
                    placeid = o.PlaceId;
                }
                else
                {
                    if (o.GameName != null)
                    {
                        try
                        {
                            placeid = Roblox.FindFirstPlace(o.GameName).PlaceID.ToString();
                        }
                        catch (Exception e) { CatchException(e); }
                    }
                    else
                    {
                        Console.WriteLine("No game specified.");
                        Console.WriteLine();
                        Environment.Exit(1);
                    }
                }
                Console.WriteLine(placeid);

                Console.Write("Getting total pages... ");
                try
                {
                    totalPages = (int)Math.Ceiling((decimal)Roblox.GetPlaceInstances(placeid, 0, cookie).TotalCollectionSize / 10);
                }
                catch (Exception e) { CatchException(e); }
                Console.WriteLine(totalPages);

                Console.WriteLine();
                for (int page = 0; page <= totalPages; page++)
                {
                    try
                    {
                        PlaceInstances placeInstances = Roblox.GetPlaceInstances(placeid, page, cookie);
                        foreach (var server in placeInstances.Collection)
                        {
                            foreach (var player in server.CurrentPlayers)
                            {
                                if (player.Thumbnail.Url == avatar)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine();
                                    Console.WriteLine(" Result: " + server.JoinScript);
                                    Console.WriteLine();
                                    Environment.Exit(0);
                                }
                            }
                        }
                        string text = $" {page + 1}/{totalPages}  [";
                        int textLen = CountCharacters(text);
                        Console.SetCursorPosition(0, Console.CursorTop);
                        Console.Write($"{text}{ProgressBar.Generate(page * 100 / 500, Console.WindowWidth - textLen - 2)}] ");
                    }
                    catch (Exception e) { CatchException(e); }
                }
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("Cant find player...");
                Console.WriteLine();
            });
        }