HZ Scripts

Exports & Events

Hz-Weather Pro exposes 50+ exports and numerous events for developers to integrate weather data into their scripts.


Server Exports

All server exports are called via exports['HZ-Weather']:functionName(...).

Core

ExportParametersReturnsDescription
IsReady()booleanWhether HZ-Weather has fully initialized
GetVersion()stringVersion string (e.g. "1.0.0")
GetUptime()numberSeconds since resource start

Weather & Zones

ExportParametersReturnsDescription
getPlayerZone(source)source: numberstring\nilZone name for a player's position
getZoneWeather(zoneName)zoneName: stringstringWeather type for a specific zone
setZoneWeather(zoneName, weather)zoneName: string, weather: stringSet weather for a zone
getPlayersInZone(zoneName)zoneName: stringnumber[]Player server IDs in a zone
createZone(data)data: tablenumberCreate a new zone, returns zone ID
updateZone(zoneId, data)zoneId: number, data: tableUpdate a zone's properties
deleteZone(zoneId)zoneId: numberDelete a zone

Forecast

ExportParametersReturnsDescription
getForecast(zoneName, count)zoneName: string\nil, count: number\niltable[]Weather predictions for a zone (nil = global)
getAllZoneForecasts(count)count: number\niltableForecasts for all zones + global {global=[...], zoneName=[...]}

Seasons

ExportParametersReturnsDescription
getCurrentSeason()stringCurrent season name
getSeasonData(name)name: stringtableSeason preset data
setSeason(name)name: stringChange to a specific season
getNextSeason()stringNext season in cycle
getSeasonProgress()numberSeason progress percentage (0-100)
getCycleProgress()tableFull cycle progress info
getAllSeasons()tableAll season presets
getSeasonState()tableFull season state object

Temperature

ExportParametersReturnsDescription
getTemperature(zoneName)zoneName: stringnumberTemperature in Celsius
getTemperatureForPlayer(source)source: numbernumberTemperature for player's zone
setTemperatureRange(zoneName, min, max)zoneName: string, min: number, max: numberSet min/max for a zone
getAllTemperatures()tableAll zone temperatures
celsiusToFahrenheit(celsius)celsius: numbernumberConvert C to F
fahrenheitToCelsius(fahrenheit)fahrenheit: numbernumberConvert F to C

Wind

ExportParametersReturnsDescription
getWindSpeed()numberCurrent wind speed (km/h)
getWindDirection()numberWind direction (0-360 degrees)
setWind(speed, direction)speed: number, direction: numberSet wind speed and direction
getWindData()tableComplete wind state {speed, direction}

Database

ExportParametersReturnsDescription
GetConfig(key)key: stringanyGet a config value from database
SetConfig(key, value)key: string, value: anySet a config value in database
LoadZones()table[]Load all weather zones from DB
CreateZone(data)data: tablenumberCreate zone in DB, returns ID
UpdateZone(zoneId, data)zoneId: number, data: tableUpdate zone in database
DeleteZone(zoneId)zoneId: numberDelete zone from database

Bridge

ExportParametersReturnsDescription
GetFramework()stringDetected framework (qb, esx, standalone)
GetFrameworkObject()table\nilRaw framework object
HasPermission(source, permission)source: number, permission: stringbooleanCheck ACE permission

Client Exports

All client exports are called via exports['HZ-Weather']:functionName(...).

Weather & Effects

ExportParametersReturnsDescription
getCurrentWeather()stringCurrent weather type
getCurrentTemperature()numberCurrent temperature value

Zones

ExportParametersReturnsDescription
getCurrentZone()string\nilCurrent zone name (nil if no zone)
getZoneData(zoneName)zoneName: stringtable\nilZone properties
getActiveZones()table[]All active zones
isInZone(zoneName)zoneName: stringbooleanCheck if player is in a zone
getAllInsideZones()string[]All zones the player is inside

Seasons

