Advertisement
ERROR_CODE

weather

Dec 11th, 2024 (edited)
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. local HttpService = game:GetService("HttpService")
  2.  
  3. local apiKey = "dc437a851815d0fc93f0488ae201dc06" -- Твой API ключ
  4. local city = "Gomel" -- Название города
  5. local country = "BY" -- Код страны
  6.  
  7. local function updateTemperature()
  8.     local url = "http://api.weatherapi.com/v1/current.json?key="..apiKey .."&q="..city..""..country.."&aqi=no"
  9.    
  10.     local response
  11.     pcall(function()
  12.         response = HttpService:JSONDecode(game:HttpGetAsync(url))
  13.     end)
  14.  
  15.     if response then
  16.         local temperature = response.main.temp
  17.         print("Температура: " .. tostring(temperature) .. "°C")
  18.     else
  19.         print("Не удалось получить данные о погоде")
  20.     end
  21. end
  22.  
  23. updateTemperature()
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement