Developer

4 min readUpdated Today

Overview

Integration uses server/client exports for radiation state, handler hooks in the open/ folder for custom logic, and a StateBag for real-time client-side access. Radiation is server-authoritative, the server only accepts increases from clients and handles all decreases internally. The mutating exports (`SetRadiation`, `AddRadiation`, `RemoveRadiation`) only accept calls from resources listed in `Config.AdminExportResources` (default: ml_radiation, ml_healthsystem, ml_staff); add your resource there to call them. `GetPlayerRadiation` is read-only and always open.

Server Exports

Radiation State

lua
1local radiation = exports.ml_radiation:GetPlayerRadiation(source)
2exports.ml_radiation:SetRadiation(source, 500)
3exports.ml_radiation:AddRadiation(source, 100)
4exports.ml_radiation:RemoveRadiation(source, 200)
5exports.ml_radiation:RemoveRadiation(source) -- removes all
6exports.ml_radiation:ResetRadiation(source)
  • GetPlayerRadiation(source): Returns current radiation level (0.0-1000.0)
  • SetRadiation(source, level): Sets radiation to a specific value. Clamped between 0 and MaxRadiation
  • AddRadiation(source, amount): Adds radiation to the current level
  • RemoveRadiation(source, amount?): Removes radiation. If amount is omitted, removes all radiation
  • ResetRadiation(source): Sets radiation to zero and saves it. Returns true if the player was loaded. Not restricted by Config.AdminExportResources

Client Exports

lua
1local radiation = exports.ml_radiation:GetRadiation()
2local ceiling = exports.ml_radiation:GetMaxRadiation()
3
4exports.ml_radiation:PauseRadiation()
5exports.ml_radiation:ResumeRadiation()
6local paused = exports.ml_radiation:IsRadiationPaused()
  • GetRadiation(): Returns the local player's current radiation level
  • GetMaxRadiation(): Returns Config.PlayerEffects.MaxRadiation
  • PauseRadiation(): Stops contamination, damage, effects and sounds, and closes the Geiger interface
  • ResumeRadiation(): Restarts from the level held before the pause
  • IsRadiationPaused(): Returns true while paused

State Bags

The player's radiation level is written to the player's own StateBag (server-side on change, client mirror every second). It is set with replication disabled, so each client reads only its own value:

lua
1local radiation = LocalPlayer.state.radiation

Readable from the local player's own client scripts without exports.

Server Handlers

Located in open/server.lua.

Item Control

open/server.lua
1function OpenServer.BeforeGiveItem(src, item, amount)
2    return true -- return false to block
3end

Called before giving an item to the player (cure/immunity items). Return false to block.

Action Lifecycle

open/server.lua
1function OpenServer.OnActionComplete(src, actionType, data)
2end

Fires after an action completes (e.g. using a cure or immunity item).

Client Handlers

Located in open/client.lua.

Interaction

open/client.lua
1function OpenClient.BeforeOpenUI(data)
2    return true -- return false to block
3end

Called before the Geiger Counter UI opens. Return false to block.

Notifications

Notifications are sent through ml_bridge. Set Config.Notify in ml_bridge/config.lua to pick the system: auto, ox, qb, esx, wasabi, okok, mythic, pnotify, tnotify, brutal, lation, r_notify, fl, zsx.

Shared Handlers

Located in open/shared.lua.

open/shared.lua
1function OpenHandlers.OnPlayerAction(src, data)
2    return true -- return false to block
3end
4
5function OpenHandlers.ValidateAction(src, actionType)
6    return true -- return false to block
7end
  • OnPlayerAction: Global hook before any action. Return false to block.
  • ValidateAction: Pre-flight validation before an action is dispatched.

Commands

  • /movegeiger: Enter UI repositioning mode (Geiger must be open)
  • /resetgeigerpos: Reset Geiger UI position to defaults
  • /setradiation [level]: Sets your own radiation to a specific value (0-1000). Only registered when Config.Debug = true; it is a debug helper, not an admin command. It does not read ServerConfig.AdminPermissions

Examples

lua
1-- Server
2local rad = exports.ml_radiation:GetPlayerRadiation(source)
3if rad > 500 then
4    Bridge.NotifyPlayer(source, 'warning', 'High radiation detected!')
5end
6
7-- Client (via StateBag, no export needed)
8CreateThread(function()
9    while true do
10        local rad = LocalPlayer.state.radiation or 0
11        if rad > 750 then
12            -- trigger custom warning
13        end
14        Wait(5000)
15    end
16end)
open/client.lua
1function OpenClient.BeforeOpenUI(data)
2    local zone = GetNameOfZone(GetEntityCoords(cache.ped))
3    if zone == 'AIRP' then
4        Bridge.Notify('Cannot use Geiger here', 'error')
5        return false
6    end
7    return true
8end
lua
1-- Server: remove all radiation and add immunity via item system
2exports.ml_radiation:RemoveRadiation(source)

Config.OnDeath already covers this when the framework reports the player as dead. Use the exports for a downed state that keeps the ped alive.

lua
1-- Client, in the ambulance or death script
2AddEventHandler('yourAmbulance:playerDowned', function()
3    exports.ml_radiation:PauseRadiation()
4end)
5
6AddEventHandler('yourAmbulance:playerRevived', function()
7    exports.ml_radiation:ResumeRadiation()
8end)

For a New Life reset, call the server export:

lua
1-- Server
2RegisterNetEvent('yourAmbulance:newLife', function()
3    exports.ml_radiation:ResetRadiation(source)
4end)
Radiation Zones Developer, FiveM Docs | Micio Mods