Rent a Car AppNewFree

Rent a Car App: Exports & Events

How the app talks to hype-rentacar, how to refresh it from other resources and the app's own exports.

v1.0.0Open sourceFreeQBox · QBCore · ESX

Resource name

Because the resource name contains hyphens, call exports as exports["hype-rentacar-app"] rather than exports.hype-rentacar-app.

How the app works

The app holds no rental state. Its server forwards every phone request to these hype-rentacar server exports, which handle prices, payments, cooldowns and validation:

hype-rentacar exportUsed for
GetCatalog()Vehicles, durations, offices, accounts and the phone rules
GetPlayerData(source)Balance, license state and active rentals
Rent(source, { model, hours, payment })Phone rental, picked up later at an office
Respawn(source, rentalId, spawnPoint)Brings a lost rental next to the player

When hype-rentacar is not running, the app shows Could not reach the Rent a Car service.

The app is registered with lb-phone's AddCustomApp, refreshed with SendCustomAppMessage and removed with RemoveCustomApp when the resource stops.

Events

hype-rentacar:client:updated

The app refreshes whenever hype-rentacar fires this client event: on rent, pickup, return, respawn and expiry. Other resources can refresh a player's app the same way:

server.lua
TriggerClientEvent("hype-rentacar:client:updated", source)

The app also refreshes when it is opened, when cash or bank changes (with a framework) and every 15 seconds on the My Rentals tab.

Client exports

GetFrameworkObject

Returns the client framework bridge, with GetFrameworkName() and OnMoneyChange(handler).

client.lua
local framework = exports["hype-rentacar-app"]:GetFrameworkObject()
print(framework.GetFrameworkName and framework.GetFrameworkName())

GetModules

Returns the client module table. With a name, only that module. The only module is Phone, the lb-phone bridge.

client.lua
local phone = exports["hype-rentacar-app"]:GetModules("Phone")
if phone.IsReady() then
    phone.SendAppMessage("hype-rentacar", { action = "refresh" })
end

Prop

Type

Phone functionPurpose
IsReady()Whether lb-phone is running
AddApp(app)Registers the app, returns added, error
RemoveApp(identifier)Removes the app from the phone
SendAppMessage(identifier, data)Sends a message to the app's UI

Bridges

The framework bridges in frameworks/ and the lb-phone bridge in modules/phone/ are not escrow protected. If you use a modified lb-phone or a custom money event, change them there.

main.lua
cl-main.lua

On this page