Features
My Vehicles (fx-garageapp)
The bundled garage app with valet, remote key, mileage and insurance, how it installs into the phone, its main settings and its exports.
#What it is
fx-garageapp is the phone app for your garage script. It lists the player's vehicles, where they are and their state. A valet takes a stored vehicle from a nearby road and drives it to the player.
Extras:
- Remote key. A vehicle that is out and within range can be locked, unlocked, located (horn, lights and a flashing map marker) and have its engine started or stopped from the phone. Ownership and distance are checked on the server.
- Give keys. Hands the vehicle's keys to a nearby player through your key script.
- Mileage. Counted while the owner drives the vehicle.
- Insurance. A policy per vehicle, paid from the bank, with a valet discount or a free valet.
The app also runs without a phone as a tablet, opened with a command.
#Requirements
| Resource | Required |
|---|---|
ox_lib |
Yes |
oxmysql |
Yes |
| A garage script | Yes: fx-garages, a QBCore/Qbox player_vehicles garage, an ESX owned_vehicles garage, or your own through bridge/garages/custom.lua |
fx-phone |
No. Without a phone the app opens as a tablet |
#Installation
Start it after ox_lib, oxmysql, your garage script and the phone:
cfgensure fx-phone
ensure fx-garageapp
The app uses the garage script's tables. Its own table for mileage and insurance, fx_garageapp_vehicles, is created on first start.
With Config.Garage.System = 'qb' or 'esx', write the garage and impound locations shown on the map into Config.Garage.Locations and Config.Garage.Impounds.
#How it registers into the phone
With Config.Phone.Resource = 'auto' the first started phone is used: fx-phone, then lb-phone, then cylex_phone.
The FX Phone adapter (client/phone/fxphone.lua) calls exports['fx-phone']:AddCustomApp with identifier = Config.Phone.AppIdentifier (default fx_garage), name, description, developer, defaultApp, size, ui and icon from Config.Phone. Messages to the page go through SendCustomAppMessage.
To keep the app from starting at all, set ['fx-garageapp'] = false in Config.BundledApps. See Apps.
#Config highlights
| Setting | Meaning |
|---|---|
Config.Locale |
tr or en |
Config.Garage.System |
auto, fx-garages, qb, esx or custom |
Config.Garage.ShowUnregistered |
fx-garages only: list vehicles the framework says the player owns but fx-garages has not taken in yet, read only |
Config.Garage.Locations, Impounds, Labels, VehicleTypes |
For qb / esx: garage positions, impound lots, display names and model types |
Config.Phone |
Phone choice, AppIdentifier, AppName, Title, Description, Icon, DefaultApp |
Config.Standalone |
Tablet mode: Enabled, Command (default araclarim), Key, AllowWithPhone |
Config.Valet.Price |
Service fee; 0 is free |
Config.Valet.Payment |
Whether cash and bank are accepted |
Config.Valet.Types |
Vehicle types a valet may bring |
Config.Valet.SpawnDistance |
How far from the player the vehicle appears on a road (Min, Max) |
Config.Valet.InstantDelivery |
true places the vehicle next to the player with no drive |
Config.Valet.DriveSpeed, DrivingStyle, StuckSeconds, MaxDriveSeconds |
How the valet drives and when a stuck vehicle is moved |
Config.Valet.CheckFines, CheckBilling |
Unpaid vehicle fines or invoices block the valet |
Config.Billing |
Invoice lock: Resource (auto uses fx-billingapp when it runs), Export, MinUnpaidTotal |
Config.Keys.Resource |
Key script; auto detects qb-vehiclekeys, qbx_vehiclekeys, wasabi_carlock, qs-vehiclekeys and MrNewbVehicleKeys |
Config.Extras |
Remote (enabled, range), ShareKeys, Odometer, Insurance plans |
Config.Map3D |
Reports the valet and "find my car" to fx-3dmap when it runs |
The garage connection is in bridge/garage.lua and one adapter per system in bridge/garages/. Those files are not encrypted.
#How the valet stays consistent with the garage
- Ownership, model and plate are verified from the garage script's record.
- The state change from "in garage" to "out" is written conditionally, so two people cannot take the same vehicle out at once.
- The vehicle is created with the plate on record, and the plate is verified on the server.
- If the valet fails on the way, the vehicle is deleted and written back to the garage. On a technical failure the fee is refunded.
#Exports
| Export | Side | Purpose |
|---|---|---|
OpenApp() |
Client | Opens the app as a tablet |
CloseApp() |
Client | Closes the tablet |
GetMileage(plate) |
Server | Returns the vehicle's mileage in whole kilometres |
GetInsurance(plate) |
Server | Returns the active policy { plan, untilAt }, or nil |
HasUnpaidInvoices(identifier, notify) |
Server | Returns true when the billing lock blocks this player, using the resource set in Config.Billing |
lualocal km = exports['fx-garageapp']:GetMileage(plate)
local policy = exports['fx-garageapp']:GetInsurance(plate)