ExportParametersReturnsDescription
getCurrentSeason()stringCurrent season name
getSeasonData()tableCurrent season preset data
getSeasonIcon()stringSeason emoji icon
getSeasonLabel(locale)locale: stringstringLocalized season name
getSeasonProgress()numberSeason progress (0-100)

Temperature

ExportParametersReturnsDescription
getTemperature()numberTemperature for player's zone (C)
getTemperatureString(unit)unit: 'C'\'F'stringFormatted string (e.g. "23°C")
getZoneTemperature(zoneName)zoneName: stringnumberTemperature for a specific zone
getAllTemperatures()tableAll zone temperatures
celsiusToFahrenheit(celsius)celsius: numbernumberConvert C to F

Wind

ExportParametersReturnsDescription
getWindSpeed()numberCurrent wind speed (km/h)
getWindDirection()numberWind direction (0-360)
getWindVector()tableWind as {x, y} vector

Admin Panel

ExportParametersReturnsDescription
openAdminPanel()Open the admin NUI panel
closeAdminPanel()Close the admin NUI panel
isAdminPanelOpen()booleanWhether panel is open

Events (Server)

Admin Events

Triggered by the admin panel (client -> server). All require the hz_weather.admin ACE permission.

EventParametersDescription
hz_weather:admin:requestDataRequest all current state data
hz_weather:admin:setWeatherweather: stringSet global weather
hz_weather:admin:setZoneWeatherzoneName: string, weather: stringSet weather for a zone
hz_weather:admin:setAllZonesWeatherweather: stringSet weather for all zones
hz_weather:admin:freezeWeatherstate: booleanFreeze/unfreeze weather
hz_weather:admin:setTimehour: number, minute: numberSet server time
hz_weather:admin:freezeTimestate: booleanFreeze/unfreeze time
hz_weather:admin:syncRealTimeSync with real-world time
hz_weather:admin:setSeasonseason: stringSet season preset
hz_weather:admin:skipSeasonSkip to next season
hz_weather:admin:setCycleModemode: stringSet cycle mode
hz_weather:admin:setBlackoutstate: booleanEnable/disable blackout
hz_weather:admin:setBlackoutVehiclesstate: booleanBlackout affects vehicles
hz_weather:admin:teleportToZonezoneName: stringTeleport admin to zone center
hz_weather:admin:setZoneTemperatureRangezoneName: string, min: number, max: numberSet zone temperature range
hz_weather:admin:setTemperatureUnitunit: 'C'\'F'Set display unit
hz_weather:admin:setTemperatureModemode: stringSet temp mode

Disaster Events

EventParametersDescription
hz_weather:admin:startTornadox?: number, y?: numberStart tornado (optional pos)
hz_weather:admin:stopTornadoStop tornado
hz_weather:admin:pauseTornadoPause/resume tornado
hz_weather:admin:startTsunamiStart tsunami
hz_weather:admin:stopTsunamiStop tsunami
hz_weather:admin:pauseTsunamiPause/resume tsunami

Forecast Events

EventParametersDescription
hz_weather:admin:getForecastzoneName: string\nil, count: numberRequest forecast for a zone (admin)
hz_weather:admin:getAllForecastscount: numberRequest all zone forecasts (admin)
hz_weather:admin:editForecastEntry{source, index, weather?, duration?}Edit a forecast entry (admin)
hz_weather:admin:insertForecastEntry{source, afterIndex, weather, duration}Insert a forecast entry (admin)
hz_weather:admin:removeForecastEntry{source, index}Remove a forecast entry (admin)

Callbacks (lib.callback)

CallbackParametersReturnsDescription
hz-weather:getForecastzoneName: string\nil, count: number\nilstringJSON-encoded forecast for a zone
hz-weather:getMapDatastringJSON-encoded map data (weather, zones, forecast, time)

Sync Events

