@aifivem/shared 0.0.0-stage → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/package.json +23 -4
  2. package/src/action.ts +6 -0
  3. package/src/admin/dataSpec.ts +63 -0
  4. package/src/admin/events.ts +45 -0
  5. package/src/admin/lookups.ts +29 -0
  6. package/src/admin/panel.ts +105 -0
  7. package/src/admin/schema.ts +58 -0
  8. package/src/admin/widgets.ts +123 -0
  9. package/src/appearance.ts +115 -0
  10. package/src/banking.ts +58 -0
  11. package/src/bans.ts +91 -0
  12. package/src/billing.ts +112 -0
  13. package/src/characters.ts +71 -0
  14. package/src/commands.ts +80 -0
  15. package/src/core.ts +125 -0
  16. package/src/deaths.ts +44 -0
  17. package/src/definitions.ts +26 -0
  18. package/src/dispatch.ts +103 -0
  19. package/src/doorlock.ts +29 -0
  20. package/src/ems.ts +50 -0
  21. package/src/exports/aiInventory.ts +96 -0
  22. package/src/exports/citizen.ts +45 -0
  23. package/src/exports/coreCharacters.ts +167 -0
  24. package/src/exports/coreClient.ts +79 -0
  25. package/src/exports/coreGroups.ts +29 -0
  26. package/src/exports/coreLayers.ts +45 -0
  27. package/src/exports/coreMoney.ts +97 -0
  28. package/src/exports/coreServer.ts +91 -0
  29. package/src/exports/coreServices.ts +60 -0
  30. package/src/exports/resources.ts +107 -0
  31. package/src/fuel.ts +48 -0
  32. package/src/garages.ts +101 -0
  33. package/src/index.ts +49 -0
  34. package/src/inventory/adapters.ts +86 -0
  35. package/src/inventory/exports.ts +92 -0
  36. package/src/inventory/items.ts +92 -0
  37. package/src/logs.ts +45 -0
  38. package/src/mdt.ts +78 -0
  39. package/src/medical.ts +18 -0
  40. package/src/menu.ts +94 -0
  41. package/src/minigame.ts +45 -0
  42. package/src/multichar.ts +44 -0
  43. package/src/phone.ts +39 -0
  44. package/src/player.ts +159 -0
  45. package/src/radial.ts +44 -0
  46. package/src/ui.ts +92 -0
  47. package/src/validation.ts +82 -0
  48. package/src/vehicleKeys.ts +78 -0
  49. package/src/vehicles.ts +117 -0
  50. package/src/vrp.ts +51 -0
  51. package/src/world.ts +26 -0
  52. package/README.md +0 -3
