@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/package.json +1 -1
- package/src/action.ts +6 -6
- package/src/characters.ts +16 -0
- package/src/commands.ts +80 -80
- package/src/core.ts +139 -125
- package/src/dispatch.ts +103 -103
- package/src/exports/citizen.ts +5 -1
- package/src/exports/coreBans.ts +32 -0
- package/src/exports/coreCharacters.ts +40 -31
- package/src/exports/coreLayers.ts +4 -2
- package/src/exports/coreServer.ts +4 -0
- package/src/exports/resources.ts +19 -13
- package/src/index.ts +2 -0
- package/src/logs.ts +45 -45
- package/src/mdt.ts +8 -0
- package/src/menu.ts +94 -94
- package/src/minigame.ts +45 -45
- package/src/phone.ts +49 -39
- package/src/player.ts +159 -159
- package/src/radial.ts +44 -44
- package/src/validation.ts +82 -82
- package/src/vehicleKeys.ts +64 -64
- package/src/vehicles.ts +35 -0
- package/src/vrp.ts +51 -51
- package/src/warrants.ts +87 -0
- package/src/world.ts +26 -26
package/src/menu.ts
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
/** Shared menu and input dialog contract (ai-core draws them for every resource through lib `menu` / `input`). */
|
|
2
|
-
|
|
3
|
-
export interface MenuItem {
|
|
4
|
-
id: string;
|
|
5
|
-
label: string;
|
|
6
|
-
/** Font Awesome solid icon name without `fa-`. */
|
|
7
|
-
icon?: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
/** A switch row: picking it flips the switch in place and the menu stays open (`menu`'s `onToggle` hears it). */
|
|
11
|
-
checked?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface MenuRequest {
|
|
15
|
-
title: string;
|
|
16
|
-
items: MenuItem[];
|
|
17
|
-
/** A sub menu: a short Escape answers `MENU_BACK` (the caller opens the menu before), holding Escape closes. */
|
|
18
|
-
back?: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** ai-core's item picker (admin tools): every item of the active inventory with its picture, search and a count. */
|
|
22
|
-
export interface ItemPickerRequest {
|
|
23
|
-
title: string;
|
|
24
|
-
/** Whose inventory the items go to (server id): its free weight caps the list. The picking admin when absent. */
|
|
25
|
-
target?: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** One item the picker shows. */
|
|
29
|
-
export interface PickerItem {
|
|
30
|
-
name: string;
|
|
31
|
-
label: string;
|
|
32
|
-
image?: string;
|
|
33
|
-
/** Weight of one, in the inventory's unit (grams for ai-inventory and ox_inventory). */
|
|
34
|
-
weight: number;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** One row of the picker's list: what the player asked for. */
|
|
38
|
-
export interface PickedItem {
|
|
39
|
-
name: string;
|
|
40
|
-
count: number;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** What the picker gets from the server: the items, and the target's weight when the inventory can tell it. */
|
|
44
|
-
export interface ItemPickerData {
|
|
45
|
-
items: PickerItem[];
|
|
46
|
-
room: { weight: number; maxWeight: number } | null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** Callback (admins only): (target: number | null) -> ItemPickerData. */
|
|
50
|
-
export const ITEM_PICKER_CALLBACK = "ai-core:admin:items";
|
|
51
|
-
|
|
52
|
-
/** What `menu()` resolves with when the player goes back from a sub menu (`back: true`). */
|
|
53
|
-
export const MENU_BACK = "__back";
|
|
54
|
-
|
|
55
|
-
export type InputField =
|
|
56
|
-
| {
|
|
57
|
-
name: string;
|
|
58
|
-
label: string;
|
|
59
|
-
type: "number";
|
|
60
|
-
min?: number;
|
|
61
|
-
max?: number;
|
|
62
|
-
placeholder?: string;
|
|
63
|
-
}
|
|
64
|
-
| {
|
|
65
|
-
name: string;
|
|
66
|
-
label: string;
|
|
67
|
-
type: "text";
|
|
68
|
-
maxLength?: number;
|
|
69
|
-
placeholder?: string;
|
|
70
|
-
/** A several-line text box (notes, descriptions). */
|
|
71
|
-
multiline?: boolean;
|
|
72
|
-
/** The text the field starts with. */
|
|
73
|
-
value?: string;
|
|
74
|
-
/** Shown, not edited (reading a note); an empty read-only field does not block the confirm. */
|
|
75
|
-
readOnly?: boolean;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export interface InputRequest {
|
|
79
|
-
title: string;
|
|
80
|
-
fields: InputField[];
|
|
81
|
-
/** Lang text of the confirm button (already translated). */
|
|
82
|
-
confirm: string;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export const MENU_EVENTS = {
|
|
86
|
-
/** Client local: (resource, requestId, itemId | null) the player picked an item or closed the menu. */
|
|
87
|
-
menuResult: "ai-lib:client:menuResult",
|
|
88
|
-
/** Client local: (resource, requestId, itemId) the pointer or focus is on an item (previews). */
|
|
89
|
-
menuHover: "ai-lib:client:menuHover",
|
|
90
|
-
/** Client local: (resource, requestId, itemId, checked) the player flipped a switch row; the menu stays open. */
|
|
91
|
-
menuToggle: "ai-lib:client:menuToggle",
|
|
92
|
-
/** Client local: (resource, requestId, values | null) the player confirmed or closed the input dialog. */
|
|
93
|
-
inputResult: "ai-lib:client:inputResult",
|
|
94
|
-
} as const;
|
|
1
|
+
/** Shared menu and input dialog contract (ai-core draws them for every resource through lib `menu` / `input`). */
|
|
2
|
+
|
|
3
|
+
export interface MenuItem {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** Font Awesome solid icon name without `fa-`. */
|
|
7
|
+
icon?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** A switch row: picking it flips the switch in place and the menu stays open (`menu`'s `onToggle` hears it). */
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface MenuRequest {
|
|
15
|
+
title: string;
|
|
16
|
+
items: MenuItem[];
|
|
17
|
+
/** A sub menu: a short Escape answers `MENU_BACK` (the caller opens the menu before), holding Escape closes. */
|
|
18
|
+
back?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** ai-core's item picker (admin tools): every item of the active inventory with its picture, search and a count. */
|
|
22
|
+
export interface ItemPickerRequest {
|
|
23
|
+
title: string;
|
|
24
|
+
/** Whose inventory the items go to (server id): its free weight caps the list. The picking admin when absent. */
|
|
25
|
+
target?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** One item the picker shows. */
|
|
29
|
+
export interface PickerItem {
|
|
30
|
+
name: string;
|
|
31
|
+
label: string;
|
|
32
|
+
image?: string;
|
|
33
|
+
/** Weight of one, in the inventory's unit (grams for ai-inventory and ox_inventory). */
|
|
34
|
+
weight: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** One row of the picker's list: what the player asked for. */
|
|
38
|
+
export interface PickedItem {
|
|
39
|
+
name: string;
|
|
40
|
+
count: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** What the picker gets from the server: the items, and the target's weight when the inventory can tell it. */
|
|
44
|
+
export interface ItemPickerData {
|
|
45
|
+
items: PickerItem[];
|
|
46
|
+
room: { weight: number; maxWeight: number } | null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Callback (admins only): (target: number | null) -> ItemPickerData. */
|
|
50
|
+
export const ITEM_PICKER_CALLBACK = "ai-core:admin:items";
|
|
51
|
+
|
|
52
|
+
/** What `menu()` resolves with when the player goes back from a sub menu (`back: true`). */
|
|
53
|
+
export const MENU_BACK = "__back";
|
|
54
|
+
|
|
55
|
+
export type InputField =
|
|
56
|
+
| {
|
|
57
|
+
name: string;
|
|
58
|
+
label: string;
|
|
59
|
+
type: "number";
|
|
60
|
+
min?: number;
|
|
61
|
+
max?: number;
|
|
62
|
+
placeholder?: string;
|
|
63
|
+
}
|
|
64
|
+
| {
|
|
65
|
+
name: string;
|
|
66
|
+
label: string;
|
|
67
|
+
type: "text";
|
|
68
|
+
maxLength?: number;
|
|
69
|
+
placeholder?: string;
|
|
70
|
+
/** A several-line text box (notes, descriptions). */
|
|
71
|
+
multiline?: boolean;
|
|
72
|
+
/** The text the field starts with. */
|
|
73
|
+
value?: string;
|
|
74
|
+
/** Shown, not edited (reading a note); an empty read-only field does not block the confirm. */
|
|
75
|
+
readOnly?: boolean;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export interface InputRequest {
|
|
79
|
+
title: string;
|
|
80
|
+
fields: InputField[];
|
|
81
|
+
/** Lang text of the confirm button (already translated). */
|
|
82
|
+
confirm: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const MENU_EVENTS = {
|
|
86
|
+
/** Client local: (resource, requestId, itemId | null) the player picked an item or closed the menu. */
|
|
87
|
+
menuResult: "ai-lib:client:menuResult",
|
|
88
|
+
/** Client local: (resource, requestId, itemId) the pointer or focus is on an item (previews). */
|
|
89
|
+
menuHover: "ai-lib:client:menuHover",
|
|
90
|
+
/** Client local: (resource, requestId, itemId, checked) the player flipped a switch row; the menu stays open. */
|
|
91
|
+
menuToggle: "ai-lib:client:menuToggle",
|
|
92
|
+
/** Client local: (resource, requestId, values | null) the player confirmed or closed the input dialog. */
|
|
93
|
+
inputResult: "ai-lib:client:inputResult",
|
|
94
|
+
} as const;
|
package/src/minigame.ts
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
/** Minigames ai-core draws for every resource (lib `skillCheck` / `lockpick`); the answer arrives as `MENU_EVENTS.menuResult`. */
|
|
2
|
-
|
|
3
|
-
/** One ring of a skill check: the green arc's size in degrees and how many turns a second the needle makes. */
|
|
4
|
-
export interface SkillStage {
|
|
5
|
-
area: number;
|
|
6
|
-
speed: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/** A named skill check stage (ox_lib's names) or ox_lib's `{ areaSize, speedMultiplier }`. */
|
|
10
|
-
export type SkillDifficulty =
|
|
11
|
-
"easy" | "medium" | "hard" | { areaSize: number; speedMultiplier: number };
|
|
12
|
-
|
|
13
|
-
export const SKILL_STAGES: Record<"easy" | "medium" | "hard", SkillStage> = {
|
|
14
|
-
easy: { area: 50, speed: 0.6 },
|
|
15
|
-
medium: { area: 40, speed: 0.85 },
|
|
16
|
-
hard: { area: 25, speed: 1 },
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/** Lockpick difficulty: the sweet spot's width in degrees of the pick's half circle. */
|
|
20
|
-
export const LOCKPICK_AREAS: Record<"easy" | "medium" | "hard", number> = {
|
|
21
|
-
easy: 18,
|
|
22
|
-
medium: 11,
|
|
23
|
-
hard: 6,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type LockpickResult = "opened" | "broken" | "cancelled";
|
|
27
|
-
|
|
28
|
-
export type MinigameRequest =
|
|
29
|
-
| { kind: "skillCheck"; stages: SkillStage[]; keys: string[] }
|
|
30
|
-
| { kind: "lockpick"; pins: number; area: number; picks: number };
|
|
31
|
-
|
|
32
|
-
/** A progress bar a server flow runs on a player's client (lib `progressFor`, ai-core's client draws it). */
|
|
33
|
-
export interface ServerProgress {
|
|
34
|
-
label: string;
|
|
35
|
-
/** Milliseconds. */
|
|
36
|
-
duration: number;
|
|
37
|
-
anim?: { dict: string; clip: string; flag?: number };
|
|
38
|
-
scenario?: string;
|
|
39
|
-
allowVehicle?: boolean;
|
|
40
|
-
canCancel?: boolean;
|
|
41
|
-
freeze?: boolean;
|
|
42
|
-
disable?: { move?: boolean; car?: boolean; mouse?: boolean; combat?: boolean };
|
|
43
|
-
/** The player turns to this point first. */
|
|
44
|
-
face?: { x: number; y: number; z: number };
|
|
45
|
-
}
|
|
1
|
+
/** Minigames ai-core draws for every resource (lib `skillCheck` / `lockpick`); the answer arrives as `MENU_EVENTS.menuResult`. */
|
|
2
|
+
|
|
3
|
+
/** One ring of a skill check: the green arc's size in degrees and how many turns a second the needle makes. */
|
|
4
|
+
export interface SkillStage {
|
|
5
|
+
area: number;
|
|
6
|
+
speed: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** A named skill check stage (ox_lib's names) or ox_lib's `{ areaSize, speedMultiplier }`. */
|
|
10
|
+
export type SkillDifficulty =
|
|
11
|
+
"easy" | "medium" | "hard" | { areaSize: number; speedMultiplier: number };
|
|
12
|
+
|
|
13
|
+
export const SKILL_STAGES: Record<"easy" | "medium" | "hard", SkillStage> = {
|
|
14
|
+
easy: { area: 50, speed: 0.6 },
|
|
15
|
+
medium: { area: 40, speed: 0.85 },
|
|
16
|
+
hard: { area: 25, speed: 1 },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Lockpick difficulty: the sweet spot's width in degrees of the pick's half circle. */
|
|
20
|
+
export const LOCKPICK_AREAS: Record<"easy" | "medium" | "hard", number> = {
|
|
21
|
+
easy: 18,
|
|
22
|
+
medium: 11,
|
|
23
|
+
hard: 6,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type LockpickResult = "opened" | "broken" | "cancelled";
|
|
27
|
+
|
|
28
|
+
export type MinigameRequest =
|
|
29
|
+
| { kind: "skillCheck"; stages: SkillStage[]; keys: string[] }
|
|
30
|
+
| { kind: "lockpick"; pins: number; area: number; picks: number };
|
|
31
|
+
|
|
32
|
+
/** A progress bar a server flow runs on a player's client (lib `progressFor`, ai-core's client draws it). */
|
|
33
|
+
export interface ServerProgress {
|
|
34
|
+
label: string;
|
|
35
|
+
/** Milliseconds. */
|
|
36
|
+
duration: number;
|
|
37
|
+
anim?: { dict: string; clip: string; flag?: number };
|
|
38
|
+
scenario?: string;
|
|
39
|
+
allowVehicle?: boolean;
|
|
40
|
+
canCancel?: boolean;
|
|
41
|
+
freeze?: boolean;
|
|
42
|
+
disable?: { move?: boolean; car?: boolean; mouse?: boolean; combat?: boolean };
|
|
43
|
+
/** The player turns to this point first. */
|
|
44
|
+
face?: { x: number; y: number; z: number };
|
|
45
|
+
}
|
package/src/phone.ts
CHANGED
|
@@ -1,39 +1,49 @@
|
|
|
1
|
-
/** A mail a script sends to a player's phone. */
|
|
2
|
-
export interface PhoneMail {
|
|
3
|
-
/** Shown as the sender (a company, "Los Santos Customs"). */
|
|
4
|
-
sender: string;
|
|
5
|
-
subject: string;
|
|
6
|
-
message: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/** A phone notification on a player's phone. */
|
|
10
|
-
export interface PhoneNotification {
|
|
11
|
-
title: string;
|
|
12
|
-
message: string;
|
|
13
|
-
/** Phone app id it belongs to when the phone knows it (`messages`, `mail`, `bank`). */
|
|
14
|
-
app?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** One phone script behind ai-core's phone layer (server side). */
|
|
18
|
-
export interface PhoneAdapter {
|
|
19
|
-
resource: string;
|
|
20
|
-
number(source: number): string | null;
|
|
21
|
-
sourceOf(number: string): number | null;
|
|
22
|
-
hasPhone(source: number): boolean;
|
|
23
|
-
/** `to` is a phone number (or the phone's mail address). */
|
|
24
|
-
mail(to: string, mail: PhoneMail): boolean;
|
|
25
|
-
/** A text from one number to another. */
|
|
26
|
-
message(from: string, to: string, text: string): boolean;
|
|
27
|
-
notify(source: number, notification: PhoneNotification): boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
/** A mail a script sends to a player's phone. */
|
|
2
|
+
export interface PhoneMail {
|
|
3
|
+
/** Shown as the sender (a company, "Los Santos Customs"). */
|
|
4
|
+
sender: string;
|
|
5
|
+
subject: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** A phone notification on a player's phone. */
|
|
10
|
+
export interface PhoneNotification {
|
|
11
|
+
title: string;
|
|
12
|
+
message: string;
|
|
13
|
+
/** Phone app id it belongs to when the phone knows it (`messages`, `mail`, `bank`). */
|
|
14
|
+
app?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** One phone script behind ai-core's phone layer (server side). */
|
|
18
|
+
export interface PhoneAdapter {
|
|
19
|
+
resource: string;
|
|
20
|
+
number(source: number): string | null;
|
|
21
|
+
sourceOf(number: string): number | null;
|
|
22
|
+
hasPhone(source: number): boolean;
|
|
23
|
+
/** `to` is a phone number (or the phone's mail address). */
|
|
24
|
+
mail(to: string, mail: PhoneMail): boolean;
|
|
25
|
+
/** A text from one number to another. */
|
|
26
|
+
message(from: string, to: string, text: string): boolean;
|
|
27
|
+
notify(source: number, notification: PhoneNotification): boolean;
|
|
28
|
+
}
|
|
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
|
+
|
|
40
|
+
/** ai-core's phone exports: whatever phone script runs answers (none: null / false). */
|
|
41
|
+
export type PhoneServerExports = {
|
|
42
|
+
GetPhoneNumber(source: number): string | null;
|
|
43
|
+
GetSourceByPhone(number: string): number | null;
|
|
44
|
+
HasPhone(source: number): boolean;
|
|
45
|
+
/** `to`: a player's server id or a phone number. */
|
|
46
|
+
SendPhoneMail(to: number | string, mail: PhoneMail): boolean;
|
|
47
|
+
SendPhoneMessage(from: string, to: number | string, text: string): boolean;
|
|
48
|
+
PhoneNotify(source: number, notification: PhoneNotification): boolean;
|
|
49
|
+
};
|