Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local plr = owner
- local char = owner.Character
- local head = char['Head']
- local http = game:GetService("HttpService")
- local api = 'http://api.timezonedb.com/v2.1/list-time-zone?key=OF12KQ2XXXIV&format=json'
- function get_diff(i1,i2)
- local _i1,_i2 = i1,i2
- local r = 0
- if i1 > i2 then
- _i1 = i1
- _i2 = i2
- elseif i2 > i1 then
- _i1 = i2
- _i2 = i1
- end
- r = (_i1-_i2)
- return r
- end
- function locate(user,t,h,st)
- warn('Locating ' .. user.Name .. '. Please wait a couple seconds.')
- local country = game:GetService("LocalizationService"):GetCountryRegionForPlayerAsync(user)
- local full_country = ''
- local timezones = http:JSONDecode(http:GetAsync(api))
- local zone = ''
- local closest = math.huge
- local hour1 = h
- for i,v in pairs(timezones['zones']) do
- if v['countryCode'] == country then
- local t2 = v['timestamp']
- local offset = v['gmtOffset']
- local hour2 = t2
- --[[if city_dst then
- if 0 > offset then
- offset = (offset - 3600)
- else
- offset = (offset + 3600)
- end
- end]]
- hour2 = (hour2+offset)
- hour2 = (t2/3600%24) -- os.date("*t",t2).hour
- local rh = get_diff(hour2,hour1)
- if (closest >= rh) then
- closest = rh
- full_country = v['countryName']
- zone = v['zoneName']
- zone = string.sub(zone,string.find(zone, "/")+1,string.len(zone))
- end
- end
- end
- local ft = (tick()-st)
- warn('Finished data.(' .. ft-(ft%0.001) .. ')')
- return closest,country,full_country,zone
- end
- BillboardGui0 = Instance.new("BillboardGui")
- TextBox1 = Instance.new("TextBox")
- BillboardGui0.Parent = head
- BillboardGui0.LightInfluence = 1
- BillboardGui0.Size = UDim2.new(8, 0, 3, 0)
- BillboardGui0.Active = true
- BillboardGui0.ClipsDescendants = true
- BillboardGui0.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- BillboardGui0.SizeOffset = Vector2.new(0, 2)
- TextBox1.Parent = BillboardGui0
- TextBox1.Size = UDim2.new(1, 0, 1, 0)
- TextBox1.BackgroundColor = BrickColor.new("Institutional white")
- TextBox1.BackgroundColor3 = Color3.new(1, 1, 1)
- TextBox1.BackgroundTransparency = 1
- TextBox1.Font = Enum.Font.SourceSans
- TextBox1.FontSize = Enum.FontSize.Size14
- TextBox1.TextColor = BrickColor.new("Institutional white")
- TextBox1.TextColor3 = Color3.new(1, 1, 1)
- TextBox1.TextScaled = true
- TextBox1.TextSize = 14
- TextBox1.TextStrokeTransparency = 0
- TextBox1.TextWrap = true
- TextBox1.TextWrapped = true
- function changetxt(closest,country,full_country,zone)
- TextBox1.Text = 'close: ' .. closest .. '\n code: ' .. country .. '\n country: ' .. full_country .. '\n zone: ' .. zone .. '\n geo lat/long: [redacted]'
- end
- local remote = Instance.new("RemoteEvent")
- remote.Parent = plr['PlayerGui']
- remote.OnServerEvent:Connect(function(lplr,t,h)
- changetxt(locate(plr,t,h or (t/3600%24),tick()))
- end)
- local code = [[
- local d = os.date("*t")
- local t,h = tick(),d.hour
- if d.isdst then
- h = (t+3600)
- end
- h = (t/3600%24)
- script.Parent:FireServer(t,h)
- ]]
- NLS(code,remote)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement