π qb-vehicleshop#
Test drive it before you wreck it.
Introduction#
qb-vehicleshop runs the in-world car dealership. It spawns showroom vehicles on pedestals, lets players browse the catalog, swap which vehicle is on display, take it for a timed test drive, and buy it outright with cash or bank. Purchased vehicles are written to the player_vehicles database and become retrievable through qb-garages.
Vehicles come from the shared vehicle list (exports['qb-core']:GetShared('Vehicles')), so each entry's label, price, and asset_name are sourced from qb-core rather than configured here.
Warning
Vehicle financing is not implemented. The config (Config.FinanceCommission, Config.PaymentWarning, Config.PaymentInterval, Config.MinimumDown, Config.MaximumPayments, Config.PreventFinanceSelling) and the locale strings exist as scaffolding, and a "Manage Financed Vehicles" target zone is registered, but there is no working finance/payment/repossession logic. Only test drive, swap vehicle, and cash/bank purchase actually work.
Configuration#
All configurable options listed below are found in the config.lua
Commission & General#
Commission percentages and sale-behavior toggles.
- Commission:
numberβ fraction of a full cash sale paid to a salesperson (0.10= 10%) - FinanceCommission:
numberβ scaffolded, finance is not implemented - PaymentWarning:
numberβ scaffolded (minutes before repo) - PaymentInterval:
numberβ scaffolded (hours between payments) - MinimumDown:
numberβ scaffolded (minimum down-payment percent) - MaximumPayments:
numberβ scaffolded (max number of payments) - PreventFinanceSelling:
booleanβ scaffolded - FilterByMake:
booleanβ show a make list before the category menu - SortAlphabetically:
booleanβ sort make/category/vehicle menus alphabetically - HideCategorySelectForOne:
booleanβ hide the category menu when only one category is sold
Config.Commission = 0.10
Config.FinanceCommission = 0.05
Config.PaymentWarning = 10
Config.PaymentInterval = 24
Config.MinimumDown = 10
Config.MaximumPayments = 24
Config.PreventFinanceSelling = false
Config.FilterByMake = false
Config.SortAlphabetically = true
Config.HideCategorySelectForOne = true
Shops#
Config.Shops is a table indexed by a unique shop id (the stock dealership id is 'pdm'). Each shop defines its type, the zones used for spawning and test-driving, and the showroom display vehicles.
- Type:
stringβ sale model ('free-use') - Job:
stringβ required job, or'none'for open access - TestDriveTimeLimit:
numberβ test-drive duration in minutes - ReturnLocation:
Vectorβ where a finished test drive returns to - VehicleSpawn:
tableβ where a purchased vehicle spawns (locationVector,rotationRotator) - TestDriveSpawn:
tableβ where a test-drive vehicle spawns (locationVector,rotationRotator) - FinanceZone:
Vectorβ registers a "Manage Financed Vehicles" target (finance is not implemented) - ShowroomVehicles:
tableβ the display pedestals (see below)
Config.Shops = {
['pdm'] = {
['Type'] = 'free-use',
['Job'] = 'none',
['TestDriveTimeLimit'] = 0.5,
['ReturnLocation'] = Vector(566599, 543296, 4564),
['VehicleSpawn'] = {
location = Vector(566528, 542426, 4467),
rotation = Rotator(0, -90, 0)
},
['TestDriveSpawn'] = {
location = Vector(566528, 542426, 4467),
rotation = Rotator(0, -90, 0)
},
['FinanceZone'] = Vector(567958, 543877, 4564),
['ShowroomVehicles'] = {
-- see below
},
},
}
Showroom Vehicles#
Each entry in a shop's ShowroomVehicles is a display pedestal. A static vehicle is spawned at coords on resource start, and a qb-target box zone is attached offering Test Drive, Swap Vehicle, and Purchase Vehicle. Swapping replaces chosenVehicle (the one that gets test-driven or bought) without changing defaultVehicle.
- coords:
tableβ display position (locationVector,rotationRotator) - defaultVehicle:
stringβ vehicle spawned on the pedestal at start, keyed into the sharedVehicleslist - chosenVehicle:
stringβ the currently selected vehicle (updated by Swap)
['ShowroomVehicles'] = {
{
coords = {
location = Vector(567561, 545062, 4470),
rotation = Rotator(0, 0, 0)
},
defaultVehicle = 'bp_merc',
chosenVehicle = 'bp_merc',
},
},
Tip
Purchase uses the price from the shared Vehicles entry. The server pays from cash if the player can afford it, otherwise bank; if neither covers the price the sale is rejected. On success a plate is generated, the vehicle is inserted into player_vehicles (garage 'apartments'), and a fueled vehicle spawns at the shop's VehicleSpawn.