βš™οΈframework bridge

Overview

The script uses an editable bridge system to support any framework. All framework-specific functions are located in two files:

  • modules/editable_client.lua - Client-side functions

  • modules/editable_server.lua - Server-side functions

Client-Side (ESX)

ESX = exports['es_extended']:getSharedObject()

Menu = {}
Interaction = {}
Notify = {}
Utils = {}

Utils.RequestModel = function(model, timeout)
    return lib.requestModel(model, timeout or 5000)
end

Utils.Callback = function(event, delay, cb, ...)
    lib.callback(event, delay or false, cb, ...)
end

Utils.CreateZone = function(data)
    return lib.zones.box(data)
end

Utils.CreateDUI = function(data)
    return lib.dui:new(data)
end

Utils.CreateBlip = function(data)
    local blip = AddBlipForCoord(data.coords.x, data.coords.y, data.coords.z)
    if data.sprite then SetBlipSprite(blip, data.sprite) end
    SetBlipDisplay(blip, 2)
    if data.scale then SetBlipScale(blip, data.scale) end
    if data.colour then SetBlipColour(blip, data.colour) end
    SetBlipAsShortRange(blip, true)
    if data.name then
        BeginTextCommandSetBlipName("STRING")
        AddTextComponentSubstringPlayerName(data.name)
        EndTextCommandSetBlipName(blip)
    end
    return blip
end

Notify.Success = function(title, description, duration)
    lib.notify({ title = title, description = description, type = 'success', duration = duration or 3000 })
end

Notify.Error = function(title, description, duration)
    lib.notify({ title = title, description = description, type = 'error', duration = duration or 3000 })
end

Notify.Info = function(title, description, duration)
    lib.notify({ title = title, description = description, type = 'info', duration = duration or 3000 })
end

Interaction.Target = function(coords, name, rotation, distance, debug, size, options)
    exports.ox_target:addBoxZone({
        coords = coords, size = size, name = name, rotation = rotation, debug = debug, distance = distance or 2.5, options = options
    })
end

Interaction.TargetObject = function(models, options)
    exports.ox_target:addModel(models, options)
end

Interaction.EntityTarget = function(entity, options)
    exports.ox_target:addLocalEntity(entity, options)
end

Interaction.RemoveTarget = function(name)
    exports.ox_target:removeZone(name)
end

Interaction.RemoveTargetObject = function(models)
    exports.ox_target:removeModel(models)
end

Utils.AddCarKey = function(plate, model, vehicleData)
    print(('[sl-cardealer] AddCarKey called - Plate: %s, Model: %s'):format(plate or 'N/A', model or 'N/A'))
end

Utils.RemoveCarKey = function(plate, model, vehicleData)
    print(('[sl-cardealer] RemoveCarKey called - Plate: %s, Model: %s'):format(plate or 'N/A', model or 'N/A'))
end

Server-Side (ESX)

Car Key Integration

The script provides two functions for vehicle key management that you can customize for your key system.

Available Key Systems

Function Reference

Client Functions

Function
Parameters
Description

Utils.RequestModel

model, timeout

Load vehicle model

Utils.Callback

event, delay, cb, ...

Trigger server callback

Utils.CreateZone

data

Create ox_lib zone

Utils.CreateDUI

data

Create DUI instance

Utils.CreateBlip

data

Create map blip

Utils.AddCarKey

plate, model, vehicleData

Give car key to player

Utils.RemoveCarKey

plate, model, vehicleData

Remove car key from player

Notify.Success

title, desc, duration

Show success notification

Notify.Error

title, desc, duration

Show error notification

Notify.Info

title, desc, duration

Show info notification

Interaction.Target

coords, name, ...

Add target zone

Interaction.RemoveTarget

name

Remove target zone

Interaction.EntityTarget

entity, options

Add entity target

Interaction.TargetObject

models, options

Add model target

Interaction.RemoveTargetObject

models

Remove model target

Server Functions

Function
Parameters
Returns
Description

Callback.Register

name, cb

-

Register server callback

HasEnoughMoney

source, amount

boolean

Check if player has money

RemoveMoney

source, amount, reason

boolean

Remove money from player

CheckMoneyForPurchase

source, amount

table

Check cash and bank

RemoveMoneyForPurchase

source, amount, reason

boolean, string

Remove from cash or bank

AddMoney

source, amount, reason

boolean

Add money to player

GiveVehicleToPlayer

source, vehicleData, plate

boolean

Save vehicle to database

CheckIfPlateExists

plate

boolean

Check if plate exists

GeneratePlate

-

string

Generate unique plate