Developer

3 min readUpdated 3 weeks ago

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
  • 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

Client Exports

lua
1local radiation = exports.ml_radiation:GetRadiation()
  • GetRadiation(): Returns the local player's current radiation level

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

open/client.lua
1function OpenClient.Notify(message, type)
2    Bridge.Notify(message, type)
3end

Override to use a custom notification system.

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)