EventParametersDescription
hz_weather:requestTemperaturesRequest temperature data
hz_weather:requestSeasonRequest season data
hz_weather:requestZonesDataRequest zone data
hz_weather:requestWindRequest wind data
hz_weather:tornado:requestSyncRequest tornado state
hz_weather:tsunami:requestSyncRequest tsunami state
hz_weather:playerZoneChangedoldZone: string, newZone: stringPlayer changed zone

Events (Client)

Sync Events (Server -> Client)

EventDataDescription
hz_weather:syncWeather{weather, windSpeed?, windDirection?}Weather sync (zone change)
hz_weather:weatherChanged{weather, zone?}Weather broadcast
hz_weather:syncSeason{season, preset, progress}Season sync
hz_weather:syncTemperatures{[zone]: temperature}Temperature data sync
hz_weather:syncWind{speed, direction}Wind data sync
hz_weather:receiveZonesDatazone[]Zone definitions

Disaster Events (Server -> Client)

Tornado

EventDataDescription
hz_weather:tornado:phaseChangedphase, dataPhase changed
hz_weather:tornado:updateStatex, y, intensity, physOwnerPosition/intensity update
hz_weather:tornado:notifymessageNotification
hz_weather:tornado:cleanupClean up effects
hz_weather:tornado:synctornadoStateFull state sync
Tornado phases: IDLE -> WARNING -> ACTIVE -> DISSIPATING -> CLEANUP -> IDLE

Tsunami

EventDataDescription
hz_weather:tsunami:phaseChangedphase, dataPhase changed
hz_weather:tsunami:updateHeightheightWater height update
hz_weather:tsunami:loadFloodLoad flood water XML
hz_weather:tsunami:notifymessageNotification
hz_weather:tsunami:cleanupClean up effects
hz_weather:tsunami:synctsunamiStateFull state sync
Tsunami phases: IDLE -> WARNING -> RISING -> PEAK -> RECEDING -> CLEANUP -> IDLE

Admin Panel Events (Server -> Client)

EventDataDescription
hz_weather:admin:sendDataallDataFull admin panel data
hz_weather:admin:updateWeatherweatherDataWeather update for panel
hz_weather:admin:updateTimetimeDataTime update for panel
hz_weather:admin:updateSeasonseasonDataSeason update for panel
hz_weather:admin:updateTemperaturestempDataTemperature update
hz_weather:client:teleportToCoordsx, y, zTeleport player

Internal Events

These are fired locally (same side) and can be listened to with AddEventHandler.

Client-Side

EventParametersDescription
hz_weather:zoneChangedoldZone, newZonePlayer entered a new zone
hz_weather:temperatureChangedzoneName, oldTemp, newTempTemperature changed
hz_weather:seasonChangedoldSeason, newSeasonSeason changed

Server-Side

EventParametersDescription
hz_weather:onPlayerZoneChangedsource, oldZone, newZoneA player changed zone
hz_weather:weatherChangedoldWeather, newWeatherGlobal weather changed
hz_weather:seasonWeatherChangedseason, weatherSeason triggered weather

GlobalState Keys

Accessible from both client and server via GlobalState.key.

KeyTypeDescription
weathertable{weather: string, blackout: boolean, timestamp: number}
blackOutbooleanLighting blackout active
blackOutVehiclesbooleanBlackout affects vehicle lights
freezeWeatherbooleanWeather changes frozen
currentTimetable{hour: number, minute: number}
freezeTimebooleanTime advancement frozen
timeScalenumberMilliseconds per game minute
windtable{speed: number, direction: number}
tornadotable\nil{phase: string, x: number, y: number, intensity: number}
tsunamitable\nil{phase: string, height: number}

Admin Commands

Server Commands

All require hz_weather.admin ACE permission.

