hghguy
(hghguy)
January 4, 2022, 11:01am
#1
Hey! First post here on the DevForum, and just wanted to ask for some help!
That’s a screenshot taken from Arsenal - I know how to get FPS and version ID, but I’m not sure how to get the server location? I’ve seen something about client location, but I don’t think that’d help.
I just want to also point out something: I know that there are servers in England, and I just want to point that out to the user. I’m also not sure if those servers are possibly related to Arsenal’s own servers? I’m not sure.
Tl;DR I need to get the server location, for example, “England (United Kingdom)”
Thank you!
NyrionDev
(Nyrion)
January 4, 2022, 11:28am
#2
A solution would be to use http requests as shown below:
Hello Developers,
As you know, some games have Server Location display
In this tutorial you’ll know how to make that
Step 1
Enable https requests in your game Enable HttpsService
Step 2
Link: http://ip-api.com/json/
So, basically what this link is, whoever clicks this click, you get the location and all info, try clicking it
So you got your info, after clicking it
Now you need to make roblox server open that link
The info you get in the link is an API and is a JSON table, we have to ma…
And to get the region:
You can also use longitude to determine the servers location based on time zone.
local longitude = http:JSONDecode(http:GetAsync('http://ip-api.com/json/')).lon
local host = 'NA'
if(longitude>-180 and longitude<=-105)then
host = 'WUS'
elseif(longitude>-105 and longitude<=-90)then
host = 'CUS'
elseif(longitude>-90 and longitude<=0)then
host = 'EUS'
elseif(longitude<=75 and longitude>0)then
host = 'EU'
elseif(longitude<=180 and longitude>75)then
host = 'AS'
end
hghguy
(hghguy)
January 4, 2022, 11:41am
#3
Hi! Thanks for the quick response. I don’t think that’d give a response like “England (United Kingdom)”? Unless there is a way to transform it.
Deadwoodx
(Deadwoodx)
January 4, 2022, 11:50am
#4
The FPS can be retrieved using a local script
While ping needs to be retrieved in the server-side like this:
game.Players.PlayerAdded:Connect(function(plr)
print(plr:GetNetworkPing()) -- printed as 5 for me
end)
Note: The network ping will be in ms, like 5 ms ping
To get the server location, you need to make https request to a third party application
You can check my tutorial here:
Hello Developers,
As you know, some games have Server Location display
In this tutorial you’ll know how to make that
Step 1
Enable https requests in your game Enable HttpsService
Step 2
Link: http://ip-api.com/json/
So, basically what this link is, whoever clicks this click, you get the location and all info, try clicking it
So you got your info, after clicking it
Now you need to make roblox server open that link
The info you get in the link is an API and is a JSON table, we have to ma…
hghguy
(hghguy)
January 4, 2022, 12:04pm
#5
Hey! I knew how to get ping already - but thanks! I was just wondering, does this tutorial go over the way to convert to the format Arsenal uses? IE “England (United Kingdom)” - I haven’t got time to check it out right now but I will afterwords.
Thanks!
Deadwoodx
(Deadwoodx)
January 4, 2022, 12:11pm
#6
Read the tutorial carefully
Also to get that format, you can do:
local city = table["City"]
local country = table["Country"]
local formatted = city.."("..country..")"
print(formatted) -- England ( United Kingdom )
Based_Bern
(Based_Bern)
January 4, 2022, 12:14pm
#7
hghguy
(hghguy)
January 4, 2022, 12:50pm
#8
That’s the player, not the server! Still useful though!
1 Like
Deadwoodx
(Deadwoodx)
January 4, 2022, 1:41pm
#9
This function will return the country code, not the country name or city