How to get latest Place History version?

As part of a Debug GUI in my game, it tries to compare the current server version to the latest version of the game. The beginning part is easy to do, thanks to game.PlaceVersion, but the latter of trying to get the latest version number is really tricky.

Does anyone know a simple way of doing this?

2 Likes

I don’t believe there’s a simple way of doing this without a middleman server that uses the Roblox API.

You probably even need authentication to get it.

I’ll take a look at the api reference/docs to see if there’s a way to do it without a middleman.

1 Like

AssetService

I originally looked at this running this code:

local pages = game:GetService("AssetService"):GetGamePlacesAsync()
while true do
     for _,place in pairs(pages:GetCurrentPage()) do

		for key,value in pairs(place) do
			print(key, value)
		end          

		print('end\n')

     end
     if pages.IsFinished then
          -- we reached the last page of results
          break
     end
     pages:AdvanceToNextPageAsync()
end

But alas, no result:

[Name]     ElliottLMz's Place Number: 594
[PlaceId]  3993979553

This was all I got (code above beautified)

Back To Searching

InsertService

My next avenue of search was this

> print(game.InsertService:GetLatestAssetVersionAsync(game.PlaceId))
4763230077
> print(game.CreatorId)
47890485

Nothing. But skeletons.

API

After half an hour of searching, I decided to bite the bullet, and check the API documentation.

GET /assets/{id}/versions

Slight issue.

{"errors":[{"code":403,"message":"Forbidden"}]}

You had to be authorised to manage the game.
It does work though

[{"Id":4763230077,"AssetId":3993979553,"VersionNumber":2,"ParentAssetVersionId":4763229799,"CreatorType":1,"CreatorTargetId":47890485,"CreatingUniverseId":null,"Created":"2019-09-27T23:12:47.11Z","Updated":"2019-09-27T23:12:47.11Z"},{"Id":4763229799,"AssetId":3993979553,"VersionNumber":1,"ParentAssetVersionId":null,"CreatorType":1,"CreatorTargetId":47890485,"CreatingUniverseId":null,"Created":"2019-09-27T23:12:44.047Z","Updated":"2019-09-27T23:12:44.047Z"}]
Why’s this bad?

Great question. Unfortunately, 1) you need a middleman server; and 2) you must be authorised, which is a pain- especially if your cookie expires.

My solution #1

When a server starts, check if a DataStore value is less than the place’s version, if so, update it.
Hook an OnUpdate and you’ll be able to know if a server has started with a newer version.

My solution #1(b)

Add a debug option to force-set the latest version.

Conclusion

This is really all I can find. I hope I’ve helped you to the best of my ability.

3 Likes

Alright. Thank you so much for the assistance! I guess I’ll mark this as the solution for now, if anyone can find anything better I’d be happy to hear though :slight_smile:

1 Like

I’ve been tackling this same problem today and this API ended up being the perfect solution for me:

Even though this provides a sort of random number for the version, that number changes with updates to the game and can be used in a “cache on start + check when you’re ready to migrate” type fashion.

This method also provides a benefit over the datastore method as you don’t need another server of the new version to start up to establish the change.

4 Likes