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
| Export | Parameters | Returns | Description |
IsReady() | — | boolean | Whether HZ-Weather has fully initialized |
GetVersion() | — | string | Version string (e.g. "1.0.0") |
GetUptime() | — | number | Seconds since resource start |
Weather & Zones
| Export | Parameters | Returns | Description |
getPlayerZone(source) | source: number | string\ | nil | Zone name for a player's position |
getZoneWeather(zoneName) | zoneName: string | string | Weather type for a specific zone |
setZoneWeather(zoneName, weather) | zoneName: string, weather: string | — | Set weather for a zone |
getPlayersInZone(zoneName) | zoneName: string | number[] | Player server IDs in a zone |
createZone(data) | data: table | number | Create a new zone, returns zone ID |
updateZone(zoneId, data) | zoneId: number, data: table | — | Update a zone's properties |
deleteZone(zoneId) | zoneId: number | — | Delete a zone |
Forecast
| Export | Parameters | Returns | Description |
getForecast(zoneName, count) | zoneName: string\ | nil, count: number\ | nil | table[] | Weather predictions for a zone (nil = global) |
getAllZoneForecasts(count) | count: number\ | nil | table | Forecasts for all zones + global {global=[...], zoneName=[...]} |
Seasons
| Export | Parameters | Returns | Description |
getCurrentSeason() | — | string | Current season name |
getSeasonData(name) | name: string | table | Season preset data |
setSeason(name) | name: string | — | Change to a specific season |
getNextSeason() | — | string | Next season in cycle |
getSeasonProgress() | — | number | Season progress percentage (0-100) |
getCycleProgress() | — | table | Full cycle progress info |
getAllSeasons() | — | table | All season presets |
getSeasonState() | — | table | Full season state object |
Temperature
| Export | Parameters | Returns | Description |
getTemperature(zoneName) | zoneName: string | number | Temperature in Celsius |
getTemperatureForPlayer(source) | source: number | number | Temperature for player's zone |
setTemperatureRange(zoneName, min, max) | zoneName: string, min: number, max: number | — | Set min/max for a zone |
getAllTemperatures() | — | table | All zone temperatures |
celsiusToFahrenheit(celsius) | celsius: number | number | Convert C to F |
fahrenheitToCelsius(fahrenheit) | fahrenheit: number | number | Convert F to C |
Wind
| Export | Parameters | Returns | Description |
getWindSpeed() | — | number | Current wind speed (km/h) |
getWindDirection() | — | number | Wind direction (0-360 degrees) |
setWind(speed, direction) | speed: number, direction: number | — | Set wind speed and direction |
getWindData() | — | table | Complete wind state {speed, direction} |
Database
| Export | Parameters | Returns | Description |
GetConfig(key) | key: string | any | Get a config value from database |
SetConfig(key, value) | key: string, value: any | — | Set a config value in database |
LoadZones() | — | table[] | Load all weather zones from DB |
CreateZone(data) | data: table | number | Create zone in DB, returns ID |
UpdateZone(zoneId, data) | zoneId: number, data: table | — | Update zone in database |
DeleteZone(zoneId) | zoneId: number | — | Delete zone from database |
Bridge
| Export | Parameters | Returns | Description |
GetFramework() | — | string | Detected framework (qb, esx, standalone) |
GetFrameworkObject() | — | table\ | nil | Raw framework object |
HasPermission(source, permission) | source: number, permission: string | boolean | Check ACE permission |
Client Exports
All client exports are called via exports['HZ-Weather']:functionName(...).
Weather & Effects
| Export | Parameters | Returns | Description |
getCurrentWeather() | — | string | Current weather type |
getCurrentTemperature() | — | number | Current temperature value |
Zones
| Export | Parameters | Returns | Description |
getCurrentZone() | — | string\ | nil | Current zone name (nil if no zone) |
getZoneData(zoneName) | zoneName: string | table\ | nil | Zone properties |
getActiveZones() | — | table[] | All active zones |
isInZone(zoneName) | zoneName: string | boolean | Check if player is in a zone |
getAllInsideZones() | — | string[] | All zones the player is inside |
Seasons
| Export | Parameters | Returns | Description |
getCurrentSeason() | — | string | Current season name |
getSeasonData() | — | table | Current season preset data |
getSeasonIcon() | — | string | Season emoji icon |
getSeasonLabel(locale) | locale: string | string | Localized season name |
getSeasonProgress() | — | number | Season progress (0-100) |
Temperature
| Export | Parameters | Returns | Description |
getTemperature() | — | number | Temperature for player's zone (C) |
getTemperatureString(unit) | unit: 'C'\ | 'F' | string | Formatted string (e.g. "23°C") |
getZoneTemperature(zoneName) | zoneName: string | number | Temperature for a specific zone |
getAllTemperatures() | — | table | All zone temperatures |
celsiusToFahrenheit(celsius) | celsius: number | number | Convert C to F |
Wind
| Export | Parameters | Returns | Description |
getWindSpeed() | — | number | Current wind speed (km/h) |
getWindDirection() | — | number | Wind direction (0-360) |
getWindVector() | — | table | Wind as {x, y} vector |
Admin Panel
| Export | Parameters | Returns | Description |
openAdminPanel() | — | — | Open the admin NUI panel |
closeAdminPanel() | — | — | Close the admin NUI panel |
isAdminPanelOpen() | — | boolean | Whether panel is open |
Events (Server)
Admin Events
Triggered by the admin panel (client -> server). All require the hz_weather.admin ACE permission.
| Event | Parameters | Description |
hz_weather:admin:requestData | — | Request all current state data |
hz_weather:admin:setWeather | weather: string | Set global weather |
hz_weather:admin:setZoneWeather | zoneName: string, weather: string | Set weather for a zone |
hz_weather:admin:setAllZonesWeather | weather: string | Set weather for all zones |
hz_weather:admin:freezeWeather | state: boolean | Freeze/unfreeze weather |
hz_weather:admin:setTime | hour: number, minute: number | Set server time |
hz_weather:admin:freezeTime | state: boolean | Freeze/unfreeze time |
hz_weather:admin:syncRealTime | — | Sync with real-world time |
hz_weather:admin:setSeason | season: string | Set season preset |
hz_weather:admin:skipSeason | — | Skip to next season |
hz_weather:admin:setCycleMode | mode: string | Set cycle mode |
hz_weather:admin:setBlackout | state: boolean | Enable/disable blackout |
hz_weather:admin:setBlackoutVehicles | state: boolean | Blackout affects vehicles |
hz_weather:admin:teleportToZone | zoneName: string | Teleport admin to zone center |
hz_weather:admin:setZoneTemperatureRange | zoneName: string, min: number, max: number | Set zone temperature range |
hz_weather:admin:setTemperatureUnit | unit: 'C'\ | 'F' | Set display unit |
hz_weather:admin:setTemperatureMode | mode: string | Set temp mode |
Disaster Events
| Event | Parameters | Description |
hz_weather:admin:startTornado | x?: number, y?: number | Start tornado (optional pos) |
hz_weather:admin:stopTornado | — | Stop tornado |
hz_weather:admin:pauseTornado | — | Pause/resume tornado |
hz_weather:admin:startTsunami | — | Start tsunami |
hz_weather:admin:stopTsunami | — | Stop tsunami |
hz_weather:admin:pauseTsunami | — | Pause/resume tsunami |
Forecast Events
| Event | Parameters | Description |
hz_weather:admin:getForecast | zoneName: string\ | nil, count: number | Request forecast for a zone (admin) |
hz_weather:admin:getAllForecasts | count: number | Request 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)
| Callback | Parameters | Returns | Description |
hz-weather:getForecast | zoneName: string\ | nil, count: number\ | nil | string | JSON-encoded forecast for a zone |
hz-weather:getMapData | — | string | JSON-encoded map data (weather, zones, forecast, time) |
Sync Events
| Event | Parameters | Description |
hz_weather:requestTemperatures | — | Request temperature data |
hz_weather:requestSeason | — | Request season data |
hz_weather:requestZonesData | — | Request zone data |
hz_weather:requestWind | — | Request wind data |
hz_weather:tornado:requestSync | — | Request tornado state |
hz_weather:tsunami:requestSync | — | Request tsunami state |
hz_weather:playerZoneChanged | oldZone: string, newZone: string | Player changed zone |
Events (Client)
Sync Events (Server -> Client)
| Event | Data | Description |
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:receiveZonesData | zone[] | Zone definitions |
Disaster Events (Server -> Client)
Tornado
| Event | Data | Description |
hz_weather:tornado:phaseChanged | phase, data | Phase changed |
hz_weather:tornado:updateState | x, y, intensity, physOwner | Position/intensity update |
hz_weather:tornado:notify | message | Notification |
hz_weather:tornado:cleanup | — | Clean up effects |
hz_weather:tornado:sync | tornadoState | Full state sync |
Tornado phases: IDLE -> WARNING -> ACTIVE -> DISSIPATING -> CLEANUP -> IDLE
Tsunami
| Event | Data | Description |
hz_weather:tsunami:phaseChanged | phase, data | Phase changed |
hz_weather:tsunami:updateHeight | height | Water height update |
hz_weather:tsunami:loadFlood | — | Load flood water XML |
hz_weather:tsunami:notify | message | Notification |
hz_weather:tsunami:cleanup | — | Clean up effects |
hz_weather:tsunami:sync | tsunamiState | Full state sync |
Tsunami phases: IDLE -> WARNING -> RISING -> PEAK -> RECEDING -> CLEANUP -> IDLE
Admin Panel Events (Server -> Client)
| Event | Data | Description |
hz_weather:admin:sendData | allData | Full admin panel data |
hz_weather:admin:updateWeather | weatherData | Weather update for panel |
hz_weather:admin:updateTime | timeData | Time update for panel |
hz_weather:admin:updateSeason | seasonData | Season update for panel |
hz_weather:admin:updateTemperatures | tempData | Temperature update |
hz_weather:client:teleportToCoords | x, y, z | Teleport player |
Internal Events
These are fired locally (same side) and can be listened to with AddEventHandler.
Client-Side
| Event | Parameters | Description |
hz_weather:zoneChanged | oldZone, newZone | Player entered a new zone |
hz_weather:temperatureChanged | zoneName, oldTemp, newTemp | Temperature changed |
hz_weather:seasonChanged | oldSeason, newSeason | Season changed |
Server-Side
| Event | Parameters | Description |
hz_weather:onPlayerZoneChanged | source, oldZone, newZone | A player changed zone |
hz_weather:weatherChanged | oldWeather, newWeather | Global weather changed |
hz_weather:seasonWeatherChanged | season, weather | Season triggered weather |
GlobalState Keys
Accessible from both client and server via GlobalState.key.
| Key | Type | Description |
weather | table | {weather: string, blackout: boolean, timestamp: number} |
blackOut | boolean | Lighting blackout active |
blackOutVehicles | boolean | Blackout affects vehicle lights |
freezeWeather | boolean | Weather changes frozen |
currentTime | table | {hour: number, minute: number} |
freezeTime | boolean | Time advancement frozen |
timeScale | number | Milliseconds per game minute |
wind | table | {speed: number, direction: number} |
tornado | table\ | nil | {phase: string, x: number, y: number, intensity: number} |
tsunami | table\ | nil | {phase: string, height: number} |
Admin Commands
Server Commands
All require hz_weather.admin ACE permission.
| Command | Usage | Description |
/time | /time [minute] | Set server time |
/morning | /morning | Set time to 09:00 |
/noon | /noon | Set time to 12:00 |
/evening | /evening | Set time to 18:00 |
/night | /night | Set time to 23:00 |
/timescale | /timescale | Set time speed |
/freezetime | /freezetime [on\ | off] | Freeze/unfreeze time |
/season | /season | summer\ | autumn\ | winter> | Set season | |
/skipseason | /skipseason | Skip to next season |
/tornado | /tornado | stop\ | pause\ | status> | Manage tornado | |
/tsunami | /tsunami | stop\ | pause\ | status> | Manage tsunami | |
Client Commands
| Command | Description |
/wind | Display wind speed in chat |
/temperature or /temp | Display current temperature |
/season | Display 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)
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
- The parent page fetches weather data via NUI callback or
lib.callback
- The parent sends data to the iframe via
postMessage({ type: 'hz-weather-data', payload: data })
map.html listens for message events and renders markers on the satellite map
- 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 needed — lib.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.