ai-jobs for developers
What ai-jobs shares with other scripts (it has no exports): the hot dog reputation, work vehicle plates and keys, ledger reasons, and its private events.
ai-jobs has no exports. Other scripts never need to call it: routes and stops are panel data, and everything a shift does goes through AI Core (money, keys, inventory). What another script can read is listed below.
Hot dog reputation
The hot dog seller's reputation is ai-core character metadata under the key rep, field hotdog (the same place QBCore keeps PlayerData.metadata.rep). It is a whole number from 0 to the panel's Highest reputation. ai-jobs reads it when a stand is rented and writes it after each cooked hot dog, keeping the other fields of rep as they are.
Side: Server · Waits: no
GetMeta(src: number, key: "rep"): { hotdog?: number; [other: string]: unknown } | nulllocal rep = exports['ai-core']:GetMeta(source, 'rep') -- table or nilReturns
The rep table of the character, or null / nil when the player has no loaded character or never earned any reputation. hotdog is missing until the first hot dog is made.
Example
import { addCommand, notify, resourceExport } from "@aicore-fivem/lib/server";
const core = resourceExport("ai-core");
// /hotdogrep shows the player their hot dog reputation.
addCommand("hotdogrep", { help: "Show your hot dog reputation" }, (source) => {
if (source === 0) return;
const rep = core.GetMeta(source, "rep") as { hotdog?: number } | null;
notify(source, `Hot dog reputation: ${rep?.hotdog ?? 0}`, "info");
});Write the reputation only with SetMeta(source, "rep", { ...old, hotdog = value }), keeping the other fields. A rented stand keeps the value it read at rent time and writes its own value after the next hot dog, so a change made while a stand is rented is overwritten.
Work vehicles
- Spawned with the lib's
spawnVehicle, plateWORK<source>(the worker's server id), deleted when the shift ends. - The worker gets the keys through AI Core's key layer (lib
vehicleKeys.give) with purposejob, so whichever key script runs sees them. - A tow route's broken-down car spawns locked, without keys, and is deleted at the depot or when the shift ends.
Money
Route pay goes to the route's Pay account with the ledger reason work:<routeId> (for example work:taxi). Hot dog sales go to Sales paid into. Both show in ai-core's transaction history.
Private events and callbacks
These are the script's own client-server contract (resource/common/routes.ts and resource/common/hotdog.ts). The server checks every call (distance, timing, the current stop). They may change between versions: do not trigger or listen to them from other resources.
| Name | Direction | What it carries |
|---|---|---|
ai-jobs:start | client callback | (routeId): start a shift at the depot, answers { ok }. |
ai-jobs:stop | client callback | (): end the shift. |
ai-jobs:arrive | client callback | (stopId, underwater): the stop's work; the server runs the progress bar, then pays. |
ai-jobs:client:shift | server -> worker | (shift | null): the current stop, or null when the shift ended. |
ai-jobs:client:attach | server -> towed car's owner | (carNetId, flatbedNetId): attach the towed car to the flatbed. |