@aifivem/shared 0.5.0 → 0.7.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/src/dispatch.ts CHANGED
@@ -1,103 +1,103 @@
1
- /** A point on the map. */
2
- export interface DispatchCoords {
3
- x: number;
4
- y: number;
5
- z: number;
6
- }
7
-
8
- /**
9
- * A police (or other job) alert a script sends through ai-core's dispatch layer (lib `dispatch.alert`); the active
10
- * alert system shows it to the on-duty members of `jobs`. Texts are already translated.
11
- */
12
- export interface DispatchAlert {
13
- /** Radio code shown before the title ("10-71"). */
14
- code?: string;
15
- /** The headline ("Shots fired"). */
16
- title: string;
17
- /** One more line (the shop's name). */
18
- message?: string;
19
- /** Where it happened; without it the `source` player's position, else no map point. */
20
- coords?: DispatchCoords;
21
- /** Jobs whose on-duty members get it; default: the alert system's police jobs. */
22
- jobs?: string[];
23
- /** The player the alert is about (shooter, robber): systems that describe the suspect (vehicle, gender) read this player. */
24
- source?: number;
25
- /** Map blip: a GTA blip sprite and colour (default: the alert system's). */
26
- blip?: { sprite: number; color?: number; scale?: number };
27
- /** Seconds the alert stays (card, blip, waypoint key); default: the alert system's own. */
28
- duration?: number;
29
- /** Font Awesome solid icon name without `fa-` ("gun"). */
30
- icon?: string;
31
- /** `high` makes the card stand out (armed robbery, officer down). */
32
- priority?: "normal" | "high";
33
- }
34
-
35
- /** One alert system behind ai-core's dispatch layer (server side). */
36
- export interface DispatchAdapter {
37
- resource: string;
38
- /** The version the adapter is written for; ai-core warns when another one runs. Absent for ai-* systems. */
39
- version?: string;
40
- /** `coords` is filled from `source` when the caller left it out. */
41
- alert(alert: DispatchAlert): void;
42
- /** The system answers QB's `police:server:policeAlert` event itself: ai-core leaves that event to it. */
43
- answersPoliceAlert?: boolean;
44
- /** Runs next to ai-policealert on purpose (an MDT with alerts): it does not make ai-policealert unneeded. */
45
- besideOurs?: boolean;
46
- }
47
-
48
- const text = (v: unknown, max: number): string | undefined =>
49
- typeof v === "string" && v.trim() ? v.trim().slice(0, max) : undefined;
50
- const finite = (v: unknown): v is number =>
51
- typeof v === "number" && Number.isFinite(v);
52
- const obj = (v: unknown): Record<string, unknown> | null =>
53
- typeof v === "object" && v !== null && !Array.isArray(v)
54
- ? (v as Record<string, unknown>)
55
- : null;
56
-
57
- /** An alert from untrusted input (another resource's export call); null without a title. Extra fields drop. */
58
- export function toDispatchAlert(value: unknown): DispatchAlert | null {
59
- const v = obj(value);
60
- const title = text(v?.title, 80);
61
- if (!v || !title) return null;
62
- const c = obj(v.coords);
63
- const b = obj(v.blip);
64
- const jobs = Array.isArray(v.jobs)
65
- ? v.jobs
66
- .filter((j): j is string => typeof j === "string" && j.length <= 32)
67
- .slice(0, 10)
68
- : [];
69
- return {
70
- code: text(v.code, 12),
71
- title,
72
- message: text(v.message, 160),
73
- coords:
74
- c && finite(c.x) && finite(c.y) && finite(c.z)
75
- ? { x: c.x, y: c.y, z: c.z }
76
- : undefined,
77
- jobs: jobs.length ? jobs : undefined,
78
- source:
79
- finite(v.source) && Number.isInteger(v.source) && v.source > 0
80
- ? v.source
81
- : undefined,
82
- blip:
83
- b && finite(b.sprite)
84
- ? {
85
- sprite: Math.trunc(b.sprite),
86
- color: finite(b.color) ? Math.trunc(b.color) : undefined,
87
- scale: finite(b.scale)
88
- ? Math.min(3, Math.max(0.1, b.scale))
89
- : undefined,
90
- }
91
- : undefined,
92
- duration: finite(v.duration)
93
- ? Math.min(3600, Math.max(1, Math.round(v.duration)))
94
- : undefined,
95
- icon: text(v.icon, 40),
96
- priority: v.priority === "high" ? "high" : "normal",
97
- };
98
- }
99
-
100
- /** ai-core's dispatch export: whatever alert system runs shows the alert (none: false). */
101
- export type DispatchServerExports = {
102
- SendDispatchAlert(alert: DispatchAlert): boolean;
103
- };
1
+ /** A point on the map. */
2
+ export interface DispatchCoords {
3
+ x: number;
4
+ y: number;
5
+ z: number;
6
+ }
7
+
8
+ /**
9
+ * A police (or other job) alert a script sends through ai-core's dispatch layer (lib `dispatch.alert`); the active
10
+ * alert system shows it to the on-duty members of `jobs`. Texts are already translated.
11
+ */
12
+ export interface DispatchAlert {
13
+ /** Radio code shown before the title ("10-71"). */
14
+ code?: string;
15
+ /** The headline ("Shots fired"). */
16
+ title: string;
17
+ /** One more line (the shop's name). */
18
+ message?: string;
19
+ /** Where it happened; without it the `source` player's position, else no map point. */
20
+ coords?: DispatchCoords;
21
+ /** Jobs whose on-duty members get it; default: the alert system's police jobs. */
22
+ jobs?: string[];
23
+ /** The player the alert is about (shooter, robber): systems that describe the suspect (vehicle, gender) read this player. */
24
+ source?: number;
25
+ /** Map blip: a GTA blip sprite and colour (default: the alert system's). */
26
+ blip?: { sprite: number; color?: number; scale?: number };
27
+ /** Seconds the alert stays (card, blip, waypoint key); default: the alert system's own. */
28
+ duration?: number;
29
+ /** Font Awesome solid icon name without `fa-` ("gun"). */
30
+ icon?: string;
31
+ /** `high` makes the card stand out (armed robbery, officer down). */
32
+ priority?: "normal" | "high";
33
+ }
34
+
35
+ /** One alert system behind ai-core's dispatch layer (server side). */
36
+ export interface DispatchAdapter {
37
+ resource: string;
38
+ /** The version the adapter is written for; ai-core warns when another one runs. Absent for ai-* systems. */
39
+ version?: string;
40
+ /** `coords` is filled from `source` when the caller left it out. */
41
+ alert(alert: DispatchAlert): void;
42
+ /** The system answers QB's `police:server:policeAlert` event itself: ai-core leaves that event to it. */
43
+ answersPoliceAlert?: boolean;
44
+ /** Runs next to ai-policealert on purpose (an MDT with alerts): it does not make ai-policealert unneeded. */
45
+ besideOurs?: boolean;
46
+ }
47
+
48
+ const text = (v: unknown, max: number): string | undefined =>
49
+ typeof v === "string" && v.trim() ? v.trim().slice(0, max) : undefined;
50
+ const finite = (v: unknown): v is number =>
51
+ typeof v === "number" && Number.isFinite(v);
52
+ const obj = (v: unknown): Record<string, unknown> | null =>
53
+ typeof v === "object" && v !== null && !Array.isArray(v)
54
+ ? (v as Record<string, unknown>)
55
+ : null;
56
+
57
+ /** An alert from untrusted input (another resource's export call); null without a title. Extra fields drop. */
58
+ export function toDispatchAlert(value: unknown): DispatchAlert | null {
59
+ const v = obj(value);
60
+ const title = text(v?.title, 80);
61
+ if (!v || !title) return null;
62
+ const c = obj(v.coords);
63
+ const b = obj(v.blip);
64
+ const jobs = Array.isArray(v.jobs)
65
+ ? v.jobs
66
+ .filter((j): j is string => typeof j === "string" && j.length <= 32)
67
+ .slice(0, 10)
68
+ : [];
69
+ return {
70
+ code: text(v.code, 12),
71
+ title,
72
+ message: text(v.message, 160),
73
+ coords:
74
+ c && finite(c.x) && finite(c.y) && finite(c.z)
75
+ ? { x: c.x, y: c.y, z: c.z }
76
+ : undefined,
77
+ jobs: jobs.length ? jobs : undefined,
78
+ source:
79
+ finite(v.source) && Number.isInteger(v.source) && v.source > 0
80
+ ? v.source
81
+ : undefined,
82
+ blip:
83
+ b && finite(b.sprite)
84
+ ? {
85
+ sprite: Math.trunc(b.sprite),
86
+ color: finite(b.color) ? Math.trunc(b.color) : undefined,
87
+ scale: finite(b.scale)
88
+ ? Math.min(3, Math.max(0.1, b.scale))
89
+ : undefined,
90
+ }
91
+ : undefined,
92
+ duration: finite(v.duration)
93
+ ? Math.min(3600, Math.max(1, Math.round(v.duration)))
94
+ : undefined,
95
+ icon: text(v.icon, 40),
96
+ priority: v.priority === "high" ? "high" : "normal",
97
+ };
98
+ }
99
+
100
+ /** ai-core's dispatch export: whatever alert system runs shows the alert (none: false). */
101
+ export type DispatchServerExports = {
102
+ SendDispatchAlert(alert: DispatchAlert): boolean;
103
+ };
@@ -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/logs.ts CHANGED
@@ -1,45 +1,45 @@
1
- /** Log contracts: every ai-* resource logs through ai-core, which sends to the providers turned on in its panel. */
2
-
3
- export type LogLevel = "debug" | "info" | "warn" | "error";
4
-
5
- export interface LogOptions {
6
- level?: LogLevel;
7
- /** The player who did it (server id); their name, character and identifiers are added. */
8
- source?: number;
9
- /** The player it was done to. */
10
- target?: number;
11
- /** Extra fields (amounts, item names, coordinates...). */
12
- metadata?: Record<string, unknown>;
13
- }
14
-
15
- /** How a resource describes one of its log channels. Webhook urls are never here: they live in ai-core's panel-edited data/secrets.json. */
16
- export interface LogChannel {
17
- /** Dataset name for Fivemanage / FiveM Stats (default: the resource name). */
18
- dataset?: string;
19
- /** false turns the channel off. */
20
- active?: boolean;
21
- }
22
-
23
- export interface LogPlayer {
24
- serverId: number;
25
- name: string;
26
- identifiers: Record<string, string>;
27
- citizenid?: string;
28
- character?: string;
29
- }
30
-
31
- /** What every provider receives. */
32
- export interface LogEntry {
33
- resource: string;
34
- channel: string;
35
- level: LogLevel;
36
- message: string;
37
- /** Unix seconds. */
38
- time: number;
39
- dataset: string;
40
- source?: number;
41
- target?: number;
42
- player?: LogPlayer;
43
- targetPlayer?: LogPlayer;
44
- metadata: Record<string, unknown>;
45
- }
1
+ /** Log contracts: every ai-* resource logs through ai-core, which sends to the providers turned on in its panel. */
2
+
3
+ export type LogLevel = "debug" | "info" | "warn" | "error";
4
+
5
+ export interface LogOptions {
6
+ level?: LogLevel;
7
+ /** The player who did it (server id); their name, character and identifiers are added. */
8
+ source?: number;
9
+ /** The player it was done to. */
10
+ target?: number;
11
+ /** Extra fields (amounts, item names, coordinates...). */
12
+ metadata?: Record<string, unknown>;
13
+ }
14
+
15
+ /** How a resource describes one of its log channels. Webhook urls are never here: they live in ai-core's panel-edited data/secrets.json. */
16
+ export interface LogChannel {
17
+ /** Dataset name for Fivemanage / FiveM Stats (default: the resource name). */
18
+ dataset?: string;
19
+ /** false turns the channel off. */
20
+ active?: boolean;
21
+ }
22
+
23
+ export interface LogPlayer {
24
+ serverId: number;
25
+ name: string;
26
+ identifiers: Record<string, string>;
27
+ citizenid?: string;
28
+ character?: string;
29
+ }
30
+
31
+ /** What every provider receives. */
32
+ export interface LogEntry {
33
+ resource: string;
34
+ channel: string;
35
+ level: LogLevel;
36
+ message: string;
37
+ /** Unix seconds. */
38
+ time: number;
39
+ dataset: string;
40
+ source?: number;
41
+ target?: number;
42
+ player?: LogPlayer;
43
+ targetPlayer?: LogPlayer;
44
+ metadata: Record<string, unknown>;
45
+ }
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
  };