ktoxktox docs

Customization and API

Extension points, public hooks, framework adapters, and exports for ktx_garages.

Customization and API

The public/ Folder

The public/ folder contains extension points for server operators. These files are never escrowed - you can always edit them, even in encrypted releases.

public/server.lua

Server-side hooks you can override.

SpawnVehicle

Override how vehicles are spawned. Called every time a vehicle is created (garage display, driving out, etc.).

function PublicServer.SpawnVehicle(source, model, coords, warpInto)
    -- source: player server ID
    -- model: vehicle model name or hash
    -- coords: { x, y, z, w, vehicleType }
    -- warpInto: boolean - whether to warp the player into the vehicle
    -- Must return: vehicle entity handle or nil
end

IsPlateOwner

Override how vehicle ownership is checked. Called when verifying a player owns a specific plate.

function PublicServer.IsPlateOwner(identifier, plate)
    -- identifier: player identifier string
    -- plate: license plate string
    -- Must return: truthy value if player owns the plate
end

OnPlayerDrop

Runs when a player disconnects while inside a garage. Default behavior saves their position to the exit point so they don't spawn inside the interior on reconnect.

function PublicServer.OnPlayerDrop()
    -- source is available via `source`
end

NotifyByWebhook

Override logging behavior. Default sends Discord webhooks or uses ox_lib logger.

function PublicServer.NotifyByWebhook(source, event, description)
    -- source: player server ID (can be nil)
    -- event: event name string
    -- description: log message string
end

public/client.lua

Client-side hooks.

FormatMoney

Controls how money values are displayed to players.

function PublicClient.FormatMoney(money)
    -- money: number
    -- Must return: formatted string (e.g., "1.000.000$")
end

RemoveVehicle

Controls how vehicles are deleted on the client.

function PublicClient.RemoveVehicle(vehicle)
    -- vehicle: entity handle
end

GetVehicleData / SetVehicleData

Controls how vehicle properties are read and applied. Uses ox_lib vehicle properties by default.

function PublicClient.GetVehicleData(vehicle)
    -- Must return: vehicle properties table or nil
end

function PublicClient.SetVehicleData(vehicle, props)
    -- props: vehicle properties table from GetVehicleData
end

public/framework.lua

Template for implementing a custom framework adapter. Only used when Config.GarageSystem.framework = "custom".

Required Client Functions

return {
    getPlayerData = function()
        -- Return: { identifier, name, job = { name, label, grade } }
    end,

    onPlayerLoaded = function(cb)
        -- Call cb() when the player has fully loaded
    end,

    onJobUpdate = function(cb)
        -- Call cb(job) when the player's job changes
        -- job = { name, label, grade }
    end,

    spawnVehicle = function(model, coords, heading, cb)
        -- Spawn a vehicle, call cb(vehicleEntity)
    end,

    teleport = function(ped, coords, cb)
        -- Teleport ped to coords { x, y, z, heading? }, call cb()
    end,
}

Required Server Functions

return {
    getPlayer = function(source)
        -- Return: player wrapper (see below) or nil
    end,

    getPlayers = function()
        -- Return: array of connected source IDs
    end,

    onPlayerLoaded = function(cb)
        -- Call cb(source, wrappedPlayer) when a player loads
    end,
}

Player Wrapper Interface

The object returned by getPlayer() must implement:

MethodReturnsDescription
sourcenumberPlayer server ID (property, not method)
getIdentifier()stringUnique player identifier
getName()stringPlayer display name
getMoney()numberPlayer's cash balance
addMoney(amount)-Add cash to player
removeMoney(amount)-Remove cash from player
getJob()table{ name, label, grade }
getGroup()stringPermission group ("admin", "user", etc.)

Bridge Adapters

Framework-specific adapters live in bridge/client/ and bridge/server/. Available adapters:

  • esx.lua
  • qb-core.lua
  • qbox.lua
  • ox.lua

These files are not escrowed. You can edit them to fix framework-specific issues or adjust behavior for your server's setup.

Exports

Server-side exports for use by other resources.

-- Make a vehicle persistent (survives restarts, respawns on deletion)
exports.ktx_garages:persistVehicle(vehicleEntity, plate)

-- Stop tracking a persistent vehicle
exports.ktx_garages:unpersistVehicle(plate)

-- Check if a vehicle is currently tracked for persistence
local isTracked = exports.ktx_garages:isVehiclePersisted(plate)

Note: These exports require persistence to be active for your framework. See the Persistence Guide.