@aifivem/shared 0.5.0 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aifivem/shared",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Contracts shared between ai-core resources: event names, payload types, export types.",
5
5
  "license": "GPL-3.0-only",
6
6
  "repository": {
package/src/action.ts CHANGED
@@ -1,6 +1,6 @@
1
- /**
2
- * What every client action answers: ok, or a lang key the client shows. Extra fields ride on the ok branch
3
- * (`ActionResult<{ id: number }>`); the new state itself arrives as a delta, never in the reply.
4
- */
5
- export type ActionResult<T extends object = object> =
6
- ({ ok: true } & T) | { ok: false; error: string };
1
+ /**
2
+ * What every client action answers: ok, or a lang key the client shows. Extra fields ride on the ok branch
3
+ * (`ActionResult<{ id: number }>`); the new state itself arrives as a delta, never in the reply.
4
+ */
5
+ export type ActionResult<T extends object = object> =
6
+ ({ ok: true } & T) | { ok: false; error: string };
package/src/commands.ts CHANGED
@@ -1,80 +1,80 @@
1
- /**
2
- * Commands and keybinds: what every resource announces to ai-core (lib `addCommand` and `Keybind`) so the admin panel
3
- * lists them and sets keybind defaults.
4
- */
5
-
6
- export type CommandParamType = "number" | "playerId" | "string" | "longString";
7
-
8
- /** One argument of a command, parsed and checked before the handler runs. */
9
- export interface CommandParam {
10
- /** Name in the usage line, the chat suggestion and the handler's `args`. */
11
- name: string;
12
- /** number: any number; playerId: the server id of an online player; string: one word; longString: the rest of the line (last param). */
13
- type: CommandParamType;
14
- /** Lang text shown in the chat suggestion. */
15
- help?: string;
16
- optional?: boolean;
17
- }
18
-
19
- /** A command of the lib's `addCommand`, as the resource announces it to ai-core. */
20
- export interface CommandInfo {
21
- /** The first is the name, the rest are aliases. */
22
- names: string[];
23
- help: string;
24
- params: CommandParam[];
25
- /** null: everyone; otherwise the aces any of which allows it (`command.<name>` always allows too). */
26
- aces: string[] | null;
27
- }
28
-
29
- /** A keybind of the lib's `Keybind`, as the resource announces it to ai-core's client. */
30
- export interface KeybindInfo {
31
- resource: string;
32
- /** Stable id; the key mapping command is `<name>_<key>`. */
33
- name: string;
34
- /** Lang text shown in GTA's key settings. */
35
- description: string;
36
- /** The script's own default key ("" = none). */
37
- defaultKey: string;
38
- /** RegisterKeyMapping input mapper ("keyboard", "MOUSE_BUTTON", "PAD_DIGITALBUTTON"). */
39
- mapper: string;
40
- /** When HUDs list it in their key hints (the owner can change it in the panel); absent = never. */
41
- hint?: KeyHintWhen;
42
- /** Font Awesome solid icon name (without `fa-`) next to the hint. */
43
- icon?: string;
44
- /** A short text for the hint (one or two words); the description when absent. */
45
- hintLabel?: string;
46
- }
47
-
48
- /** When a key hint shows: on foot, in a vehicle, or always. */
49
- export type KeyHintWhen = "foot" | "vehicle" | "always";
50
-
51
- /** One row of the key hints HUDs show: the key as the player has it bound, and what it does (translated). */
52
- export interface KeyHintView {
53
- id: string;
54
- key: string;
55
- label: string;
56
- /** Font Awesome solid icon name without `fa-`; HUDs draw a key icon when they do not know it. */
57
- icon?: string;
58
- }
59
-
60
- /** A hint a script shows for a while (admin noclip keys): a keybind's current key, or a literal key text. */
61
- export interface KeyHintRequest {
62
- label: string;
63
- keybind?: string;
64
- key?: string;
65
- /** Font Awesome solid icon name without `fa-`. */
66
- icon?: string;
67
- }
68
-
69
- export const KEY_HINTS = {
70
- /** ai-core client -> HUDs (local): (KeyHintView[]) the hints to show now, after every change. */
71
- changedEvent: "ai-core:client:keyHints",
72
- } as const;
73
-
74
- /** Client local events between the lib's `Keybind` and ai-core's client. */
75
- export const KEYBIND = {
76
- /** lib -> ai-core: (info: KeybindInfo) a keybind waits for its default key. */
77
- announceEvent: "ai-core:client:keybind",
78
- /** ai-core -> lib: (resource, name, key) the default key to register: the panel's value, else the script's. */
79
- keyEvent: "ai-core:client:keybindKey",
80
- } as const;
1
+ /**
2
+ * Commands and keybinds: what every resource announces to ai-core (lib `addCommand` and `Keybind`) so the admin panel
3
+ * lists them and sets keybind defaults.
4
+ */
5
+
6
+ export type CommandParamType = "number" | "playerId" | "string" | "longString";
7
+
8
+ /** One argument of a command, parsed and checked before the handler runs. */
9
+ export interface CommandParam {
10
+ /** Name in the usage line, the chat suggestion and the handler's `args`. */
11
+ name: string;
12
+ /** number: any number; playerId: the server id of an online player; string: one word; longString: the rest of the line (last param). */
13
+ type: CommandParamType;
14
+ /** Lang text shown in the chat suggestion. */
15
+ help?: string;
16
+ optional?: boolean;
17
+ }
18
+
19
+ /** A command of the lib's `addCommand`, as the resource announces it to ai-core. */
20
+ export interface CommandInfo {
21
+ /** The first is the name, the rest are aliases. */
22
+ names: string[];
23
+ help: string;
24
+ params: CommandParam[];
25
+ /** null: everyone; otherwise the aces any of which allows it (`command.<name>` always allows too). */
26
+ aces: string[] | null;
27
+ }
28
+
29
+ /** A keybind of the lib's `Keybind`, as the resource announces it to ai-core's client. */
30
+ export interface KeybindInfo {
31
+ resource: string;
32
+ /** Stable id; the key mapping command is `<name>_<key>`. */
33
+ name: string;
34
+ /** Lang text shown in GTA's key settings. */
35
+ description: string;
36
+ /** The script's own default key ("" = none). */
37
+ defaultKey: string;
38
+ /** RegisterKeyMapping input mapper ("keyboard", "MOUSE_BUTTON", "PAD_DIGITALBUTTON"). */
39
+ mapper: string;
40
+ /** When HUDs list it in their key hints (the owner can change it in the panel); absent = never. */
41
+ hint?: KeyHintWhen;
42
+ /** Font Awesome solid icon name (without `fa-`) next to the hint. */
43
+ icon?: string;
44
+ /** A short text for the hint (one or two words); the description when absent. */
45
+ hintLabel?: string;
46
+ }
47
+
48
+ /** When a key hint shows: on foot, in a vehicle, or always. */
49
+ export type KeyHintWhen = "foot" | "vehicle" | "always";
50
+
51
+ /** One row of the key hints HUDs show: the key as the player has it bound, and what it does (translated). */
52
+ export interface KeyHintView {
53
+ id: string;
54
+ key: string;
55
+ label: string;
56
+ /** Font Awesome solid icon name without `fa-`; HUDs draw a key icon when they do not know it. */
57
+ icon?: string;
58
+ }
59
+
60
+ /** A hint a script shows for a while (admin noclip keys): a keybind's current key, or a literal key text. */
61
+ export interface KeyHintRequest {
62
+ label: string;
63
+ keybind?: string;
64
+ key?: string;
65
+ /** Font Awesome solid icon name without `fa-`. */
66
+ icon?: string;
67
+ }
68
+
69
+ export const KEY_HINTS = {
70
+ /** ai-core client -> HUDs (local): (KeyHintView[]) the hints to show now, after every change. */
71
+ changedEvent: "ai-core:client:keyHints",
72
+ } as const;
73
+
74
+ /** Client local events between the lib's `Keybind` and ai-core's client. */
75
+ export const KEYBIND = {
76
+ /** lib -> ai-core: (info: KeybindInfo) a keybind waits for its default key. */
77
+ announceEvent: "ai-core:client:keybind",
78
+ /** ai-core -> lib: (resource, name, key) the default key to register: the panel's value, else the script's. */
79
+ keyEvent: "ai-core:client:keybindKey",
80
+ } as const;
package/src/core.ts CHANGED
@@ -1,125 +1,125 @@
1
- /** Names owned by ai-core that other resources, the bridges and the build step use. */
2
- export const CORE = {
3
- resource: "ai-core",
4
- /** Client -> server: (resource: string, text: string). Sent by the reporter every client bundle carries. */
5
- clientErrorEvent: "ai-core:clientError",
6
-
7
- // Server local events (other resources and the bridges mirror player state from these deltas).
8
- /** (src, character: CharacterInfo) after a character is loaded and spawned. */
9
- playerLoadedEvent: "ai-core:playerLoaded",
10
- /** (src, charId) the loaded character was sent into the world (after `playerLoaded`; after the pick when the player chooses where to appear). */
11
- playerSpawnedEvent: "ai-core:playerSpawned",
12
- /** (src, charId, reason: UnloadReason) before a character's state is dropped. */
13
- playerUnloadedEvent: "ai-core:playerUnloaded",
14
- /** (src, account: string, balance: number, delta: number, reason: string) */
15
- moneyChangedEvent: "ai-core:moneyChanged",
16
- /** (src, jobs: JobMembership[]) */
17
- jobsChangedEvent: "ai-core:jobsChanged",
18
- /** (src, job: string | null) */
19
- dutyChangedEvent: "ai-core:dutyChanged",
20
- /** (src, gangs: GangMembership[]) */
21
- gangsChangedEvent: "ai-core:gangsChanged",
22
- /** (src, gang: string | null) */
23
- activeGangChangedEvent: "ai-core:activeGangChanged",
24
- /** Server local: (src, key, value | null) a character metadata value changed. */
25
- metaChangedEvent: "ai-core:metaChanged",
26
- /** Server local: (file: "jobs" | "gangs", name) a job or gang definition changed (panel edit, or a script registered / removed one). */
27
- definitionsChangedEvent: "ai-core:definitionsChanged",
28
- /** Server local: (charId, userId) a character was deleted (soft delete: character screen, admin panel, `DeleteCharacter`). */
29
- characterDeletedEvent: "ai-core:characterDeleted",
30
- /** GlobalState prefixes: `<prefix><name>` = a job / gang definition a script registered (`RegisterJobDefinition`); panel ones are not here. */
31
- runtimeJobPrefix: "ai:jobdef:",
32
- runtimeGangPrefix: "ai:gangdef:",
33
- /** (src, charIds: number[]) each time a player's character screen loads; ai-core sends the looks, a clothing script may answer with portraits. */
34
- characterScreenEvent: "ai-core:characterScreen",
35
- /** (resource: string | null) the inventory behind ai-core's inventory layer changed (the bridge drops its item cache). */
36
- inventoryChangedEvent: "ai-core:inventoryChanged",
37
- /** (src, name: string, status: Record<string, number> | null) a player used an item; status = the needs it gives, from inventories that define them. */
38
- itemUsedEvent: "ai-core:itemUsed",
39
- /** (src, killer: number | null, weaponHash: number, info: DeathInfo) a player with a loaded character died; fired from FXServer's `onPedDeath` (ai-core requires FXServer 38039+); `info` (`deaths.ts`) says who, how and from where, built on the server. */
40
- playerDiedEvent: "ai-core:playerDied",
41
-
42
- // Client local events (same payloads, for client scripts and bridges).
43
- clientPlayerLoadedEvent: "ai-core:client:playerLoaded",
44
- clientPlayerUnloadedEvent: "ai-core:client:playerUnloaded",
45
- /** (charId: number, url: string) a portrait image of a character on the character screen (e.g. `https://nui-img/<txd>/<txd>`). */
46
- clientCharacterPortraitEvent: "ai-core:client:characterPortrait",
47
- /** Server -> client (latent): (looks: { id: number, look: CharacterAppearance }[]) the character screen's looks, read through the appearance layer; ai-core dresses its scene peds with them. */
48
- characterLooksEvent: "ai-core:client:characterLooks",
49
- /** (key: keyof PlayerCache, value) a cached value of the local player changed (one watcher in ai-core for every resource). */
50
- clientCacheEvent: "ai-core:client:cache",
51
- /** Client local event: (visible: boolean) HUDs show or hide (a full-screen UI opened or closed; lib `hud`). */
52
- clientHudVisibleEvent: "ai-core:client:hudVisible",
53
- /** Client local: (paused: boolean) the weather and time sync is paused (interiors, scenes) or runs again. */
54
- clientWorldSyncEvent: "ai-core:client:worldSync",
55
- /** Client local: (file: "jobs" | "gangs", name, definition | null) a job or gang definition changed. */
56
- clientDefinitionsEvent: "ai-core:client:definitions",
57
- /** Server -> client callback: (model: string) the `CreateVehicleServerSetter` type of a model, null when the game has no such vehicle (ai-core's client answers for every resource, lib `spawnVehicle`). */
58
- vehicleTypeCallback: "ai-core:vehicleType",
59
- /** GlobalState: "prompt" | "target", how lib `Points` let players interact (ai-core panel setting). */
60
- interactionStateKey: "ai:interaction",
61
- /** GlobalState: boolean, players can hurt each other (ai-core panel setting `pvp`, `/togglepvp`). */
62
- pvpStateKey: "ai:pvp",
63
- /** GlobalState: the resource name of the death script ai-core's medical layer uses (client adapter pick). */
64
- medicalStateKey: "ai:medical",
65
- /** Client local: (dead: boolean) the local player went down (dead or last stand) or got up, in any death script. */
66
- clientDeadEvent: "ai-core:client:dead",
67
- /** GlobalState: the resource name of the MDT ai-core's MDT layer uses (client adapter pick). */
68
- mdtStateKey: "ai:mdt",
69
- /** Server -> client: (bills: { id, label, amount, sender }[]) the player's open ai-core bills (a new one arrived, or at load); the client lists them to pay. */
70
- billsEvent: "ai-core:client:bills",
71
- /** Callback: (id) -> ActionResult the player pays one of their ai-core bills. */
72
- payBillCallback: "ai-core:payBill",
73
- /** Client local: (worn: boolean | null) the local player's seat belt changed, in whichever seat belt script runs. */
74
- clientSeatbeltEvent: "ai-core:client:seatbelt",
75
- /** Server -> client: (amount: number) stress for a HUD that takes it only from its player's client (QB `hud:server:*Stress`). */
76
- stressRelayEvent: "ai-core:client:stress",
77
- /** GlobalState: the resource name of the notification UI ai-lib's notifications go to (unset = ai-lib's own cards). */
78
- notifyStateKey: "ai:notify",
79
-
80
- // Callbacks (character screen).
81
- charactersCallback: "ai-core:characters",
82
- createCharacterCallback: "ai-core:createCharacter",
83
- deleteCharacterCallback: "ai-core:deleteCharacter",
84
- selectCharacterCallback: "ai-core:selectCharacter",
85
-
86
- /** Server -> client: (spawn: SpawnPoint) puts the loaded character into the world. */
87
- spawnEvent: "ai-core:client:spawn",
88
- /** Server -> client: (options: { id, label, last }[]) the character is loaded; the player picks where to appear. */
89
- chooseSpawnEvent: "ai-core:client:chooseSpawn",
90
- /** Callback: (id) -> { ok } the picked spawn option (from `chooseSpawnEvent`); `spawnEvent` follows. */
91
- spawnChoiceCallback: "ai-core:spawnChoice",
92
- /** Server -> client: () the character was let go (switch); show the character screen again. */
93
- openCharactersEvent: "ai-core:client:openCharacters",
94
- /** GlobalState: the resource name of the external character screen (a multichar) while one runs; unset = ai-core's own screen. */
95
- characterScreenKey: "ai:characterScreen",
96
- /** Server -> client: (armour, health) the character loaded under an external character screen, which spawns the ped itself. */
97
- externalLoadedEvent: "ai-core:client:externalLoaded",
98
- /** Client -> server: () the character loaded under an external screen stands in the world (`playerSpawned` follows). */
99
- externalSpawnedEvent: "ai-core:externalSpawned",
100
- /** Server -> client: () the character was let go under an external character screen (that screen shows itself again). */
101
- externalLogoutEvent: "ai-core:client:externalLogout",
102
- } as const;
103
-
104
- /** GlobalState key holding how many players are on duty in a job (counts only, never member lists). */
105
- export const DUTY_COUNT_PREFIX = "ai:duty:";
106
- export const dutyCountKey = (job: string): string =>
107
- `${DUTY_COUNT_PREFIX}${job}`;
108
-
109
- /** GlobalState key holding the resource name of the active inventory (null while none runs). */
110
- export const INVENTORY_STATE_KEY = "ai:inventory";
111
-
112
- /** Client local event: (worn: boolean | null) the local player's seat belt changed (ai-smallresources, read by HUDs). */
113
- export const SEATBELT_EVENT = "ai-smallresources:seatbelt";
114
- /** Player state bag keys several resources read (written by one server resource each). */
115
- export const PLAYER_BAGS = {
116
- /** true while downed (ai-death). */
117
- dead: "dead",
118
- /** true while handcuffed (ai-police). */
119
- cuffed: "cuffed",
120
- /** pma-voice's voice range `{ index, distance, mode }` (ai-voice writes it). */
121
- proximity: "proximity",
122
- } as const;
123
-
124
- /** Why a character is let go: the player left, or went back to the character screen. */
125
- export type UnloadReason = "dropped" | "switch";
1
+ /** Names owned by ai-core that other resources, the bridges and the build step use. */
2
+ export const CORE = {
3
+ resource: "ai-core",
4
+ /** Client -> server: (resource: string, text: string). Sent by the reporter every client bundle carries. */
5
+ clientErrorEvent: "ai-core:clientError",
6
+
7
+ // Server local events (other resources and the bridges mirror player state from these deltas).
8
+ /** (src, character: CharacterInfo) after a character is loaded and spawned. */
9
+ playerLoadedEvent: "ai-core:playerLoaded",
10
+ /** (src, charId) the loaded character was sent into the world (after `playerLoaded`; after the pick when the player chooses where to appear). */
11
+ playerSpawnedEvent: "ai-core:playerSpawned",
12
+ /** (src, charId, reason: UnloadReason) before a character's state is dropped. */
13
+ playerUnloadedEvent: "ai-core:playerUnloaded",
14
+ /** (src, account: string, balance: number, delta: number, reason: string) */
15
+ moneyChangedEvent: "ai-core:moneyChanged",
16
+ /** (src, jobs: JobMembership[]) */
17
+ jobsChangedEvent: "ai-core:jobsChanged",
18
+ /** (src, job: string | null) */
19
+ dutyChangedEvent: "ai-core:dutyChanged",
20
+ /** (src, gangs: GangMembership[]) */
21
+ gangsChangedEvent: "ai-core:gangsChanged",
22
+ /** (src, gang: string | null) */
23
+ activeGangChangedEvent: "ai-core:activeGangChanged",
24
+ /** Server local: (src, key, value | null) a character metadata value changed. */
25
+ metaChangedEvent: "ai-core:metaChanged",
26
+ /** Server local: (file: "jobs" | "gangs", name) a job or gang definition changed (panel edit, or a script registered / removed one). */
27
+ definitionsChangedEvent: "ai-core:definitionsChanged",
28
+ /** Server local: (charId, userId) a character was deleted (soft delete: character screen, admin panel, `DeleteCharacter`). */
29
+ characterDeletedEvent: "ai-core:characterDeleted",
30
+ /** GlobalState prefixes: `<prefix><name>` = a job / gang definition a script registered (`RegisterJobDefinition`); panel ones are not here. */
31
+ runtimeJobPrefix: "ai:jobdef:",
32
+ runtimeGangPrefix: "ai:gangdef:",
33
+ /** (src, charIds: number[]) each time a player's character screen loads; ai-core sends the looks, a clothing script may answer with portraits. */
34
+ characterScreenEvent: "ai-core:characterScreen",
35
+ /** (resource: string | null) the inventory behind ai-core's inventory layer changed (the bridge drops its item cache). */
36
+ inventoryChangedEvent: "ai-core:inventoryChanged",
37
+ /** (src, name: string, status: Record<string, number> | null) a player used an item; status = the needs it gives, from inventories that define them. */
38
+ itemUsedEvent: "ai-core:itemUsed",
39
+ /** (src, killer: number | null, weaponHash: number, info: DeathInfo) a player with a loaded character died; fired from FXServer's `onPedDeath` (ai-core requires FXServer 38039+); `info` (`deaths.ts`) says who, how and from where, built on the server. */
40
+ playerDiedEvent: "ai-core:playerDied",
41
+
42
+ // Client local events (same payloads, for client scripts and bridges).
43
+ clientPlayerLoadedEvent: "ai-core:client:playerLoaded",
44
+ clientPlayerUnloadedEvent: "ai-core:client:playerUnloaded",
45
+ /** (charId: number, url: string) a portrait image of a character on the character screen (e.g. `https://nui-img/<txd>/<txd>`). */
46
+ clientCharacterPortraitEvent: "ai-core:client:characterPortrait",
47
+ /** Server -> client (latent): (looks: { id: number, look: CharacterAppearance }[]) the character screen's looks, read through the appearance layer; ai-core dresses its scene peds with them. */
48
+ characterLooksEvent: "ai-core:client:characterLooks",
49
+ /** (key: keyof PlayerCache, value) a cached value of the local player changed (one watcher in ai-core for every resource). */
50
+ clientCacheEvent: "ai-core:client:cache",
51
+ /** Client local event: (visible: boolean) HUDs show or hide (a full-screen UI opened or closed; lib `hud`). */
52
+ clientHudVisibleEvent: "ai-core:client:hudVisible",
53
+ /** Client local: (paused: boolean) the weather and time sync is paused (interiors, scenes) or runs again. */
54
+ clientWorldSyncEvent: "ai-core:client:worldSync",
55
+ /** Client local: (file: "jobs" | "gangs", name, definition | null) a job or gang definition changed. */
56
+ clientDefinitionsEvent: "ai-core:client:definitions",
57
+ /** Server -> client callback: (model: string) the `CreateVehicleServerSetter` type of a model, null when the game has no such vehicle (ai-core's client answers for every resource, lib `spawnVehicle`). */
58
+ vehicleTypeCallback: "ai-core:vehicleType",
59
+ /** GlobalState: "prompt" | "target", how lib `Points` let players interact (ai-core panel setting). */
60
+ interactionStateKey: "ai:interaction",
61
+ /** GlobalState: boolean, players can hurt each other (ai-core panel setting `pvp`, `/togglepvp`). */
62
+ pvpStateKey: "ai:pvp",
63
+ /** GlobalState: the resource name of the death script ai-core's medical layer uses (client adapter pick). */
64
+ medicalStateKey: "ai:medical",
65
+ /** Client local: (dead: boolean) the local player went down (dead or last stand) or got up, in any death script. */
66
+ clientDeadEvent: "ai-core:client:dead",
67
+ /** GlobalState: the resource name of the MDT ai-core's MDT layer uses (client adapter pick). */
68
+ mdtStateKey: "ai:mdt",
69
+ /** Server -> client: (bills: { id, label, amount, sender }[]) the player's open ai-core bills (a new one arrived, or at load); the client lists them to pay. */
70
+ billsEvent: "ai-core:client:bills",
71
+ /** Callback: (id) -> ActionResult the player pays one of their ai-core bills. */
72
+ payBillCallback: "ai-core:payBill",
73
+ /** Client local: (worn: boolean | null) the local player's seat belt changed, in whichever seat belt script runs. */
74
+ clientSeatbeltEvent: "ai-core:client:seatbelt",
75
+ /** Server -> client: (amount: number) stress for a HUD that takes it only from its player's client (QB `hud:server:*Stress`). */
76
+ stressRelayEvent: "ai-core:client:stress",
77
+ /** GlobalState: the resource name of the notification UI ai-lib's notifications go to (unset = ai-lib's own cards). */
78
+ notifyStateKey: "ai:notify",
79
+
80
+ // Callbacks (character screen).
81
+ charactersCallback: "ai-core:characters",
82
+ createCharacterCallback: "ai-core:createCharacter",
83
+ deleteCharacterCallback: "ai-core:deleteCharacter",
84
+ selectCharacterCallback: "ai-core:selectCharacter",
85
+
86
+ /** Server -> client: (spawn: SpawnPoint) puts the loaded character into the world. */
87
+ spawnEvent: "ai-core:client:spawn",
88
+ /** Server -> client: (options: { id, label, last }[]) the character is loaded; the player picks where to appear. */
89
+ chooseSpawnEvent: "ai-core:client:chooseSpawn",
90
+ /** Callback: (id) -> { ok } the picked spawn option (from `chooseSpawnEvent`); `spawnEvent` follows. */
91
+ spawnChoiceCallback: "ai-core:spawnChoice",
92
+ /** Server -> client: () the character was let go (switch); show the character screen again. */
93
+ openCharactersEvent: "ai-core:client:openCharacters",
94
+ /** GlobalState: the resource name of the external character screen (a multichar) while one runs; unset = ai-core's own screen. */
95
+ characterScreenKey: "ai:characterScreen",
96
+ /** Server -> client: (armour, health) the character loaded under an external character screen, which spawns the ped itself. */
97
+ externalLoadedEvent: "ai-core:client:externalLoaded",
98
+ /** Client -> server: () the character loaded under an external screen stands in the world (`playerSpawned` follows). */
99
+ externalSpawnedEvent: "ai-core:externalSpawned",
100
+ /** Server -> client: () the character was let go under an external character screen (that screen shows itself again). */
101
+ externalLogoutEvent: "ai-core:client:externalLogout",
102
+ } as const;
103
+
104
+ /** GlobalState key holding how many players are on duty in a job (counts only, never member lists). */
105
+ export const DUTY_COUNT_PREFIX = "ai:duty:";
106
+ export const dutyCountKey = (job: string): string =>
107
+ `${DUTY_COUNT_PREFIX}${job}`;
108
+
109
+ /** GlobalState key holding the resource name of the active inventory (null while none runs). */
110
+ export const INVENTORY_STATE_KEY = "ai:inventory";
111
+
112
+ /** Client local event: (worn: boolean | null) the local player's seat belt changed (ai-smallresources, read by HUDs). */
113
+ export const SEATBELT_EVENT = "ai-smallresources:seatbelt";
114
+ /** Player state bag keys several resources read (written by one server resource each). */
115
+ export const PLAYER_BAGS = {
116
+ /** true while downed (ai-death). */
117
+ dead: "dead",
118
+ /** true while handcuffed (ai-police). */
119
+ cuffed: "cuffed",
120
+ /** pma-voice's voice range `{ index, distance, mode }` (ai-voice writes it). */
121
+ proximity: "proximity",
122
+ } as const;
123
+
124
+ /** Why a character is let go: the player left, or went back to the character screen. */
125
+ export type UnloadReason = "dropped" | "switch";