CommandUsageDescription
/time/time [minute]Set server time
/morning/morningSet time to 09:00
/noon/noonSet time to 12:00
/evening/eveningSet time to 18:00
/night/nightSet time to 23:00
/timescale/timescale Set time speed
/freezetime/freezetime [on\off]Freeze/unfreeze time
/season/season summer\autumn\winter>Set season
/skipseason/skipseasonSkip to next season
/tornado/tornado stop\pause\status>Manage tornado
/tsunami/tsunami stop\pause\status>Manage tsunami

Client Commands

CommandDescription
/windDisplay wind speed in chat
/temperature or /tempDisplay current temperature
/seasonDisplay current season

Compatibility Layer

Hz-Weather provides full backward compatibility for these resources. Scripts using their exports will work without any changes.

qb-weathersync

-- Server exports
exports['qb-weathersync']:setWeather('CLEAR')
exports['qb-weathersync']:setTime(12, 0)
exports['qb-weathersync']:setBlackout(true)
exports['qb-weathersync']:setTimeFreeze(true)
exports['qb-weathersync']:getBlackoutState()
exports['qb-weathersync']:getTimeFreezeState()
exports['qb-weathersync']:getWeatherState()
exports['qb-weathersync']:getTime()

-- Server events
TriggerServerEvent('qb-weathersync:server:setWeather', 'CLEAR')
TriggerServerEvent('qb-weathersync:server:setTime', 12, 0)
TriggerServerEvent('qb-weathersync:server:setBlackout', true)

-- Client events
RegisterNetEvent('qb-weathersync:client:DisableSync')
RegisterNetEvent('qb-weathersync:client:EnableSync')

cd\_easytime

-- Server exports
local data = exports['cd_easytime']:GetWeather()
-- Returns: { weather = 'CLEAR', blackout = false, freeze = false }

-- Client events
RegisterNetEvent('cd_easytime:PauseSync')


Integration Examples

Get weather for a zone (server)

local weather = exports['HZ-Weather']:getZoneWeather('Sandy Shores')
print('Sandy Shores weather:', weather) -- "EXTRASUNNY"

React to zone changes (client)

AddEventHandler('hz_weather:zoneChanged', function(oldZone, newZone)
    print('Entered zone:', newZone, 'from', oldZone)
end)

Get formatted temperature (client)

local tempStr = exports['HZ-Weather']:getTemperatureString('C')
print('Current temperature:', tempStr) -- "23°C"

Check player zone and temperature (server)

local zoneName = exports['HZ-Weather']:getPlayerZone(source)
local temp = exports['HZ-Weather']:getTemperature(zoneName or 'global')
TriggerClientEvent('chat:addMessage', source, {
    args = { 'Weather', 'Temperature: ' .. temp .. '°C' }
})

Special weather for a heist (server)

RegisterCommand('startHeist', function(source)
    exports['HZ-Weather']:setZoneWeather('Los Santos', 'FOGGY')
    -- Restore after 30 minutes
    SetTimeout(30  60  1000, function()
        exports['HZ-Weather']:setZoneWeather('Los Santos', 'CLEAR')
    end)
end, true)

Check if tornado is active (client)

local tornado = GlobalState.tornado
if tornado and tornado.phase == 'ACTIVE' then
    print('Tornado at', tornado.x, tornado.y, 'intensity:', tornado.intensity)
end

Listen for season changes (server)

AddEventHandler('hz_weather:seasonChanged', function(oldSeason, newSeason)
    print('Season changed:', oldSeason, '->', newSeason)
    -- Add snow decorations, seasonal items, etc.
end)

Embeddable Weather Map (iframe)

Hz-Weather Pro includes a standalone weather map page that can be embedded in any phone resource or NUI via iframe.

URL

https://cfx-nui-HZ-Weather/web/dist/map.html

What it displays

  • GTA V satellite map (tile-based, pan + zoom)
  • Weather emoji + zone name + temperature at each zone center
  • Global weather, season, wind info
  • Auto-refreshes every 30 seconds

Embed in any phone (HTML)

