Exports

The following events and exports can be used from your own scripts to interact and/or receive info from the weather script.

zoneUpdated

This event gets triggered when a zone is updated from server, contains the zone name and a table with zone info.

params:

  • zone: string

  • data: table

AddEventHandler('av_weather:zoneUpdated', function(zone,data)
    print(zone, json.encode(data,{ indent = true}))
    --[[
        data = {
           wind: number,
           zone: string,
           fog: string,
           windState: string,
           label: string,
           weather: string,
           freeze: boolean,
           frozenFog: string,
           temperature: number
        }
    ]]--
end

timeUpdated

This event gets triggered when in game time is updated.

params:

  • hours: number

  • minutes: number

  • seconds: number

AddEventHandler('av_weather:timeUpdated',function(hours,minutes,seconds)
    print(hours, minutes, seconds)
end)

Freeze/Unfreeze Time and Weather for local player

Use this event to freeze or sync the time for a local player, useful for multicharacter, spawn scripts, houses/motel scripts, etc.

params:

  • state: Boolean

  • hours: number optional

  • minutes: number optional

  • weather: string optional

  • blackout: Boolean optional

  • fog: string optional

  • snow: boolean optional

-- This is an example on how to freeze a player time:
local state = true
local hours = 23
local minutes = 0
local weather = "CLEAR"
local blackout = false
local fog = false
local snow = false -- render snow on ground
-- Fog options: "automatic", "no", "normal", "low", "medium", "high", "max" or false
TriggerEvent('av_weather:freeze', state, hours, minutes, weather, blackout, fog, snow)
-- This is an example on how to unfreeze player time and sync with server
TriggerEvent('av_weather:freeze', false)

getZone()

Use this export to get the current zone where the player is standing.

returns:

zone: string

local zone = exports['av_weather']:getZone()
-- zone can be "santos", "cayo", "paleto" or "sandy"

getBlackout()

Use this export to retrieve the current blackout state.

returns:

state: Boolean

local blackout = exports['av_weather']:getBlackout()
-- blackout = true or false

setRain()

Removes rain effects from the player, useful for those using YMAPs where rain comes through the roof creating puddles inside their map.

params:

state: Boolean

local state = true -- or false to enable effect again
exports['av_weather']:setRain(state)

Last updated