AI Core

ai-cityhall for developers

The document item metadata ai-cityhall writes (ID card, driver license), how to give a document from another script, and its private events.

ai-cityhall has no exports. Jobs taken at the job center are set with ai-core's job functions, and documents are ordinary inventory items, so another script works with them through AI Core.

Document item metadata

A document (id_card, driver_license, or any item listed under Documents) is one unique item whose metadata carries the holder. The fields are qbx_idcard's, so scripts written for Qbox read them as they are.

Prop

Type

Giving a document from another script

Using the item shows the card, whoever gave it: ai-cityhall registers every document item as usable. Give the item with the same metadata and it behaves like one bought at the counter.

Side: Server · Waits: no

Example

A police script hands a new driver license after a test:

import { inventory, notify, online } from "@aicore-fivem/lib/server";

function giveLicense(source: number): boolean {
  const c = online.character(source);
  if (!c) return false;
  const metadata = {
    name: `${c.firstname} ${c.lastname}`,
    firstname: c.firstname,
    lastname: c.lastname,
    birthdate: c.birthdate,
    sex: c.sex,
    nationality: c.nationality,
    citizenid: c.citizenid,
  };
  if (!inventory.canCarryItem(source, "driver_license", 1, metadata)) {
    notify(source, "No room in your inventory", "error");
    return false;
  }
  return inventory.addItem(source, "driver_license", 1, metadata);
}

Only items listed under Documents in the panel are registered as usable by ai-cityhall. An item that is not in that list does not show a card when used.

Money

Documents are paid with ai-core's RemoveMoney from the panel's accounts, ledger reason cityhall:<item> (for example cityhall:id_card).

Private events and callbacks

The script's own contract (resource/common/hall.ts). The server checks the distance to the hall on every call. They may change between versions: do not trigger or listen to them from other resources.

NameDirectionWhat it carries
ai-cityhall:offerclient callback(hallId): answers { ok, jobs, documents }, what this hall offers.
ai-cityhall:takeJobclient callback(hallId, job): take a job from the job center.
ai-cityhall:buyclient callback(hallId, item): buy a document.
ai-cityhall:client:showCardserver -> each player near a shown document(card): show the card on screen.
ai-cityhall:client:showingserver -> the player showing(): play the showing animation.

On this page