Koja Scripts
NEW

Exports & Commands

Everything here is client-side unless it says otherwise.

Exports & Commands

Everything here is client-side unless it says otherwise. The export namespace is the resource folder name, koja_hud.

Commands

The resource registers one command, and its name comes from KOJA.SettingsCommand in editable/shared/config.lua:

KOJA.SettingsCommand = 'settings'

/settings opens the player's own settings menu. Rename it there if it clashes with something else on your server.

Notifications

exports['koja_hud']:sendNotify({
    type  = 'success',
    icon  = 'fa-solid fa-check',
    color = '#B1FEA1',
    title = 'Saved',
    desc  = 'Your vehicle is in the garage.',
    time  = 5000,
})

Every field is passed straight through to the interface. Leave one out and the HUD falls back to its own default for it.

Progress bar

exports['koja_hud']:startProgressbar({
    label     = 'Repairing…',
    time      = 5,
    animation = { dict = 'mini@repair', name = 'fixing_a_ped' },
    inputBlock = { keys = { 'W', 'A', 'S', 'D', 'SPACE' } },
}, function(finished)
    if finished then
        -- it ran to the end
    end
end)
FieldMeaning
timeSeconds. The animation is played for the same length.
animationOptional dict and name. The dictionary is requested and loaded before the bar starts.
inputBlock.keysKey names to disable while the bar runs — W, SPACE, LEFTSHIFT and so on.

The callback receives whether the bar finished rather than being cancelled.

exports['koja_hud']:cancelProgressbar()

Text UI

exports['koja_hud']:TextUI({ ... })
exports['koja_hud']:HideUI()

Both are also reachable as server-triggerable events, which is what you want when the decision to show something is made server-side:

TriggerClientEvent('koja_hud:startTextUI', source, { ... })
TriggerClientEvent('koja_hud:cancelTextUI', source)

Hiding the HUD

exports['koja_hud']:ToggleHUD(false)  -- during a cutscene
exports['koja_hud']:ToggleHUD(true)

Stress

local stress = exports['koja_hud']:GetStress()

Stress is moved with events rather than exports:

TriggerEvent('koja-hud:addStress', 5)
TriggerEvent('koja-hud:removeStress', 5)

Seatbelt

if not exports['koja_hud']:IsSeatbeltOn() then
    -- they are not belted in
end

exports['koja_hud']:SeatbeltState(true)

SeatbeltState sets the flag the HUD reads. Use it when another resource owns the seatbelt and this one only has to display it.

Nitro

exports['koja_hud']:SetNitro()
local nitro = exports['koja_hud']:GetNitro()

Persisting it goes the other way — these are server events, triggered from the client:

TriggerServerEvent('koja_hud:setVehicleNitro', GetVehicleNumberPlateText(veh), 100)
TriggerServerEvent('koja_hud:removeNitroItem')

setVehicleNitro takes the plate and the value and writes it to your vehicles table. removeNitroItem takes nothing and removes one KOJA.Nitro.Item from whoever triggered it.

Nitro is the one thing the HUD persists — see Database.

The full list

ExportReturns
sendNotify(data)
startProgressbar(data, cb)calls back with whether it finished
cancelProgressbar()
TextUI(data)
HideUI()
ToggleHUD(visible)
GetStress()the player's stress
IsSeatbeltOn()true / false
SeatbeltState(state)
SetNitro()
GetNitro()the current vehicle's nitro
  • Installation — Read the entire installation process to ensure the resource is fully usable.
  • Configuration — Changing Language, Debug Prints, Settings Command, Hide Minimap, Notifications, Nitro, Engine, Seatbelt and Cruisemode.
  • Guides — Creating/Editing Locales, Progress Bar, Text UI and Stress.
  • Features
  • Database
  • HUD — back to the section overview