Checking last time a player was online

It’s right in the title. I’ve tried taking a look at other posts and I’m just not grasping it! This is my first time attempting to setup proxies as well as make them suitable for this exact scenario.

My objective is to be able to communicate with Roblox API to recall the last time a player was online (as in on Roblox). Unfortunately, you can’t directly request that from Roblox, but rather work through a proxy.

I may need a complete rundown or walkthrough, as I am honestly completely lost. This is essential for what i’m trying to do.

All help and comments are appreciated!

1 Like

The Rolimon’s API can provide with useful information about different Roblox users, including the time they were last online. As far as I know, this is the only way to do this for now. The only flaw with this is that Rolimon’s only has users that have limited’s under their account or have been manually added to the website. If this won’t be an issue for you then you can try the following.

The link under Rolimon’s API is my Roblox users information, you should see “last_online” with a timestamp of when the user was last on the Roblox website in the epoch format. I’ve created a module that can provide you with with those numbers.

You can convert the numbers returned from the API with this function:

function ConvertTime(n)

	return os.date('%B %d %Y %H:%M:%S', n)

end

print(ConvertTime(1678759966)) -- Expected output: March 14 2023 02:12:46
3 Likes

I will take a look, and get back to you.

Still open to other peoples responses though on helpful information.

I like this, but I still need something more for grabbing absolutely a random player off of Roblox without necessarily being on Rolimon’s.

1 Like

Bumping this topic…

Any other help?

Here’s a scirpt that might help:

local function getUserOnlineStatus(userId)
	local data = {
		userIds = {
			userId,
		}
	}
	local success, result = pcall(function()
		return http:PostAsync(baseUrl,http:JSONEncode(data))
	end)
	if success then
		if result then
			local decodesuccess,decodedresult = pcall(jsonDecode,http,result)
			if decodesuccess then
				if decodedresult then
					return decodedresult
				else
					warn(decodedresult)
				end
			else
				warn(decodedresult)
			end
		else
			warn(result)
		end
	else
		warn(result)
	end
end

print(getUserOnlineStatus(1).lastOnlineTimestamps[1].lastOnline) -- returns an ISO date thingy

I’m aware of how to use the HTTP service and communicating with API. My problem is getting that online data from an API or from Roblox but I can’t directly request it from them. I need to work through a proxy unfortunately.

Just use roproxy, it worked perfectly for me…

local proxyUrl = "roproxy.com"
local baseUrl = "https://presence."..proxyUrl.."/v1/presence/last-online"

Also here’s the full script:

local http = game:GetService("HttpService")
local jsonDecode = http.JSONDecode

local proxyUrl = "roproxy.com"
local baseUrl = "https://presence."..proxyUrl.."/v1/presence/last-online"

local function getUserOnlineStatus(userId)
	local data = {
		userIds = {
			userId,
		}
	}
	print(http:JSONEncode(data))
	print(userId)
	local success, result = pcall(function()
		return http:PostAsync(baseUrl,http:JSONEncode(data))
	end)
	if success then
		print(result)
		if result then
			print(result)
			local decodesuccess,decodedresult = pcall(jsonDecode,http,result)
			if decodesuccess then
				if decodedresult then
					return decodedresult
				else
					warn(decodedresult)
				end
			else
				warn(decodedresult)
			end
		else
			warn(result)
		end
	else
		warn(result)
	end
end
1 Like

I’m pretty sure I’ve tried this very method (this api), and it did not work.

Can you test it right now, and let me know if it works still?

I tested it out, its a feature in my game…

Alright then. I’ll take your word for it and try this right now. I’ll let you know if it works lol

Worked for me:

print(getUserOnlineStatus(game.Players:GetUserIdFromNameAsync("Thunder_Alex12")).lastOnlineTimestamps[1].lastOnline)

Okay, I’m just an idiot. I did this method before, but I didn’t pass the player userId as a parameter, I added into the url lol

Do you know of a way I can convert this to epoch time?

I think this works:

print(os.time({
   year = date.Year, month = date.Month, day = date.Day, hour = date.Hour, min = date.Minute, sec = date.Second
})

First, convert the ISO date to Universal Time

local date = DateTime.fromIsoDate(isodate):ToUniversalTime()

iso date being the string or os.time()?

ISO Date being the last online date string.

So this returns epoch time after I convert it? cause ik os.time() returns epoch

The DateTime returns a formatted date… and then you convert it using the os.time() function

print(os.time({
   year = date.Year, month = date.Month, day = date.Day, hour = date.Hour, min = date.Minute, sec = date.Second
})
1 Like

Got it, thank you very much for your time. First time doing any of this, so I appreciate it.

1 Like