Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: "Failed to retrieve real time from API, falling back to local time" #84

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
6 changes: 3 additions & 3 deletions server/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ end
--- @return number - Unix time
local function retrieveTimeFromApi(callback)
Citizen.CreateThread(function()
PerformHttpRequest("http://worldtimeapi.org/api/ip", function(statusCode, response)
PerformHttpRequest("https://worldtimeapi.org/api/ip", function(statusCode, response)
if statusCode == 200 then
local data = json.decode(response)
if data == nil or data.unixtime == nil then
Expand Down Expand Up @@ -293,12 +293,12 @@ CreateThread(function()
end)
end
while realTimeFromApi == nil do
if failedCount > 10 then
if failedCount > 60 then
print("Failed to retrieve real time from API, falling back to local time")
break
end
failedCount = failedCount + 1
Wait(100)
Wait(1000)
end
if realTimeFromApi ~= nil then
newBaseTime = realTimeFromApi
Expand Down
Loading