How to Build a Vehicle Dealership Script for a GTA Roleplay Server With AI
A dealership is where players spend the money your economy creates, which makes it one of the most important sinks on a roleplay server. A good one lets a player preview a car in a showroom, test drive it, see the price and stats, pay (in full or financed), and walk away owning it with a plate registered to their name then find it waiting in their garage. The fancy versions add player-owned dealerships where employees earn commission on real sales.
This guide covers the full dealership flow showroom preview, test drive, purchase, ownership, financing, and the handoff to the garage for ESX and QBCore (and QBox). PlayDeck teaches you to build this with AI: you describe the categories, prices, and whether it's self-service or staffed, then steer the AI as it writes the spawn/preview logic and the server-side purchase, and verify funds checks before you ship it on Tebex.
Decide the dealership model
There are two broad models. A self-service dealership is an automated showroom: the player walks up, browses a menu of vehicles, and buys instantly simple and always available. A player-owned (NPC or job-based) dealership puts staff in the loop: employees handle sales, run test drives, and earn commission, with the business holding a society account. Many servers run both self-service for everyday cars, player-owned for luxury sales roleplay.
Pick the model before writing anything, because it changes your data: self-service only needs a vehicle catalog and prices; player-owned needs a job, grades, commission logic, and a society account (see the job and banking guides). Decide which categories you sell (compacts, sports, off-road, motorcycles) and whether stock is unlimited or limited. When you describe this to an AI, name the model and categories up front so it scaffolds the right structure.
Build the showroom and test drive
A showroom is a spawn point where the currently selected vehicle is displayed. When a player opens the dealer menu and selects a car, you delete the previous preview and spawn the new model at the showroom coordinates with the engine off and the player locked out, then show its price and stats (top speed, acceleration, braking from GetVehicleHandlingFloat). Use ox_target or a marker on the salesperson ped to open the menu.
A test drive spawns the chosen vehicle temporarily, teleports the player in, and starts a timer; when it expires you delete the car and return the player to the showroom. Crucially, the test-drive vehicle is not owned and shouldn't persist it's a temporary entity tagged so your garage script ignores it. Describe the showroom position, the preview behavior, and the test-drive duration to your AI; it handles the spawn/delete lifecycle, and you verify temporary vehicles are cleaned up so they don't litter the server.
Handle purchase, ownership, and financing
Buying a car is a money-and-database operation, all server-side. The server checks the player can afford it, deducts the price from cash or bank (validating funds), generates a unique plate, and inserts a row into your owned-vehicles table (player_vehicles in QBCore, owned_vehicles in ESX) with the citizen/owner id, the vehicle model, the plate, and a default mods/state blob. Then it tells the garage script the player owns this vehicle so it appears when they retrieve cars.
Financing is a loan you model yourself: take a down payment, store the remaining balance and a payment schedule on the vehicle row, and on missed payments flag or repossess the car. Always generate the plate and write ownership on the server so a client can't forge a free car. When steering an AI, specify the owned-vehicles table for your framework, the plate format, and the financing terms; it writes the insert and deduction, and you confirm funds are checked before the car is granted.
Hand off to the garage and protect the economy
Ownership only matters if the player can use the car. After purchase, either spawn the vehicle once outside the dealership and mark it as out, or simply register it so the garage script (see the garage guide) lists it for retrieval. The two scripts agree on one source of truth the owned-vehicles table so a car bought here shows up in the garage, keeps its mods, and persists across relogs.
Because vehicles are a major money sink, price them to actually drain the economy: a meaningful gap between a starter car and a supercar gives players a reason to grind and keeps high earners spending. Don't pay much for selling a car back unless you want a sink to become a faucet offer only a fraction of the price on resale. You build and sell this dealership on Tebex with a Cfx.re license and escrow; you never ship leaked vehicle data or paid models you don't have the rights to.
Frequently asked questions
Where is vehicle ownership stored?
In your framework's owned-vehicles table player_vehicles on QBCore, owned_vehicles on ESX keyed by the owner's citizen/identifier, with the model, a unique plate, and a mods/state blob. The dealership inserts the row; the garage reads it.
How does a test drive not become a free car?
The test-drive vehicle is a temporary entity that's never written to the owned-vehicles table and is deleted when the timer ends. Tag it so your garage script ignores it, and it can never persist as owned.
Self-service or player-owned dealership?
Self-service is automated and simpler; player-owned adds employees, commission, and a society account for richer roleplay. Many servers run both automated for common cars, staffed for luxury sales.
How do I add financing?
Take a down payment, store the remaining balance and a payment schedule on the vehicle row, and repossess or flag the car on missed payments. Model it yourself as a loan, all validated server-side.
Can AI build the whole dealership flow?
Yes. You define the model, categories, prices, and ownership table; the AI writes the showroom spawn, test-drive lifecycle, purchase deduction, and garage handoff. You verify funds checks and cleanup exactly what PlayDeck teaches.