@aifivem/shared 0.6.0 → 0.8.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.6.0",
3
+ "version": "0.8.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/characters.ts CHANGED
@@ -68,4 +68,20 @@ export interface CharacterInfoPatch {
68
68
  birthdate?: string;
69
69
  nationality?: string;
70
70
  sex?: "male" | "female";
71
+ /** QB's numbering of the sex (0 male, 1 female); `sex` wins when both are given. */
72
+ gender?: 0 | 1;
73
+ /** Centimetres, a whole number 0-300 (0 = not set), kept in metadata `height`. */
74
+ height?: number;
71
75
  }
76
+
77
+ /** A character `IsIllegal` / `SetIllegal` name: a loaded player's server id, a citizenid, or a character id. */
78
+ export type CharacterTarget = number | string | { charId: number };
79
+
80
+ /** ai-core's panel `paycheck.mode`: salary straight into the pay account, or kept in the paycheck office until withdrawn. */
81
+ export type PaycheckMode = "account" | "office";
82
+
83
+ /** `WithdrawPaycheck`'s answer: the amount paid out and what stays in the paycheck office, or a lang key. */
84
+ export type PaycheckWithdrawal = ActionResult<{
85
+ amount: number;
86
+ balance: number;
87
+ }>;
package/src/core.ts CHANGED
@@ -27,6 +27,10 @@ export const CORE = {
27
27
  definitionsChangedEvent: "ai-core:definitionsChanged",
28
28
  /** Server local: (charId, userId) a character was deleted (soft delete: character screen, admin panel, `DeleteCharacter`). */
29
29
  characterDeletedEvent: "ai-core:characterDeleted",
30
+ /** Server local: (charId, illegal: boolean, src | null) a character's legal / illegal status changed (`SetIllegal`); `src` while loaded. */
31
+ illegalChangedEvent: "ai-core:illegalChanged",
32
+ /** Server local: (kind: "added" | "cleared", warrant: Warrant, by: src | null) one of ai-core's own warrants was issued or cleared (`by`: the issuer's or clearer's server id). */
33
+ warrantChangedEvent: "ai-core:warrantChanged",
30
34
  /** GlobalState prefixes: `<prefix><name>` = a job / gang definition a script registered (`RegisterJobDefinition`); panel ones are not here. */
31
35
  runtimeJobPrefix: "ai:jobdef:",
32
36
  runtimeGangPrefix: "ai:gangdef:",
@@ -58,6 +62,8 @@ export const CORE = {
58
62
  vehicleTypeCallback: "ai-core:vehicleType",
59
63
  /** GlobalState: "prompt" | "target", how lib `Points` let players interact (ai-core panel setting). */
60
64
  interactionStateKey: "ai:interaction",
65
+ /** GlobalState: "account" | "office", ai-core's panel `paycheck.mode` (`PaycheckMode`; server scripts read `GetPaycheckMode`). */
66
+ paycheckModeStateKey: "ai:paycheckMode",
61
67
  /** GlobalState: boolean, players can hurt each other (ai-core panel setting `pvp`, `/togglepvp`). */
62
68
  pvpStateKey: "ai:pvp",
63
69
  /** GlobalState: the resource name of the death script ai-core's medical layer uses (client adapter pick). */
@@ -76,6 +82,14 @@ export const CORE = {
76
82
  stressRelayEvent: "ai-core:client:stress",
77
83
  /** GlobalState: the resource name of the notification UI ai-lib's notifications go to (unset = ai-lib's own cards). */
78
84
  notifyStateKey: "ai:notify",
85
+ /** GlobalState: the resource name of the phone ai-core's phone layer uses (client adapter pick). */
86
+ phoneStateKey: "ai:phone",
87
+ /** Client local: (phone: string) the local player opened the phone (resource name of the active phone); once per opening, at most once per 10 s. */
88
+ clientPhoneUsedEvent: "ai-core:client:phoneUsed",
89
+ /** Client -> server: () the player opened the phone (sent with `clientPhoneUsedEvent`; the server checks and fires `phoneUsedEvent`). */
90
+ phoneOpenedEvent: "ai-core:phoneOpened",
91
+ /** Server local: (src, phone: string) a player with a loaded character opened the phone (resource name of the active phone); at most once per 10 s per player. */
92
+ phoneUsedEvent: "ai-core:phoneUsed",
79
93
 
80
94
  // Callbacks (character screen).
81
95
  charactersCallback: "ai-core:characters",
@@ -14,8 +14,10 @@ import type {
14
14
  AiHudClientExports,
15
15
  AiHudServerExports,
16
16
  AiPoliceAlertServerExports,
17
+ AiPoliceServerExports,
17
18
  AiRadialClientExports,
18
19
  AiSmallResourcesClientExports,
20
+ AiSmallResourcesServerExports,
19
21
  AiTargetClientExports,
20
22
  AiVehicleKeysServerExports,
21
23
  AiVehicleshopServerExports,
@@ -35,11 +37,13 @@ declare global {
35
37
  "ai-vehiclekeys": AiVehicleKeysServerExports;
36
38
  "ai-death": AiDeathServerExports;
37
39
  "ai-radialmenu": AiRadialClientExports;
40
+ "ai-police": AiPoliceServerExports;
38
41
  "ai-policealert": AiPoliceAlertServerExports;
39
42
  "ai-doorlock": AiDoorlockServerExports;
40
43
  "ai-garages": AiGaragesServerExports;
41
44
  "ai-inventory": AiInventoryServerExports & AiInventoryClientExports;
42
- "ai-smallresources": AiSmallResourcesClientExports;
45
+ "ai-smallresources": AiSmallResourcesClientExports &
46
+ AiSmallResourcesServerExports;
43
47
  "ai-hud": AiHudClientExports & AiHudServerExports;
44
48
  }
45
49
  }
@@ -0,0 +1,32 @@
1
+ import type {
2
+ BanEdit,
3
+ BanInfo,
4
+ BanListPage,
5
+ BanQuery,
6
+ BanRecord,
7
+ BansPage,
8
+ BanTarget,
9
+ } from "../bans";
10
+
11
+ /** ai-core's server exports for bans (checked when a player connects). */
12
+ export type BanServerExports = {
13
+ /** Bans an online player (dropped at once) or identifiers; `minutes` left out = permanent. False on wrong arguments. */
14
+ BanPlayer(
15
+ target: BanTarget,
16
+ reason: string,
17
+ minutes?: number,
18
+ by?: number | string,
19
+ done?: (banId: number | null) => void,
20
+ ): boolean;
21
+ /** Lifts an active ban; false when no active ban has that id. */
22
+ UnbanPlayer(banId: number, by?: number | string): boolean;
23
+ IsBanned(target: BanTarget): BanInfo | null;
24
+ /** Active bans, newest first, 50 per page (page 1 first). */
25
+ GetBans(page?: number): BansPage;
26
+ /** Every ban (active, expired, revoked) matching any identifier of the target, newest first, at most 100. */
27
+ GetBanHistory(target: BanTarget, done: (bans: BanRecord[]) => void): void;
28
+ /** A page of bans by state and search (`BanQuery`); `done(null)` on a wrong query or a failed read. */
29
+ ListBans(query: BanQuery, done: (page: BanListPage | null) => void): void;
30
+ /** Changes an active ban's reason and / or end; false when no active ban has that id or the edit is wrong. */
31
+ EditBan(banId: number, edit: BanEdit, by?: number | string): boolean;
32
+ };
@@ -1,23 +1,17 @@
1
- import type {
2
- BanEdit,
3
- BanInfo,
4
- BanListPage,
5
- BanQuery,
6
- BanRecord,
7
- BansPage,
8
- BanTarget,
9
- } from "../bans";
10
1
  import type {
11
2
  CharacterInfoPatch,
12
3
  CharacterResult,
13
4
  CharacterSearchPage,
5
+ CharacterTarget,
14
6
  MembersPage,
7
+ PaycheckMode,
8
+ PaycheckWithdrawal,
15
9
  OfflineCharacter,
16
10
  StoredCharacter,
17
11
  } from "../characters";
18
12
  import type { GangDefinition, JobDefinition } from "../definitions";
19
13
 
20
- /** ai-core's server exports for stored characters, bans, script job / gang definitions and player extras. */
14
+ /** ai-core's server exports for stored characters, script job / gang definitions and player extras. */
21
15
  export type CharacterServerExports = {
22
16
  /** A character with money, memberships, metadata and position; loaded ones answer from memory. `done(null)`: unknown or deleted. */
23
17
  GetOfflineCharacter(
@@ -33,6 +27,14 @@ export type CharacterServerExports = {
33
27
  done: (page: CharacterSearchPage) => void,
34
28
  cursor?: number,
35
29
  ): void;
30
+ /**
31
+ * The character id of a citizenid, loaded or not (a loaded one from memory, a stored one by the unique `citizenid`
32
+ * key). `done(null)`: unknown or deleted.
33
+ */
34
+ GetCharIdByCitizenId(
35
+ citizenid: string,
36
+ done: (charId: number | null) => void,
37
+ ): void;
36
38
  /** The characters of an account by its id or a license (`license:abc` or `abc`), by slot. */
37
39
  GetCharactersOfUser(
38
40
  user: number | string,
@@ -105,7 +107,10 @@ export type CharacterServerExports = {
105
107
  value: unknown,
106
108
  done?: (result: CharacterResult) => void,
107
109
  ): void;
108
- /** Name, birth date, nationality, sex (sex only while not loaded: the ped model follows it). */
110
+ /**
111
+ * Name, birth date, nationality, sex / gender (sex only while not loaded: the ped model follows it) and height
112
+ * (metadata `height`); a loaded character gets the change as a delta.
113
+ */
109
114
  SetCharacterInfo(
110
115
  charId: number,
111
116
  patch: CharacterInfoPatch,
@@ -118,26 +123,6 @@ export type CharacterServerExports = {
118
123
  done?: (result: CharacterResult) => void,
119
124
  ): void;
120
125
 
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
126
  /** 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
127
  RegisterJobDefinition(
143
128
  name: string,
@@ -154,6 +139,30 @@ export type CharacterServerExports = {
154
139
  /** Turns a loaded player's paycheck off or on (runtime, until the character unloads); false when not loaded. */
155
140
  SetPaycheckEnabled(source: number, on: boolean): boolean;
156
141
  IsPaycheckEnabled(source: number): boolean;
142
+ /** The panel's `paycheck.mode`; clients follow GlobalState `CORE.paycheckModeStateKey`. */
143
+ GetPaycheckMode(): PaycheckMode;
144
+ /** Salary waiting in the paycheck office (metadata `paycheck`, panel `paycheck.mode` "office"); 0 when not loaded. */
145
+ GetPaycheckBalance(source: number): number;
146
+ /** Pays the office's salary into the pay account (`amount` left out = all of it); refusals are lang keys. */
147
+ WithdrawPaycheck(source: number, amount?: number): PaycheckWithdrawal;
148
+ /** Runs the paycheck for one loaded player now (same rules as the timer); false when not loaded. */
149
+ ForcePaycheck(source: number): boolean;
150
+
151
+ /**
152
+ * Legal / illegal status of a character (metadata `illegal`): a server id (false when not loaded) or a loaded
153
+ * character answers at once; otherwise it returns null and `done` gets the stored value (null: unknown character).
154
+ * `done` always gets the answer. Always false while the panel's `illegal.enabled` is off.
155
+ */
156
+ IsIllegal(
157
+ target: CharacterTarget,
158
+ done?: (illegal: boolean | null) => void,
159
+ ): boolean | null;
160
+ /** Marks a character illegal or legal, loaded or not; fires `CORE.illegalChangedEvent`. Refused while the feature is off. */
161
+ SetIllegal(
162
+ target: CharacterTarget,
163
+ illegal: boolean,
164
+ done?: (result: CharacterResult) => void,
165
+ ): void;
157
166
  /**
158
167
  * Played seconds (saved metadata `playtime` plus the running session): a server id answers at once (null when not
159
168
  * loaded); `{ charId }` answers at once while loaded, else returns null and `done` gets the stored value.
@@ -38,8 +38,10 @@ export type CoreLayerServerExports = {
38
38
  GetStressSystem(): string | null;
39
39
  /** Adds stress to a player (a negative amount relieves it) through whichever HUD keeps it; false without one. */
40
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. */
41
+ /** Fills a loaded player's hunger and thirst (ai-core keeps them in metadata, any HUD draws them); false when not loaded. */
42
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. */
43
+ /** Adds hunger or thirst (0-100 scale, a negative amount takes it away); false when refused. */
44
44
  AddNeed(source: number, need: "hunger" | "thirst", amount: number): boolean;
45
+ /** Sets hunger or thirst to `value` (0-100, clamped); false when refused. */
46
+ SetNeed(source: number, need: "hunger" | "thirst", value: number): boolean;
45
47
  };
@@ -1,5 +1,6 @@
1
1
  import type { BankingServerExports } from "../banking";
2
2
  import type { BillingServerExports } from "../billing";
3
+ import type { BanServerExports } from "./coreBans";
3
4
  import type { CharacterServerExports } from "./coreCharacters";
4
5
  import type { DispatchServerExports } from "../dispatch";
5
6
  import type { DoorlockServerExports } from "../doorlock";
@@ -8,6 +9,7 @@ import type { FuelServerExports } from "../fuel";
8
9
  import type { GaragesServerExports } from "../garages";
9
10
  import type { InventoryServerExports } from "../inventory/exports";
10
11
  import type { MdtServerExports } from "../mdt";
12
+ import type { WarrantServerExports } from "../warrants";
11
13
  import type { MulticharServerExports } from "../multichar";
12
14
  import type { PhoneServerExports } from "../phone";
13
15
  import type { AiPlayerData, CharacterInfo } from "../player";
@@ -83,9 +85,11 @@ export type AiCoreServerExports = {
83
85
  BillingServerExports &
84
86
  BankingServerExports &
85
87
  MdtServerExports &
88
+ WarrantServerExports &
86
89
  EmsServerExports &
87
90
  FuelServerExports &
88
91
  DoorlockServerExports &
89
92
  GaragesServerExports &
90
93
  CharacterServerExports &
94
+ BanServerExports &
91
95
  MulticharServerExports;
@@ -65,6 +65,15 @@ export type AiPoliceAlertServerExports = {
65
65
  DispatchAlert(alert: DispatchAlert): void;
66
66
  };
67
67
 
68
+ /** ai-police's server exports (optional: callers use `optionalExport("ai-police")`). */
69
+ export type AiPoliceServerExports = {
70
+ /**
71
+ * A place saw the player (`"atm"`, `"bank"`, `"shop"`, `"clothing"`, `"garage"`, `"phone"`, any other name uses the
72
+ * panel's default chance): with an active warrant the police may get a "wanted suspect seen" alert.
73
+ */
74
+ ReportSighting(source: number, place: string): void;
75
+ };
76
+
68
77
  /** ai-doorlock's server exports (doors by panel id). */
69
78
  export type AiDoorlockServerExports = {
70
79
  SetDoorState(id: string, locked: boolean): void;
@@ -77,6 +86,13 @@ export type AiSmallResourcesClientExports = {
77
86
  GetSeatbelt(): boolean | null;
78
87
  };
79
88
 
89
+ /** ai-smallresources' server exports: ambient pedestrians and traffic off for everyone (ai-admin's `npc`). */
90
+ export type AiSmallResourcesServerExports = {
91
+ /** false on a wrong argument. */
92
+ SetNpcDisabled(on: boolean): boolean;
93
+ IsNpcDisabled(): boolean;
94
+ };
95
+
80
96
  /** ai-hud's client exports (ai-core opens its settings; ai-admin's minimap toggle). */
81
97
  export type AiHudClientExports = {
82
98
  OpenSettings(): void;
@@ -84,20 +100,10 @@ export type AiHudClientExports = {
84
100
  GetMinimapAlways(): boolean;
85
101
  };
86
102
 
87
- /** ai-hud's server exports (ai-core's stress layer adds stress through `AddNeed`). */
103
+ /** ai-hud's server exports (ai-core's stress layer asks how fast stress fades while ai-hud keeps it). */
88
104
  export type AiHudServerExports = {
89
- /** Adds `delta` to a loaded player's need (0-100, clamped). */
90
- AddNeed(
91
- source: number,
92
- need: "hunger" | "thirst" | "stress",
93
- delta: number,
94
- ): void;
95
- /** Sets a loaded player's need to `value` (0-100, clamped). */
96
- SetNeed(
97
- source: number,
98
- need: "hunger" | "thirst" | "stress",
99
- value: number,
100
- ): void;
105
+ /** Stress points that fade per minute (ai-hud's panel). */
106
+ GetStressRelief(): number;
101
107
  };
102
108
 
103
109
  /** ai-vehicleshop's server exports. */
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ export type * from "./exports/coreGroups";
10
10
  export type * from "./exports/coreServices";
11
11
  export type * from "./exports/coreLayers";
12
12
  export * from "./exports/coreCharacters";
13
+ export type * from "./exports/coreBans";
13
14
  export type * from "./exports/coreClient";
14
15
  export type * from "./exports/aiInventory";
15
16
  export type * from "./exports/resources";
@@ -23,6 +24,7 @@ export * from "./dispatch";
23
24
  export * from "./billing";
24
25
  export type * from "./banking";
25
26
  export * from "./mdt";
27
+ export * from "./warrants";
26
28
  export * from "./ems";
27
29
  export * from "./fuel";
28
30
  export * from "./doorlock";
package/src/mdt.ts CHANGED
@@ -31,6 +31,8 @@ export interface MdtAdapter {
31
31
  version?: string;
32
32
  /** Writes a record; false when the MDT has no such record kind. Absent = the MDT takes no records from scripts. */
33
33
  record?(entry: MdtEntry): boolean;
34
+ /** Whether a character (citizenid) has an active warrant. Absent = the MDT exposes no warrants (answered false). */
35
+ hasWarrant?(citizenid: string): Promise<boolean>;
34
36
  }
35
37
 
36
38
  /** An MDT's client half: opens its screen for the local player. */
@@ -75,4 +77,10 @@ export type MdtServerExports = {
75
77
  GetMdtSystem(): string | null;
76
78
  /** Writes a record into the active MDT; false when it is invalid, no MDT runs or it takes no such record. */
77
79
  AddMdtRecord(record: MdtRecord): boolean;
80
+ /**
81
+ * Whether a character (a loaded player's server id or a citizenid) has an active warrant: the active MDT's and / or
82
+ * ai-core's own, by the panel setting `warrants`; `done(false)` when not. A callback: no promise crosses a resource
83
+ * boundary.
84
+ */
85
+ HasMdtWarrant(target: number | string, done: (wanted: boolean) => void): void;
78
86
  };
package/src/phone.ts CHANGED
@@ -27,6 +27,16 @@ export interface PhoneAdapter {
27
27
  notify(source: number, notification: PhoneNotification): boolean;
28
28
  }
29
29
 
30
+ /**
31
+ * Client half of a phone behind ai-core's phone layer: how it tells that the local player opened it. A phone without
32
+ * a confirmed signal has neither member.
33
+ */
34
+ export interface PhoneClientAdapter {
35
+ resource: string;
36
+ /** Registers the phone's open signal (an event or a state bag) once at start; calls `opened()` on each opening. */
37
+ watch(opened: () => void): void;
38
+ }
39
+
30
40
  /** ai-core's phone exports: whatever phone script runs answers (none: null / false). */
31
41
  export type PhoneServerExports = {
32
42
  GetPhoneNumber(source: number): string | null;
package/src/vehicles.ts CHANGED
@@ -25,6 +25,8 @@ export interface OwnedVehicle {
25
25
  fuel: number;
26
26
  engine: number;
27
27
  body: number;
28
+ /** VehicleDamage (`@aifivem/lib/shared`: windows, tyres, lights, bumpers, tank) read by the server on Enhanced; null when none is stored. */
29
+ damage?: unknown;
28
30
  }
29
31
 
30
32
  /** Entity state bags ai-vehicles sets on a spawned owned vehicle. */
@@ -41,6 +43,23 @@ export const VEHICLE_BAGS = {
41
43
  fuel: "fuel",
42
44
  } as const;
43
45
 
46
+ /** `DeleteVehicleByPlate`'s answer: `entities` = world entities with that plate that were deleted. */
47
+ export type DeleteByPlateResult =
48
+ | { ok: true; id: number; entities: number }
49
+ | { ok: false; error: "invalid_plate" | "not_found" | "failed" };
50
+
51
+ /**
52
+ * `AdoptVehicle`'s answer: `owned` = the entity is already an owned vehicle, `plate_owned` = its plate belongs to an
53
+ * owned vehicle (owner online or not), `model` = the model name is not the entity's, `invalid` = no vehicle entity, a
54
+ * wrong owner or props that are not the entity's.
55
+ */
56
+ export type AdoptVehicleResult =
57
+ | { ok: true; id: number; plate: string }
58
+ | {
59
+ ok: false;
60
+ error: "invalid" | "model" | "owned" | "plate_owned" | "failed";
61
+ };
62
+
44
63
  /** ai-vehicles' server exports. */
45
64
  export type AiVehiclesServerExports = {
46
65
  CreateVehicle(
@@ -86,6 +105,8 @@ export type AiVehiclesServerExports = {
86
105
  fuel?: number;
87
106
  engine?: number;
88
107
  body?: number;
108
+ /** VehicleDamage (lib server `enhanced.readVehicleDamage`); null clears it, left out keeps the stored one. */
109
+ damage?: unknown;
89
110
  state?: VehicleState;
90
111
  garage?: string | null;
91
112
  },
@@ -95,6 +116,24 @@ export type AiVehiclesServerExports = {
95
116
  StoreVehicle(id: number, garage: string | null, state?: VehicleState): void;
96
117
  SetOwner(id: number, owner: VehicleOwner): void;
97
118
  DeleteVehicle(id: number): void;
119
+ /** Deletes an owned vehicle completely by plate (row and every world entity with the plate), owner online or not. */
120
+ DeleteVehicleByPlate(
121
+ plate: string,
122
+ done?: (result: DeleteByPlateResult) => void,
123
+ ): void;
124
+ /**
125
+ * Makes an existing world vehicle an owned one, "out" and tracked like a spawned one (admin `/admincar`). `model` is
126
+ * the entity's model name (the server cannot read it; checked against the entity), `props` its look read on a client
127
+ * (lib VehicleProps or ox_lib / qb-core's shape, of the entity's model). The entity keeps its plate when that is a
128
+ * valid custom plate (`SetPlate`'s rules), else it gets the generated one.
129
+ */
130
+ AdoptVehicle(
131
+ owner: VehicleOwner,
132
+ entity: number,
133
+ model: string,
134
+ props: unknown,
135
+ done?: (result: AdoptVehicleResult) => void,
136
+ ): void;
98
137
  /**
99
138
  * Creates the entity; `cb` gets its net id (null when it failed). `asker` is a player whose client answers the model
100
139
  * type. `setup` (lib VehicleSetup, e.g. `{ colors }`) is kept with a vehicle that has no props yet and applied on every
@@ -0,0 +1,87 @@
1
+ import type { ActionResult } from "./action";
2
+
3
+ /** ai-core's own warrants (`ai_core_warrants`): set by admins, the police job menu or any script through lib `warrants`. */
4
+ export interface Warrant {
5
+ id: number;
6
+ charId: number;
7
+ reason: string;
8
+ /** Who issued it: an officer's character, an admin or a resource name. */
9
+ by: string;
10
+ /** Epoch ms. */
11
+ created: number;
12
+ /** Epoch ms; null = until cleared. */
13
+ expires: number | null;
14
+ }
15
+
16
+ /** A row of the active list: the warrant and its character. */
17
+ export interface WarrantRow extends Warrant {
18
+ citizenid: string;
19
+ name: string;
20
+ }
21
+
22
+ /** A page of active warrants, newest first; `next` is the cursor of the next page (null: last page). */
23
+ export interface WarrantPage {
24
+ warrants: WarrantRow[];
25
+ next: number | null;
26
+ }
27
+
28
+ /** A character: a loaded player's server id, a citizenid or `{ charId }`. */
29
+ export type WarrantTarget = number | string | { charId: number };
30
+
31
+ /** A new warrant; `minutes` left out or null = until cleared, `by` an officer's server id or a name. */
32
+ export interface WarrantAdd {
33
+ target: WarrantTarget;
34
+ reason: string;
35
+ minutes?: number | null;
36
+ by?: number | string;
37
+ }
38
+
39
+ /** `AddWarrant`'s answer: the new id, or an ai-core lang key. */
40
+ export type WarrantResult = ActionResult<{ id: number }>;
41
+
42
+ /**
43
+ * How ai-core's MDT layer answers a warrant check (panel setting `warrants`): `auto` = the MDT's warrants while it
44
+ * answers warrant checks, else ai-core's own; `both` = either; `mdt` = only the MDT's.
45
+ */
46
+ export type WarrantMode = "auto" | "both" | "mdt";
47
+
48
+ /** Lengths offered by the admin panel and the police menu (lang `..._D_<id>`); null = until cleared. */
49
+ export const WARRANT_DURATIONS = [
50
+ { id: "1H", minutes: 60 },
51
+ { id: "6H", minutes: 360 },
52
+ { id: "1D", minutes: 1440 },
53
+ { id: "3D", minutes: 4320 },
54
+ { id: "1W", minutes: 10_080 },
55
+ { id: "CLEARED", minutes: null },
56
+ ] as const satisfies ReadonlyArray<{ id: string; minutes: number | null }>;
57
+
58
+ /** Active warrants one character may hold; a full list refuses new ones. */
59
+ export const MAX_WARRANTS = 20;
60
+
61
+ /** ai-core's warrant exports (server). Callbacks: no promise crosses a resource boundary. */
62
+ export type WarrantServerExports = {
63
+ /** Issues a warrant; `done` gets `{ ok, id }` or `{ ok: false, error }` (an ai-core lang key). */
64
+ AddWarrant(warrant: WarrantAdd, done?: (result: WarrantResult) => void): void;
65
+ /** Clears one active warrant; `done(false)` when no active warrant has that id. */
66
+ ClearWarrant(
67
+ id: number,
68
+ by?: number | string,
69
+ done?: (cleared: boolean) => void,
70
+ ): void;
71
+ /** Clears every active warrant of a character; `done` gets how many. */
72
+ ClearWarrants(
73
+ target: WarrantTarget,
74
+ by?: number | string,
75
+ done?: (count: number) => void,
76
+ ): void;
77
+ /** A character's active warrants, newest first; null when the target names no character. */
78
+ GetWarrants(
79
+ target: WarrantTarget,
80
+ done: (warrants: Warrant[] | null) => void,
81
+ ): void;
82
+ /** Every active warrant, newest first, 25 a page (`cursor` = the last page's `next`). */
83
+ ListWarrants(
84
+ cursor: number | null | undefined,
85
+ done: (page: WarrantPage) => void,
86
+ ): void;
87
+ };