AI Core

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

TableWhat it holds
ai_vehiclesales_listingsOne row per listed vehicle (unique vehicle_id): lot, seller, price, description.
ai_vehiclesales_payoutsMoney 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.

NameKindWhat it does
ai-vehiclesales:watch / unwatchcallback / client eventStart or stop the parked-car updates when entering or leaving a lot.
ai-vehiclesales:displayserver to client(lotId, puts, removes): parked listings changed.
ai-vehiclesales:browse / unbrowsecallback / client eventStart or stop the screen updates.
ai-vehiclesales:listingsserver to client(lotId, puts, removes): listings of the open screen changed.
ai-vehiclesales:detailscallback(lotId, listingId): the description and look of one listing.
ai-vehiclesales:listcallback(lotId, netId, price, description): list the vehicle the player drives.
ai-vehiclesales:quote / sellBackcallback(lotId, netId): the dealer's price, and the dealer sale.
ai-vehiclesales:buy / takeBackcallback(lotId, listingId): buy, or take your own listing back.
ai-vehiclesales:testDrive / endTestDrivecallbackStart or end a test drive.
ai-vehiclesales:testDriveEndedserver to client(lotId): the test drive ended; the player goes back to the lot.

On this page