Custom · origen_dealerships
The custom/ folder contains all integration points between origen_dealerships and the rest of your server stack. These files are not escrowed and must be adapted to your specific setup.
custom/
├── client/
│ ├── framework.lua — player identifier, vehicle props, NPC interaction
│ ├── keys.lua — vehicle key assignment on purchase
│ └── notify.lua — notifications and text UI
└── server/
├── framework.lua — admin check, payments, vehicle DB insertion
├── financing.lua — financing eligibility hook
└── plate.lua — plate generation and uniqueness checkcustom/client/framework.lua
Custom.GetPlayerIdentifier() → string
Returns the local player's unique identifier (citizenid or identifier depending on framework).
Custom.GetPlayerIdentifier = function()
local identifier = nil
if Config.Framework == 'qb-core' then
identifier = Framework.Functions.GetPlayerData().citizenid
elseif Config.Framework == 'esx' then
identifier = Framework.GetPlayerData().identifier
end
return identifier
endCustom.HandleInteraction(interactionData) → boolean
Hook called when a player attempts to interact with a dealership NPC. Return true to override the default interaction flow, false to let the resource handle it normally.
| Parameter | Type | Description |
|---|---|---|
interactionData.type | string | Interaction type. Currently: 'npc' |
interactionData.onInteract | function | Call this to trigger the default interaction from within the hook |
Custom.HandleInteraction = function(interactionData)
if interactionData.type == 'npc' then
-- interactionData.onInteract() -- uncomment to delegate back
return true -- return true to fully take over
end
return false
endNPC interaction override is disabled by default (return false). Enable it if you want to use a custom ox_lib context menu or a third-party interaction resource.
Custom.GetVehicleProps(vehicle) → table
Returns the properties of the given vehicle entity. Uses lib.getVehicleProperties when Config.VehiclePurchase.useOxLibProps is true.
| Parameter | Type | Description |
|---|---|---|
vehicle | entity | The vehicle entity handle |
Custom.GetVehicleProps = function(vehicle)
if Config.VehiclePurchase.useOxLibProps and lib and lib.getVehicleProperties then
return lib.getVehicleProperties(vehicle)
end
-- fallback: returns basic props table
endCustom.SetVehicleProps(vehicle, props) → boolean
Applies a properties table to a vehicle entity. Uses lib.setVehicleProperties when available.
| Parameter | Type | Description |
|---|---|---|
vehicle | entity | The vehicle entity handle |
props | table | Properties table (same format as GetVehicleProps) |
custom/client/keys.lua
Custom.GiveKeys(vehicle, plate) → boolean
Grants the local player ownership keys for the specified vehicle. Called automatically after purchase when Config.VehiclePurchase.giveKeysOnPurchase is true.
| Parameter | Type | Description |
|---|---|---|
vehicle | entity | nil | Vehicle entity. If nil, plate is used |
plate | string | nil | License plate. Used as fallback if entity is not available |
Custom.GiveKeys = function(vehicle, plate)
local plateToUse = plate or (DoesEntityExist(vehicle) and GetVehicleNumberPlateText(vehicle) or nil)
TriggerEvent("vehiclekeys:client:SetOwner", plateToUse)
return true
endThe default implementation fires the vehiclekeys:client:SetOwner event (compatible with qb-vehiclekeys). Replace this function if your server uses a different key system such as qs-vehiclekeys or vehicles_keys.
custom/client/notify.lua
Custom.Notify(text, type, length)
Displays a notification to the local player using lib.notify.
| Parameter | Type | Description |
|---|---|---|
text | string | Already-translated message |
type | string | Notification type: 'success', 'error', 'warning', 'info' |
length | number | Duration in milliseconds |
Custom.Notify = function(text, type, length)
lib.notify({
title = 'Origen Dealerships',
description = text,
type = type,
duration = length
})
endCustom.DrawText(text, key)
Shows the ox_lib text UI with a key hint.
| Parameter | Type | Description |
|---|---|---|
text | string | Label text |
key | string | Key label shown in brackets |
Custom.HideText()
Hides the active ox_lib text UI.
custom/server/framework.lua
Custom.isAdmin(source) → boolean
Checks whether the given player source has admin permissions according to Config.AdminGroups.
| Parameter | Type | Description |
|---|---|---|
source | number | Player server ID |
Custom.getPlayerIdentifier(source) → string | nil
Returns the player's unique identifier (citizenid for QB/QBX, identifier for ESX).
| Parameter | Type | Description |
|---|---|---|
source | number | Player server ID |
Custom.doPayment(source, paymentData) → boolean
Processes a payment from a player's account. Supports cash, bank, and xp methods.
| Parameter | Type | Description |
|---|---|---|
source | number | Player server ID |
paymentData.method | string | Payment method: 'cash', 'bank', 'xp' |
paymentData.amount | number | Amount to deduct |
Custom.doPayment = function(source, paymentData)
-- Handles cash/bank via framework, XP via exports['origen_xp']
endThe 'xp' payment method requires origen_xp to be running. It calls exports['origen_xp']:RemoveXPFromLicense(license, amount).
Custom.removeFinanceMoney(source, amount) → boolean
Deducts a financing installment payment from the player's bank account.
| Parameter | Type | Description |
|---|---|---|
source | number | Player server ID |
amount | number | Amount to deduct from bank |
Custom.addVehicleToDatabase(source, vehicleModel, plate, props, callback)
Inserts a purchased vehicle into the appropriate vehicles table for the active framework.
| Parameter | Type | Description |
|---|---|---|
source | number | Player server ID |
vehicleModel | string | Vehicle model name (spawn name) |
plate | string | License plate string |
props | table | nil | Vehicle properties. If nil, defaults are used |
callback | function(success, message) | Called after the DB insert completes |
Target tables:
| Framework | Table |
|---|---|
| QBCore / QBX | player_vehicles |
| ESX | owned_vehicles |
Custom.GetPlayerSourceByIdentifier(identifier) → number | nil
Finds an online player's server source ID by their unique identifier. Used for financing payment notifications.
| Parameter | Type | Description |
|---|---|---|
identifier | string | citizenid (QB/QBX) or identifier (ESX) |
Custom.canBuyCategory(source, categoryKey, vehicleModel) → { cant: boolean, msg: string }
Hook to add custom restrictions on vehicle category purchases. Return cant = false with a message to block the purchase.
| Parameter | Type | Description |
|---|---|---|
source | number | Player server ID |
categoryKey | string | The dealership category identifier |
vehicleModel | string | Vehicle model being purchased |
Custom.canBuyCategory = function(source, categoryKey, vehicleModel)
-- Example: block category for players without a license
return { cant = true, msg = "" }
endcustom/server/financing.lua
Custom.canFinanceVehicle(source, model, price, period) → { success: boolean, message: string }
Hook called before creating a financing contract. Return success = false with a message to block the operation.
| Parameter | Type | Description |
|---|---|---|
source | number | Player server ID |
model | string | Vehicle model |
price | number | Total vehicle price |
period | number | Requested number of payment periods |
Custom.canFinanceVehicle = function(source, model, price, period)
return { success = true, message = '' }
endcustom/server/plate.lua
Custom.GeneratePlate() → string | nil
Generates a unique 8-character license plate (4 letters + 4 digits). Retries up to 100 times to avoid collisions. Returns nil if no unique plate is found after max attempts.
Custom.PlateExists(plate) → boolean
Checks whether a given plate is already registered in the vehicles table.
| Parameter | Type | Description |
|---|---|---|
plate | string | License plate to check |
Queries player_vehicles for QBCore/QBX and owned_vehicles for ESX.