ai-garages for developers
Server exports of ai-garages and the shapes they use.
From your own script, use the lib's garages layer (server): garages.impound(vehicle, by?), garages.store(vehicle, garage?, by?), garages.open(source, garage?) and garages.stored(source). It works with whichever garage script the server runs. The exports below are what the layer calls while ai-garages is the active garage script. ai-garages cannot open its list from afar, so garages.open answers false with it.
Typed as AiGaragesServerExports in @aicore-fivem/shared (garages.ts). All three are synchronous.
import { resourceExport } from "@aicore-fivem/lib/server";
const garages = resourceExport("ai-garages");Server exports
ImpoundVehicle
Sends an owned vehicle to the impound: saves its condition (fuel, engine, body), deletes the entity and sets its state to impound. The owner gets it back at an impound lot for the fee.
Side: Server · Waits: no
ImpoundVehicle(vehicle: number): booleanlocal ok = exports['ai-garages']:ImpoundVehicle(vehicle)Parameters
Prop
Type
Returns
true when it was impounded. false when the entity does not exist or is not an owned vehicle of ai-vehicles; delete it yourself then.
Example
import { resourceExport } from "@aicore-fivem/lib/server";
const garages = resourceExport("ai-garages");
export function towAway(vehicle: number): void {
if (!garages.ImpoundVehicle(vehicle)) DeleteEntity(vehicle); // not owned: just remove it
}StoreVehicle
Parks an owned vehicle in one of the panel's garages: saves its condition, deletes the entity, sets its state to garage.
Side: Server · Waits: no
StoreVehicle(vehicle: number, garage: string): booleanlocal ok = exports['ai-garages']:StoreVehicle(vehicle, garage)Parameters
Prop
Type
Returns
true when it was stored. false for a vehicle that is not owned, a garage id that does not exist, or an impound lot.
GetStoredVehicles
The vehicles of a player's character that are not out: parked in a garage or waiting at the impound. Fleet vehicles are not included.
Side: Server · Waits: no
GetStoredVehicles(source: number): GaragedVehicle[]local list = exports['ai-garages']:GetStoredVehicles(source)Returns
An array of GaragedVehicle. Empty when the player has no loaded character.
GaragedVehicle
Prop
Type
Example
const list = garages.GetStoredVehicles(source);
const impounded = list.filter((v) => v.impounded).map((v) => v.plate);
console.log(`impounded: ${impounded.join(", ") || "none"}`);Events
ai-garages' callbacks are internal (its client to its server). Do not call them from other scripts.
| Name | Kind | What it does |
|---|---|---|
ai-garages:list | client callback | (garageId): the vehicles the player can take out there. Rated 2 per 2 seconds. |
ai-garages:takeOut | client callback | (garageId, vehicleId): spawns the vehicle at the exit point. |
ai-garages:park | client callback | (garageId, netId, props): parks the vehicle the player drives. |