ai-vehiclesales for developers
How ai-vehiclesales holds listed vehicles, its tables and its internal events.
ai-vehiclesales has no exports. What other scripts need to know is how a listed vehicle looks from the outside.
Listed vehicles in ai-vehicles
A listed vehicle stays in ai-vehicles with the same id, plate, look and trunk. While it is listed:
- its owner is
{ type: "resource", id: "ai-vehiclesales" }; - its state is
"garage"with no garage (garage: null), so it shows in no garage; - the seller holds no key for it.
Buying or taking back sets the owner to the character with SetOwner and spawns it at the lot's delivery spot.
import { resourceExport } from "@aicore-fivem/lib/server";
const vehicles = resourceExport("ai-vehicles");
// Is this plate up for sale at a used car lot right now?
export function isListed(plate: string): boolean {
const vehicle = vehicles.GetVehicle(plate);
return vehicle?.owner.type === "resource" && vehicle.owner.id === "ai-vehiclesales";
}Tables
| Table | What it holds |
|---|---|
ai_vehiclesales_listings | One row per listed vehicle (unique vehicle_id): lot, seller, price, description. |
ai_vehiclesales_payouts | Money waiting for sellers who were offline when their vehicle sold. Paid out and deleted at their next login. |
Events
All of ai-vehiclesales' events are internal (its client and its server); do not call them from other scripts. Listings reach clients as a snapshot and then only changes (deltas), and only to players at the lot or with the screen open.
| Name | Kind | What it does |
|---|---|---|
ai-vehiclesales:watch / unwatch | callback / client event | Start or stop the parked-car updates when entering or leaving a lot. |
ai-vehiclesales:display | server to client | (lotId, puts, removes): parked listings changed. |
ai-vehiclesales:browse / unbrowse | callback / client event | Start or stop the screen updates. |
ai-vehiclesales:listings | server to client | (lotId, puts, removes): listings of the open screen changed. |
ai-vehiclesales:details | callback | (lotId, listingId): the description and look of one listing. |
ai-vehiclesales:list | callback | (lotId, netId, price, description): list the vehicle the player drives. |
ai-vehiclesales:quote / sellBack | callback | (lotId, netId): the dealer's price, and the dealer sale. |
ai-vehiclesales:buy / takeBack | callback | (lotId, listingId): buy, or take your own listing back. |
ai-vehiclesales:testDrive / endTestDrive | callback | Start or end a test drive. |
ai-vehiclesales:testDriveEnded | server to client | (lotId): the test drive ended; the player goes back to the lot. |