@@ -0,0 +1,29 @@
1
+ /**
2
+ * ai-core's door lock layer: lock, unlock and read a door by the door lock script's own id (ai-doorlock, tgiann-doorlock,
3
+ * ox_doorlock...). `docs/compat/doorlock.md`.
4
+ */
5
+
6
+ /** One door lock script on ai-core's server (`resource/server/doorlock/`). */
7
+ export interface DoorlockAdapter {
8
+ resource: string;
9
+ version?: string;
10
+ /** Meant to run next to ai-doorlock. */
11
+ besideOurs?: boolean;
12
+ /**
13
+ * Locks or unlocks a door; false when the script has no such door or refused. `by` is a player whose client or
14
+ * session a script needs to carry the change (scripts without a server API).
15
+ */
16
+ setLocked(id: string, locked: boolean, by: number | null): boolean;
17
+ /** Whether the door is locked; null when the script has no such door or cannot tell on the server. */
18
+ isLocked(id: string): boolean | null;
19
+ }
20
+
21
+ /** ai-core's door lock exports (lib `doors`): a door is the active script's door id (text). */
22
+ export type DoorlockServerExports = {
23
+ /** The door lock script the layer forwards to, or null. */
24
+ GetDoorlockSystem(): string | null;
25
+ /** Locks or unlocks a door; false when no door lock runs, the door is unknown or the script refused. */
26
+ SetDoorLocked(id: string, locked: boolean, by?: number): boolean;
27
+ /** Whether a door is locked; null when unknown (no door lock, no such door, the script cannot tell). */
28
+ IsDoorLocked(id: string): boolean | null;
29
+ };
package/src/ems.ts ADDED
@@ -0,0 +1,50 @@
1
+ /** A distress call of a downed player to the medics (lib `ems.distress`); texts already translated. */
2
+ export interface DistressCall {
3
+ /** Jobs whose on-duty members get it (the script's EMS jobs). */
4
+ jobs: string[];
5
+ /** One more line ("Unconscious"). */
6
+ message?: string;
7
+ }
8
+
9
+ /**
10
+ * One EMS source or sink behind ai-core's EMS layer (server side). Each part is optional: what the active adapter
11
+ * lacks, ai-core answers itself (on-duty members from its duty counts, the distress call as an alert to the jobs
12
+ * through the dispatch layer).
13
+ */
14
+ export interface EmsAdapter {
15
+ resource: string;
16
+ /** The version the adapter is written for; ai-core warns when another one runs. Absent for ai-core's own part. */
17
+ version?: string;
18
+ /** Medics free to take a call in `jobs` (a dispatch script leaves busy ones out). */
19
+ available?(jobs: readonly string[]): number;
20
+ /** Sends a distress call for the player; false when it was refused. */
21
+ distress?(source: number, call: DistressCall): boolean;
22
+ }
23
+
24
+ /** A distress call from untrusted input; null without jobs. */
25
+ export function toDistressCall(value: unknown): DistressCall | null {
26
+ if (typeof value !== "object" || value === null || Array.isArray(value))
27
+ return null;
28
+ const v = value as Record<string, unknown>;
29
+ const jobs = Array.isArray(v.jobs)
30
+ ? v.jobs
31
+ .filter((j): j is string => typeof j === "string" && j.length <= 32)
32
+ .slice(0, 10)
33
+ : [];
34
+ if (!jobs.length) return null;
35
+ const message =
36
+ typeof v.message === "string" && v.message.trim()
37
+ ? v.message.trim().slice(0, 160)
38
+ : undefined;
39
+ return { jobs, message };
40
+ }
41
+
42
+ /** ai-core's EMS exports: the medics available and distress calls, whatever EMS script runs. */
43
+ export type EmsServerExports = {
44
+ /** The EMS source the layer uses ("ai-core" for ai-core's own duty counts). */
45
+ GetEmsSystem(): string | null;
46
+ /** Medics free to take a call in `jobs`. */
47
+ GetAvailableMedics(jobs: string[]): number;
48
+ /** Sends a distress call for a player to the medics; false when nothing took it. */
49
+ SendDistress(source: number, call: DistressCall): boolean;
50
+ };
@@ -0,0 +1,96 @@
1
+ import type { ShopProduct } from "../inventory/items";
2
+
3
+ /** ai-inventory's own server exports (ai-core's inventory adapter uses them; ox / qb names are answered too). */
4
+ export type AiInventoryServerExports = {
5
+ AddItem(
6
+ inv: number | string,
7
+ item: string,
8
+ count: number,
9
+ metadata?: Record<string, unknown>,
10
+ slot?: number,
11
+ ): boolean;
12
+ RemoveItem(
13
+ inv: number | string,
14
+ item: string,
15
+ count: number,
16
+ metadata?: Record<string, unknown>,
17
+ slot?: number,
18
+ ): boolean;
19
+ GetItemCount(
20
+ inv: number | string,
21
+ item: string,
22
+ metadata?: Record<string, unknown>,
23
+ ): number;
24
+ /** Registers (or replaces) a script shop: `{ name, price }` products, paid from cash then bank. */
25
+ RegisterShop(name: string, label: string, items: ShopProduct[]): void;
26
+ /** Opens a registered script shop on the player's screen; false when it is unknown or the player has no inventory. */
27
+ OpenShop(source: number, name: string): boolean;
28
+ /** Every stack of an inventory with its item label. */
29
+ GetItems(inv: number | string): Array<{
30
+ name: string;
31
+ label: string;
32
+ count: number;
33
+ slot: number;
34
+ metadata: Record<string, unknown>;
35
+ }>;
36
+ CanCarryItem(
37
+ inv: number | string,
38
+ item: string,
39
+ count: number,
40
+ metadata?: Record<string, unknown>,
41
+ ): boolean;
42
+ /** Whether all the items fit together (summed weight, shared stack room and grid space). */
43
+ CanCarryItems(
44
+ inv: number | string,
45
+ items: Array<{ name: string; count: number; metadata?: Record<string, unknown> }>,
46
+ ): boolean;
47
+ /** `handler` returning false keeps the item (otherwise the item's "consume" amount is taken). */
48
+ RegisterUsableItem(
49
+ name: string,
50
+ handler: (
51
+ source: number,
52
+ item: {
53
+ name: string;
54
+ slot: number;
55
+ count: number;
56
+ metadata: Record<string, unknown>;
57
+ },
58
+ ) => unknown,
59
+ ): void;
60
+ RegisterStash(
61
+ name: string,
62
+ label: string,
63
+ slots: number,
64
+ maxWeight: number,
65
+ jobs?: string[],
66
+ personal?: boolean,
67
+ ): void;
68
+ OpenInventory(source: number, inv: number | string): boolean;
69
+ ClearInventory(inv: number | string): void;
70
+ /** One item definition (ox shape), or every one by name when `name` is left out. */
71
+ Items(name?: string): unknown;
72
+ /** An inventory's carried weight and limit (grams), null when it is not loaded. */
73
+ GetWeight(inv: number | string): { weight: number; maxWeight: number } | null;
74
+ /** Replaces the metadata of the stack at `slot`; false when the inventory is not loaded or the slot is empty. */
75
+ SetMetadata(
76
+ inv: number | string,
77
+ slot: number,
78
+ metadata: Record<string, unknown>,
79
+ ): boolean;
80
+ /** Sets a loaded inventory's weight limit (grams) until it loads again or the panel changes the limit. */
81
+ SetMaxWeight(inv: number | string, grams: number): boolean;
82
+ };
83
+
84
+ /** ai-inventory's own client exports (ai-core's inventory adapter uses them). */
85
+ export type AiInventoryClientExports = {
86
+ /** Opens the player's own inventory screen (with the ground / trunk / glovebox around). */
87
+ OpenSelf(): void;
88
+ HasItem(
89
+ items: string | string[] | Record<string, number>,
90
+ amount?: number,
91
+ ): boolean;
92
+ /** How many of an item the player holds. */
93
+ GetItemCount(item: string): number;
94
+ /** The player's stacks (ox_inventory's item shape plus `amount` / `info`); its totals change with `ox_inventory:itemCount`. */
95
+ GetPlayerItems(): unknown[];
96
+ };
@@ -0,0 +1,45 @@
1
+ import type { AiGaragesServerExports } from "../garages";
2
+ import type { AiLibClientExports } from "../ui";
3
+ import type { AiVehiclesServerExports } from "../vehicles";
4
+ import type {
5
+ AiInventoryClientExports,
6
+ AiInventoryServerExports,
7
+ } from "./aiInventory";
8
+ import type { AiCoreClientExports } from "./coreClient";
9
+ import type { AiCoreServerExports } from "./coreServer";
10
+ import type {
11
+ AiAppearanceClientExports,
12
+ AiDeathServerExports,
13
+ AiDoorlockServerExports,
14
+ AiHudClientExports,
15
+ AiHudServerExports,
16
+ AiPoliceAlertServerExports,
17
+ AiRadialClientExports,
18
+ AiSmallResourcesClientExports,
19
+ AiTargetClientExports,
20
+ AiVehicleKeysServerExports,
21
+ AiVehicleshopServerExports,
22
+ } from "./resources";
23
+
24
+ /** Both sides share the resource key; a caller uses the half of its own side. */
25
+ export type AiCoreExports = AiCoreServerExports & AiCoreClientExports;
26
+
27
+ declare global {
28
+ interface CitizenExports {
29
+ "ai-core": AiCoreExports;
30
+ "ai-lib": AiLibClientExports;
31
+ "ai-target": AiTargetClientExports;
32
+ "ai-appearance": AiAppearanceClientExports;
33
+ "ai-vehicles": AiVehiclesServerExports;
34
+ "ai-vehicleshop": AiVehicleshopServerExports;
35
+ "ai-vehiclekeys": AiVehicleKeysServerExports;
36
+ "ai-death": AiDeathServerExports;
37
+ "ai-radialmenu": AiRadialClientExports;
38
+ "ai-policealert": AiPoliceAlertServerExports;
39
+ "ai-doorlock": AiDoorlockServerExports;
40
+ "ai-garages": AiGaragesServerExports;
41
+ "ai-inventory": AiInventoryServerExports & AiInventoryClientExports;
42
+ "ai-smallresources": AiSmallResourcesClientExports;
43
+ "ai-hud": AiHudClientExports & AiHudServerExports;
44
+ }
45
+ }
@@ -0,0 +1,167 @@
1
+ import type {
2
+ BanEdit,
3
+ BanInfo,
4
+ BanListPage,
5
+ BanQuery,
6
+ BanRecord,
7
+ BansPage,
8
+ BanTarget,
9
+ } from "../bans";
10
+ import type {
11
+ CharacterInfoPatch,
12
+ CharacterResult,
13
+ CharacterSearchPage,
14
+ MembersPage,
15
+ OfflineCharacter,
16
+ StoredCharacter,
17
+ } from "../characters";
18
+ import type { GangDefinition, JobDefinition } from "../definitions";
19
+
20
+ /** ai-core's server exports for stored characters, bans, script job / gang definitions and player extras. */
21
+ export type CharacterServerExports = {
22
+ /** A character with money, memberships, metadata and position; loaded ones answer from memory. `done(null)`: unknown or deleted. */
23
+ GetOfflineCharacter(
24
+ charId: number,
25
+ done: (character: OfflineCharacter | null) => void,
26
+ ): void;
27
+ /**
28
+ * Characters by a typed text, loaded or not (the admin panel's rules: first / last name prefixes, "first last",
29
+ * citizenid, fivem / license / discord id), 25 a page newest first (`cursor` = the last page's `next`).
30
+ */
31
+ SearchCharacters(
32
+ text: string,
33
+ done: (page: CharacterSearchPage) => void,
34
+ cursor?: number,
35
+ ): void;
36
+ /** The characters of an account by its id or a license (`license:abc` or `abc`), by slot. */
37
+ GetCharactersOfUser(
38
+ user: number | string,
39
+ done: (characters: StoredCharacter[]) => void,
40
+ ): void;
41
+ /** Holders of a job, loaded or not, by character id (`after` = the last page's `next`; `limit` 1-500, default 100). */
42
+ GetJobMembers(
43
+ job: string,
44
+ done: (page: MembersPage) => void,
45
+ after?: number,
46
+ limit?: number,
47
+ ): void;
48
+ GetGangMembers(
49
+ gang: string,
50
+ done: (page: MembersPage) => void,
51
+ after?: number,
52
+ limit?: number,
53
+ ): void;
54
+
55
+ /** Money of a character loaded or not (a loaded one goes through its wallet). `amount` a whole number > 0. */
56
+ AddOfflineMoney(
57
+ charId: number,
58
+ account: string,
59
+ amount: number,
60
+ reason?: string,
61
+ done?: (result: CharacterResult) => void,
62
+ ): void;
63
+ /** Refused below zero (unless the account type allows it), like the live path. */
64
+ RemoveOfflineMoney(
65
+ charId: number,
66
+ account: string,
67
+ amount: number,
68
+ reason?: string,
69
+ done?: (result: CharacterResult) => void,
70
+ ): void;
71
+ SetOfflineMoney(
72
+ charId: number,
73
+ account: string,
74
+ amount: number,
75
+ reason?: string,
76
+ done?: (result: CharacterResult) => void,
77
+ ): void;
78
+ /** Adds or regrades a job (`maxJobs` / `multiJob` rules of the panel); the unemployed job is never stored. */
79
+ SetOfflineJob(
80
+ charId: number,
81
+ job: string,
82
+ grade: number,
83
+ done?: (result: CharacterResult) => void,
84
+ ): void;
85
+ RemoveOfflineJob(
86
+ charId: number,
87
+ job: string,
88
+ done?: (result: CharacterResult) => void,
89
+ ): void;
90
+ SetOfflineGang(
91
+ charId: number,
92
+ gang: string,
93
+ grade: number,
94
+ done?: (result: CharacterResult) => void,
95
+ ): void;
96
+ RemoveOfflineGang(
97
+ charId: number,
98
+ gang: string,
99
+ done?: (result: CharacterResult) => void,
100
+ ): void;
101
+ /** One metadata value (null removes the key); the value must be JSON. */
102
+ SetOfflineMeta(
103
+ charId: number,
104
+ key: string,
105
+ value: unknown,
106
+ done?: (result: CharacterResult) => void,
107
+ ): void;
108
+ /** Name, birth date, nationality, sex (sex only while not loaded: the ped model follows it). */
109
+ SetCharacterInfo(
110
+ charId: number,
111
+ patch: CharacterInfoPatch,
112
+ done?: (result: CharacterResult) => void,
113
+ ): void;
114
+ /** Soft delete (the row stays for logs); refused while the character is loaded. Fires `CORE.characterDeletedEvent`. */
115
+ DeleteCharacter(
116
+ charId: number,
117
+ by?: number | string,
118
+ done?: (result: CharacterResult) => void,
119
+ ): void;
120
+
121
+ /** Bans an online player (dropped at once) or identifiers; `minutes` left out = permanent. False on wrong arguments. */
122
+ BanPlayer(
123
+ target: BanTarget,
124
+ reason: string,
125
+ minutes?: number,
126
+ by?: number | string,
127
+ done?: (banId: number | null) => void,
128
+ ): boolean;
129
+ /** Lifts an active ban; false when no active ban has that id. */
130
+ UnbanPlayer(banId: number, by?: number | string): boolean;
131
+ IsBanned(target: BanTarget): BanInfo | null;
132
+ /** Active bans, newest first, 50 per page (page 1 first). */
133
+ GetBans(page?: number): BansPage;
134
+ /** Every ban (active, expired, revoked) matching any identifier of the target, newest first, at most 100. */
135
+ GetBanHistory(target: BanTarget, done: (bans: BanRecord[]) => void): void;
136
+ /** A page of bans by state and search (`BanQuery`); `done(null)` on a wrong query or a failed read. */
137
+ ListBans(query: BanQuery, done: (page: BanListPage | null) => void): void;
138
+ /** Changes an active ban's reason and / or end; false when no active ban has that id or the edit is wrong. */
139
+ EditBan(banId: number, edit: BanEdit, by?: number | string): boolean;
140
+
141
+ /** A job of the calling resource (gone when it stops); refused (lang key) when the panel has that job or another resource owns it. */
142
+ RegisterJobDefinition(
143
+ name: string,
144
+ definition: JobDefinition,
145
+ ): CharacterResult;
146
+ /** Removes a job the calling resource registered; false otherwise. */
147
+ RemoveJobDefinition(name: string): boolean;
148
+ RegisterGangDefinition(
149
+ name: string,
150
+ definition: GangDefinition,
151
+ ): CharacterResult;
152
+ RemoveGangDefinition(name: string): boolean;
153
+
154
+ /** Turns a loaded player's paycheck off or on (runtime, until the character unloads); false when not loaded. */
155
+ SetPaycheckEnabled(source: number, on: boolean): boolean;
156
+ IsPaycheckEnabled(source: number): boolean;
157
+ /**
158
+ * Played seconds (saved metadata `playtime` plus the running session): a server id answers at once (null when not
159
+ * loaded); `{ charId }` answers at once while loaded, else returns null and `done` gets the stored value.
160
+ */
161
+ GetPlayTime(
162
+ target: number | { charId: number },
163
+ done?: (seconds: number | null) => void,
164
+ ): number | null;
165
+ /** Saves a loaded player's position and metadata now and waits for their queued writes; `done(false)` when not loaded. */
166
+ SavePlayer(source: number, done?: (ok: boolean) => void): void;
167
+ };
@@ -0,0 +1,79 @@
1
+ import type {
2
+ CharacterAppearance,
3
+ ClothingMenu,
4
+ JobOutfit,
5
+ } from "../appearance";
6
+ import type { KeyHintRequest, KeyHintView } from "../commands";
7
+ import type { InventoryClientExports } from "../inventory/exports";
8
+ import type { ItemPickerRequest } from "../menu";
9
+ import type { AiPlayerData, Notification } from "../player";
10
+ import type { RadialClientExports } from "../radial";
11
+ import type { VehicleKeysClientExports } from "../vehicleKeys";
12
+
13
+ /** ai-core's client exports. */
14
+ export type AiCoreClientExports = {
15
+ GetPlayerData(): AiPlayerData | null;
16
+ /** The local player is down in whatever death script runs (lib `medical.isDead`, kept by `CORE.clientDeadEvent`). */
17
+ IsDead(): boolean;
18
+ IsPlayerLoaded(): boolean;
19
+ /** Hides every HUD while any reason holds (the calling resource's reasons go when it stops). */
20
+ HideHud(reason: string): void;
21
+ ShowHud(reason: string): void;
22
+ IsHudVisible(): boolean;
23
+ /** Opens the running HUD's own settings (ai-hud's /hud, tgiann-lumihud's /hud); false without one. */
24
+ OpenHudSettings(): boolean;
25
+ HasHudSettings(): boolean;
26
+ /** Opens the keys screen: a keyboard with every key that has an action, and what each does. */
27
+ OpenKeyboard(): void;
28
+ /** Pauses the weather and time sync while any reason holds (interiors, scenes). */
29
+ PauseWorldSync(reason: string): void;
30
+ ResumeWorldSync(reason: string): void;
31
+ /** Whether the weather and time sync is paused now (for a weather script that starts later). */
32
+ IsWorldSyncPaused(): boolean;
33
+ /** Job or gang definitions as the panel file holds them (bridges; follow `CORE.clientDefinitionsEvent`). */
34
+ GetDefinitions(file: "jobs" | "gangs"): Record<string, unknown> | null;
35
+ /** Opens the item picker; the list (`PickedItem[]`) or null arrives as `MENU_EVENTS.menuResult`. */
36
+ OpenItemPicker(requestId: number, request: ItemPickerRequest): void;
37
+ /** The key a lib `Keybind` was registered with (mapping command `+<name>_<key>`); null until it is registered. */
38
+ GetKeybindKey(name: string): string | null;
39
+ /** Shows a key hint of the calling resource until `HideKeyHint` (dropped when that resource stops). */
40
+ ShowKeyHint(id: string, hint: KeyHintRequest): void;
41
+ HideKeyHint(id: string): void;
42
+ /** The key hints HUDs show now (also sent as `KEY_HINTS.changedEvent`). */
43
+ GetKeyHints(): KeyHintView[];
44
+ /** The emote script answering hands up / pointing (tgiann-emotes, ai-smallresources), or null. */
45
+ GetGestureProvider(): string | null;
46
+ /** The local player has the hands up / points, in whichever emote script runs. */
47
+ IsHandsUp(): boolean;
48
+ IsPointing(): boolean;
49
+ /**
50
+ * Puts a look from `GetCharacterAppearance` on a ped through the active clothing script; false when the ped is gone,
51
+ * its model differs from the look's or no clothing script runs. On the player's own ped it changes what they wear
52
+ * (whether that is saved is the clothing script's rule).
53
+ */
54
+ ApplyAppearance(ped: number, look: CharacterAppearance): boolean;
55
+ /** The look a ped wears now (same shape as `GetCharacterAppearance`), null when the clothing script cannot tell. */
56
+ GetPedAppearance(ped: number): CharacterAppearance | null;
57
+ /** Opens the active clothing script's clothing shop, barber or saved outfits; false when it has no such menu. */
58
+ OpenClothingMenu(menu: ClothingMenu): boolean;
59
+ /** Puts a job outfit on the local player until `ReloadSkin` (not saved); false when the clothing script cannot. */
60
+ WearOutfit(outfit: JobOutfit): boolean;
61
+ /** Puts the local player's saved look back on (takes a job outfit off); false without a clothing script. */
62
+ ReloadSkin(): boolean;
63
+ /** The emote script that plays emotes by name (tgiann-emotes, rpemotes), or null. */
64
+ GetEmoteProvider(): string | null;
65
+ /** Plays an emote of the running emote script by its command name (`e <name>`); false without one. */
66
+ PlayEmote(name: string): boolean;
67
+ /** Stops the emote the local player plays; false without an emote script. */
68
+ CancelEmote(): boolean;
69
+ /** The seat belt script ai-core reads (ai-smallresources, a HUD's own belt), or null. */
70
+ GetSeatbeltProvider(): string | null;
71
+ /** Whether the local player wears a seat belt; null when no seat belt script answers or not in a car with one. */
72
+ GetSeatbelt(): boolean | null;
73
+ /** Shows an ai-lib card in the notification UI the panel picked; false when ai-lib draws it itself. */
74
+ ExternalNotify(notification: Notification): boolean;
75
+ /** Opens the active MDT for the local player (the MDT checks the job itself); false when none runs or it cannot be opened from outside. */
76
+ OpenMdt(): boolean;
77
+ } & InventoryClientExports &
78
+ VehicleKeysClientExports &
79
+ RadialClientExports;
@@ -0,0 +1,29 @@
1
+ import type { GangDefinition, JobDefinition } from "../definitions";
2
+ import type { GangMembership, JobMembership } from "../player";
3
+
4
+ /** ai-core's job and gang exports: memberships, duty, definitions (part of `AiCoreServerExports`). */
5
+ export type CoreGroupServerExports = {
6
+ GetJobs(src: number): JobMembership[] | null;
7
+ GetCurrentJob(src: number): JobMembership | null;
8
+ GetDutyJob(src: number): string | null;
9
+ SetDuty(src: number, job: string | null): boolean;
10
+ SetJob(src: number, job: string, grade: number): boolean;
11
+ RemoveJob(src: number, job: string): boolean;
12
+ GetOnDutyCount(job: string): number;
13
+ /** Whether it is prime time for `job` (the default hours without one): tgiann-policealert's hours while it runs, else ai-core's panel hours. */
14
+ IsPrimeTime(job?: string): boolean;
15
+
16
+ GetGangs(src: number): GangMembership[] | null;
17
+ GetActiveGang(src: number): string | null;
18
+ SetGang(src: number, gang: string, grade: number): boolean;
19
+ RemoveGang(src: number, gang: string): boolean;
20
+ SetActiveGang(src: number, gang: string | null): boolean;
21
+
22
+ /** Every job definition (a copy of the whole map: for rare reads; one job is `GetJobDefinition`). */
23
+ GetJobDefinitions(): Record<string, JobDefinition>;
24
+ GetGangDefinitions(): Record<string, GangDefinition>;
25
+ GetJobDefinition(job: string): JobDefinition | null;
26
+ GetGangDefinition(gang: string): GangDefinition | null;
27
+ /** The job of a character without one (the panel's `jobs.unemployed` setting). */
28
+ GetUnemployedJob(): string;
29
+ };
@@ -0,0 +1,45 @@
1
+ import type { CharacterAppearance } from "../appearance";
2
+
3
+ /** ai-core's layers over other scripts: prison, weather and time, medical, appearance, stress (part of `AiCoreServerExports`). */
4
+ export type CoreLayerServerExports = {
5
+ /** Prison layer (lib `prison`): the first running prison script answers. */
6
+ JailPlayer(source: number, minutes: number, by?: number): boolean;
7
+ ReleasePlayer(source: number): boolean;
8
+ GetJailTime(source: number): number;
9
+
10
+ /** Time and weather of whatever weather script runs (the qb-weathersync contract); null / false while none runs. */
11
+ GetWeather(): string | null;
12
+ SetWeather(type: string): boolean;
13
+ GetTime(): { hour: number; minute: number } | null;
14
+ SetTime(hour: number, minute?: number): boolean;
15
+ SetBlackout(on: boolean): boolean;
16
+ FreezeTime(on: boolean): boolean;
17
+
18
+ /** The death / ambulance script ai-core's medical layer forwards to, or null. */
19
+ GetMedicalSystem(): string | null;
20
+ /** Gets a downed player up where they lie; false when not down or no death script runs. */
21
+ RevivePlayer(source: number): boolean;
22
+ /** Full health for a player who is not down; false when no death script runs. */
23
+ HealPlayer(source: number): boolean;
24
+ IsPlayerDead(source: number): boolean;
25
+
26
+ /** The clothing script ai-core's appearance layer reads looks from (ai-appearance, tgiann-clothing), or null. */
27
+ GetAppearanceSystem(): string | null;
28
+ /**
29
+ * Reads a character's stored look (loaded or not) from the active clothing script; `done` gets it, or null when the
30
+ * character has none or no clothing script runs. A callback, not a promise: no promise crosses a resource boundary.
31
+ */
32
+ GetCharacterAppearance(
33
+ charId: number,
34
+ done: (look: CharacterAppearance | null) => void,
35
+ ): void;
36
+
37
+ /** The HUD ai-core's stress layer gives stress to (ai-hud, a QB-style HUD), or null. */
38
+ GetStressSystem(): string | null;
39
+ /** Adds stress to a player (a negative amount relieves it) through whichever HUD keeps it; false without one. */
40
+ AddStress(source: number, amount: number): boolean;
41
+ /** Fills a player's hunger and thirst through the HUD that keeps them (metadata without one); false when not loaded. */
42
+ RefillNeeds(source: number): boolean;
43
+ /** Adds hunger or thirst (0-100 scale, a negative amount takes it away) through the same HUD; false when refused. */
44
+ AddNeed(source: number, need: "hunger" | "thirst", amount: number): boolean;
45
+ };
@@ -0,0 +1,97 @@
1
+ import type { AccountTypeDefinition } from "../definitions";
2
+
3
+ /** A money account for `TransferMoney`: a loaded player's, or a job's / gang's shared account. */
4
+ export type MoneyRef =
5
+ | { source: number; account: string }
6
+ | { owner: "job" | "gang"; id: string; account: string };
7
+
8
+ /** An account whose ledger is read: a money account, or a stored character's (`id` = its character id). */
9
+ export type LedgerRef = MoneyRef | { owner: "character"; id: string; account: string };
10
+
11
+ /** One ledger row of an account. */
12
+ export interface LedgerRow {
13
+ id: number;
14
+ /** Signed: below 0 money left the account. */
15
+ amount: number;
16
+ /** The account's balance right after it. */
17
+ balance: number;
18
+ reason: string;
19
+ /** Who made it (a citizenid or a resource), null when unknown. */
20
+ actor: string | null;
21
+ /** Unix seconds. */
22
+ at: number;
23
+ }
24
+
25
+ /** Which rows: older than the row `before` (keyset), not older than `since` (unix seconds), at most `limit` (1-200, default 50). */
26
+ export interface LedgerQuery {
27
+ before?: number;
28
+ since?: number;
29
+ limit?: number;
30
+ }
31
+
32
+ /** A page of ledger rows, newest first; `next` is the `before` of the next page, null on the last. */
33
+ export interface LedgerPage {
34
+ rows: LedgerRow[];
35
+ next: number | null;
36
+ }
37
+
38
+ /** ai-core's money exports: player accounts, job and gang accounts, transfers (part of `AiCoreServerExports`). */
39
+ export type CoreMoneyServerExports = {
40
+ GetMoney(src: number, account: string): number | null;
41
+ AddMoney(
42
+ src: number,
43
+ account: string,
44
+ amount: number,
45
+ reason?: string,
46
+ ): boolean;
47
+ RemoveMoney(
48
+ src: number,
49
+ account: string,
50
+ amount: number,
51
+ reason?: string,
52
+ ): boolean;
53
+ SetMoney(
54
+ src: number,
55
+ account: string,
56
+ amount: number,
57
+ reason?: string,
58
+ ): boolean;
59
+ GetAccountTypes(): Record<string, AccountTypeDefinition>;
60
+
61
+ GetSharedMoney(
62
+ ownerType: "job" | "gang",
63
+ ownerId: string,
64
+ account: string,
65
+ ): number | null;
66
+ AddSharedMoney(
67
+ ownerType: "job" | "gang",
68
+ ownerId: string,
69
+ account: string,
70
+ amount: number,
71
+ reason?: string,
72
+ ): boolean;
73
+ RemoveSharedMoney(
74
+ ownerType: "job" | "gang",
75
+ ownerId: string,
76
+ account: string,
77
+ amount: number,
78
+ reason?: string,
79
+ ): boolean;
80
+ /**
81
+ * Moves `amount` between two accounts in one DB transaction with both ledger rows; `from` also pays `fee`.
82
+ * False when an account is missing, both are the same or `from` cannot pay.
83
+ */
84
+ /** Ledger rows of an account (ai-core writes them a moment after the change), newest first; `done` gets a page. */
85
+ GetAccountHistory(
86
+ account: LedgerRef,
87
+ done: (page: LedgerPage) => void,
88
+ query?: LedgerQuery,
89
+ ): void;
90
+ TransferMoney(
91
+ from: MoneyRef,
92
+ to: MoneyRef,
93
+ amount: number,
94
+ reason?: string,
95
+ fee?: number,
96
+ ): boolean;
97
+ };