<iframe
  src="https://cfx-nui-HZ-Weather/web/dist/map.html"
  style="width:100%;height:100%;border:none"
  sandbox="allow-same-origin allow-scripts"
/>

Embed in React

<iframe
  src="https://cfx-nui-HZ-Weather/web/dist/map.html"
  style={{ width: '100%', height: '100%', border: 'none' }}
  sandbox="allow-same-origin allow-scripts"
/>

How it works

  1. The parent page fetches weather data via NUI callback or lib.callback
  2. The parent sends data to the iframe via postMessage({ type: 'hz-weather-data', payload: data })
  3. map.html listens for message events and renders markers on the satellite map
  4. On load, the iframe requests data from its parent via postMessage({ type: 'hz-weather-request' })
The map page does not call any NUI callback directly — all data comes from the parent via postMessage.

NUI Callback: getMapData

Returns JSON:

{
  "globalWeather": "CLEAR",
  "globalTemperature": 22.5,
  "season": {
    "name": "summer",
    "icon": "...",
    "label": { "en": "Summer", "fr": "Ete" }
  },
  "wind": { "speed": 15.2, "direction": 180 },
  "locale": "en",
  "temperatureUnit": "C",
  "zones": [
    {
      "name": "los_santos",
      "label": { "en": "Los Santos" },
      "center": { "x": 200, "y": -1000 },
      "weather": "CLEAR",
      "temperature": 22.5,
      "isActive": true
    }
  ]
}

Build Your Own Weather App (Phone Integration)

You can create a weather app inside any phone resource (lb-phone, qs-phone, etc.) using HZ-Weather's callback and events.

Architecture

┌─────────────┐  NUI callback  ┌─────────────┐  lib.callback  ┌────────────┐
│  Your Phone │ ──────────────► │ Your Phone  │ ──────────────► │ HZ-Weather │
│    (UI)     │ ◄────────────── │  (Client)   │ ◄────────────── │  (Server)  │
└─────────────┘  JSON response  └──────┬──────┘  JSON string    └────────────┘
                                       │
                                       │  hz_weather:zoneChanged (local event)
                                       │
                                ┌──────┴──────┐
                                │ HZ-Weather  │
                                │  (Client)   │
                                └─────────────┘
No server file neededlib.callback handles the client-server round-trip.

Client-side Lua (one file)

-- client/weather.lua in your phone resource

RegisterNUICallback('getWeatherData', function(_, cb)
lib.callback('hz-weather:getMapData', false, function(jsonStr)
if type(jsonStr) == 'string' then
local data = json.decode(jsonStr)
if data then
local ok, zone = pcall(exports['HZ-Weather'].getCurrentZone, exports['HZ-Weather'])
data.currentZone = ok and zone or nil
end
cb(data or { error = 'no_data' })
else
cb({ error = 'no_data' })
end
end)
end)

AddEventHandler('hz_weather:zoneChanged', function(oldZone, newZone)
SendNUIMessage({ type = 'weather-zone-update', currentZone = newZone })
end)

UI-side (JavaScript)

async function fetchWeather() {
  const resp = await fetch('https://cfx-nui-YOUR_RESOURCE/getWeatherData', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({})
  });
  return resp.json();
}

// Listen for real-time zone changes
window.addEventListener('message', (e) => {
if (e.data.type === 'weather-zone-update') {
const newZone = e.data.currentZone;
// Update your UI
}
});

Weather type icons

const WEATHER_ICONS = {
  EXTRASUNNY: '☀️', CLEAR: '🌤️', CLOUDS: '⛅',
  OVERCAST: '☁️', RAIN: '🌧️', THUNDER: '⛈️',
  CLEARING: '🌥️', FOGGY: '🌫️', SMOG: '🌫️',
  SNOW: '❄️', SNOWLIGHT: '🌨️', BLIZZARD: '🌬️', XMAS: '🎄'
};

Tip: Exports are the recommended way to integrate Hz-Weather Pro. They are stable and won't change between minor updates.