Developer

3 min readUpdated 2 weeks ago

Overview

Other scripts integrate through the editable handler files in open/ and through exports. An error in one of the hack hooks counts as a deny. Mutating server exports are allowlist-gated: ml_* resources are allowed automatically, anything else must be added to Config.AllowedExportResources in server/config_server.lua.

Server Exports

Broadcast

  • GetActiveBroadcast(frequency): Current broadcast data for a frequency, or nil.
  • IsFrequencyBroadcasting(frequency): true while a station or autoplay is live on that frequency.
  • CanTransmitOnFrequency(src, frequency): checks the station permission of that frequency. Returns true on any frequency without a station.
  • BootstrapAutoplay(stationId): Starts a station's autoplay playlist. Allowlist-gated.
  • PauseAutoplay(stationId) / ResumeAutoplay(stationId): Suspend and resume autoplay. Allowlist-gated.

Antennas

  • GetFixedAntennas(): Table of fixed towers with their live state. Allowlist-gated, returns {} otherwise.
  • DamageFixedAntenna(id, amount): Applies damage to a fixed tower. Allowlist-gated.
  • GetJammers(): Table of active jammers. Allowlist-gated, returns {} otherwise.

Client Exports

Interface

  • OpenRadioUI() / CloseRadioUI(): Open or close the handset interface.
  • OpenStereoMenu(stereoId) / CloseStereoMenu(): Stereo control panel.
  • OpenJammerMenu(jammerId) / CloseJammerMenu(): Jammer control panel for a placed jammer.
  • GetActiveTheme(): Current interface theme name.

Signal

  • CalculateSignal(coords): signal value at those coordinates.
  • GetSignalQuality(value): Quality tier for a signal value.
  • IsSignalLost(): true while the player has no usable reception.
  • IsInsideJammer(): true inside an active jammer radius.

Broadcast Audio

  • IsBroadcastPlaying(): Whether station audio is playing locally.
  • SetBroadcastVolume(volume): Local station audio volume, from 0 to 100.
  • StopAllBroadcasts(): Stops all locally playing station audio.
  • IsInSpeakerZone(): true inside a configured speaker zone.

Battery

  • RechargeBattery(): uses one Config.Items.battery item and adds Config.Battery.chargeAmount to the held radio.

Server Handlers

Located in open/server.lua. The hack hooks run in a protected call, and an error there counts as a deny.

OnChannelJoin

open/server.lua
1function OpenServer.OnChannelJoin(src, frequency)
2end

Runs after a player joins a frequency. Its return value is ignored. To refuse a frequency, use ValidateFrequency.

OnChannelLeave

open/server.lua
1function OpenServer.OnChannelLeave(src, frequency)
2end

Notification only, fires after a player leaves a frequency.

CanHack

open/server.lua
1function OpenServer.CanHack(src, antenna, isFixed)
2    return true
3end

Authorizes an antenna hack attempt, after the distance, lockout and requireSkill checks and before the item check. Return false plus a locale key to deny with a custom message.

OnHackStart

open/server.lua
1function OpenServer.OnHackStart(src, antenna, isFixed, itemUsed)
2end

Fires when the server commits to the attempt, before the progress bar runs. Useful for attempt logs or stat counters.

OnHackSuccess

open/server.lua
1function OpenServer.OnHackSuccess(src, antenna, isFixed, itemUsed)
2end

Fires after a successful hack: the item is consumed, the lockout and hack damage are applied, and clients are updated.

Client Handler

Located in open/client.lua.

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

Runs before the handset opens. data.isPoweredOn tells whether the radio is on. Return false to keep it closed.

Shared Handler

Located in open/shared.lua and called on the server.

open/shared.lua
1function OpenHandlers.ValidateFrequency(frequency)
2    return true
3end

Runs when a player tunes the main or secondary channel. Return false to refuse that frequency.

Examples

open/server.lua
1function OpenServer.OnHackStart(src, antenna, isFixed, itemUsed)
2    exports.ml_skills:AddXp('hacking', 5, src)
3end
4
5function OpenServer.OnHackSuccess(src, antenna, isFixed, itemUsed)
6    exports.ml_skills:AddXp('hacking', 50, src)
7end
open/server.lua
1function OpenServer.CanHack(src, antenna, isFixed)
2    if not exports.ml_skills:HasUnlockedSkill(nil, 'signals_mastery_3', src) then
3        return false, 'hack_skill_missing'
4    end
5    return true
6end

The calling resource must be an ml_* resource or listed in Config.AllowedExportResources.

your_script/server.lua
1exports.ml_radio:BootstrapAutoplay('radio_station')