@aifivem/shared 0.0.0-stage → 0.5.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 +23 -4
- package/src/action.ts +6 -0
- package/src/admin/dataSpec.ts +63 -0
- package/src/admin/events.ts +45 -0
- package/src/admin/lookups.ts +29 -0
- package/src/admin/panel.ts +105 -0
- package/src/admin/schema.ts +58 -0
- package/src/admin/widgets.ts +123 -0
- package/src/appearance.ts +115 -0
- package/src/banking.ts +58 -0
- package/src/bans.ts +91 -0
- package/src/billing.ts +112 -0
- package/src/characters.ts +71 -0
- package/src/commands.ts +80 -0
- package/src/core.ts +125 -0
- package/src/deaths.ts +44 -0
- package/src/definitions.ts +26 -0
- package/src/dispatch.ts +103 -0
- package/src/doorlock.ts +29 -0
- package/src/ems.ts +50 -0
- package/src/exports/aiInventory.ts +96 -0
- package/src/exports/citizen.ts +45 -0
- package/src/exports/coreCharacters.ts +167 -0
- package/src/exports/coreClient.ts +79 -0
- package/src/exports/coreGroups.ts +29 -0
- package/src/exports/coreLayers.ts +45 -0
- package/src/exports/coreMoney.ts +97 -0
- package/src/exports/coreServer.ts +91 -0
- package/src/exports/coreServices.ts +60 -0
- package/src/exports/resources.ts +107 -0
- package/src/fuel.ts +48 -0
- package/src/garages.ts +101 -0
- package/src/index.ts +49 -0
- package/src/inventory/adapters.ts +86 -0
- package/src/inventory/exports.ts +92 -0
- package/src/inventory/items.ts +92 -0
- package/src/logs.ts +45 -0
- package/src/mdt.ts +78 -0
- package/src/medical.ts +18 -0
- package/src/menu.ts +94 -0
- package/src/minigame.ts +45 -0
- package/src/multichar.ts +44 -0
- package/src/phone.ts +39 -0
- package/src/player.ts +159 -0
- package/src/radial.ts +44 -0
- package/src/ui.ts +92 -0
- package/src/validation.ts +82 -0
- package/src/vehicleKeys.ts +78 -0
- package/src/vehicles.ts +117 -0
- package/src/vrp.ts +51 -0
- package/src/world.ts +26 -0
- package/README.md +0 -3
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ai-core's inventory layer: every script calls ai-core (lib `inventory`), ai-core forwards to the active inventory
|
|
3
|
+
* through one adapter per inventory (`resources/[ai]/ai-core/resource/server/inventory/adapters/`).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** A player server id, or the id of another inventory (stash name, trunk plate...). */
|
|
7
|
+
export type InventoryRef = number | string;
|
|
8
|
+
|
|
9
|
+
export type ItemMetadata = Record<string, unknown>;
|
|
10
|
+
|
|
11
|
+
/** One stack of an inventory. */
|
|
12
|
+
export interface InventoryStack {
|
|
13
|
+
name: string;
|
|
14
|
+
label: string;
|
|
15
|
+
count: number;
|
|
16
|
+
slot: number;
|
|
17
|
+
metadata: ItemMetadata;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The stack a usable item handler gets. */
|
|
21
|
+
export interface UsedItem {
|
|
22
|
+
name: string;
|
|
23
|
+
slot: number;
|
|
24
|
+
count: number;
|
|
25
|
+
metadata: ItemMetadata;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Runs when a player uses the item. Returning false keeps the item in inventories that take a used item themselves
|
|
30
|
+
* (ai-inventory: the item's `consume` amount); other inventories follow their own item settings.
|
|
31
|
+
*/
|
|
32
|
+
export type UsableItemHandler = (source: number, item: UsedItem) => unknown;
|
|
33
|
+
|
|
34
|
+
export interface ItemDefinition {
|
|
35
|
+
name: string;
|
|
36
|
+
label: string;
|
|
37
|
+
weight: number;
|
|
38
|
+
/** One per stack (no stacking). */
|
|
39
|
+
unique: boolean;
|
|
40
|
+
/** Using it closes the inventory screen. */
|
|
41
|
+
close: boolean;
|
|
42
|
+
description: string;
|
|
43
|
+
/** A picture url (`nui://`, `https://`) when the inventory has one. */
|
|
44
|
+
image?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface StashDefinition {
|
|
48
|
+
name: string;
|
|
49
|
+
label: string;
|
|
50
|
+
slots: number;
|
|
51
|
+
maxWeight: number;
|
|
52
|
+
/** Jobs allowed to open it; empty: everyone. */
|
|
53
|
+
jobs: string[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** One product of a script shop. */
|
|
57
|
+
export interface ShopProduct {
|
|
58
|
+
name: string;
|
|
59
|
+
/** Price per item, paid the inventory's own way (cash / bank). */
|
|
60
|
+
price: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** A shop a script registers (lib `inventory.registerShop`): opened by the server for a player, no place of its own. */
|
|
64
|
+
export interface ShopDefinition {
|
|
65
|
+
/** Unique id (`police_armoury`). */
|
|
66
|
+
name: string;
|
|
67
|
+
label: string;
|
|
68
|
+
items: ShopProduct[];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The weapon item the local player holds, as the inventory knows it (HUD weapon box). */
|
|
72
|
+
export interface HeldWeapon {
|
|
73
|
+
/** Item name (`WEAPON_PISTOL`). */
|
|
74
|
+
name: string;
|
|
75
|
+
label: string;
|
|
76
|
+
/** Picture url (`nui://...`); absent when the inventory has none. */
|
|
77
|
+
image?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Client -> server callback: every item definition of the active inventory (the client's snapshot). */
|
|
81
|
+
export const ITEM_DEFINITIONS_CALLBACK = "ai-core:itemDefinitions";
|
|
82
|
+
/** Server -> clients: `(changes: Record<name, ItemDefinition | null>)`, null = the item is gone. */
|
|
83
|
+
export const ITEM_DEFINITIONS_EVENT = "ai-core:client:itemDefinitions";
|
|
84
|
+
/** Client local: `(changes: Record<name, ItemDefinition | null>)` after the snapshot (every item) and each change. */
|
|
85
|
+
export const CLIENT_ITEM_DEFINITIONS_EVENT = "ai-core:client:itemDefinitionsChanged";
|
|
86
|
+
/** Server local, emitted by an inventory adapter: the active inventory's definitions changed (no arguments). */
|
|
87
|
+
export const ITEM_DEFINITIONS_CHANGED_EVENT = "ai-core:itemDefinitionsChanged";
|
|
88
|
+
/**
|
|
89
|
+
* Client local: `(item: string, count: number, previous: number)` the local player's total of an item changed in the
|
|
90
|
+
* active inventory (0 = none left). The first counts after a load arrive as changes from 0.
|
|
91
|
+
*/
|
|
92
|
+
export const CLIENT_ITEM_COUNT_EVENT = "ai-core:client:itemCount";
|
package/src/logs.ts
ADDED
|
@@ -0,0 +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
|
+
}
|
package/src/mdt.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** What an MDT record is about. */
|
|
2
|
+
export type MdtRecordKind = "fine" | "warrant" | "arrest" | "jail";
|
|
3
|
+
|
|
4
|
+
/** A record a script writes into the police MDT through ai-core's MDT layer (lib `mdt.record`); texts already translated. */
|
|
5
|
+
export interface MdtRecord {
|
|
6
|
+
kind: MdtRecordKind;
|
|
7
|
+
/** The player the record is about. */
|
|
8
|
+
target: number;
|
|
9
|
+
/** The officer who writes it. */
|
|
10
|
+
by?: number;
|
|
11
|
+
/** What happened ("Speeding", "Armed robbery"). */
|
|
12
|
+
title: string;
|
|
13
|
+
/** A fine's amount in dollars. */
|
|
14
|
+
amount?: number;
|
|
15
|
+
/** A jail sentence in minutes. */
|
|
16
|
+
minutes?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** A record as an adapter gets it: what ai-core knows about the players filled in. */
|
|
20
|
+
export interface MdtEntry extends MdtRecord {
|
|
21
|
+
targetCitizenid: string;
|
|
22
|
+
targetName: string;
|
|
23
|
+
byCitizenid?: string;
|
|
24
|
+
byName?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** One MDT behind ai-core's MDT layer (server side). */
|
|
28
|
+
export interface MdtAdapter {
|
|
29
|
+
resource: string;
|
|
30
|
+
/** The version the adapter is written for; ai-core warns when another one runs. */
|
|
31
|
+
version?: string;
|
|
32
|
+
/** Writes a record; false when the MDT has no such record kind. Absent = the MDT takes no records from scripts. */
|
|
33
|
+
record?(entry: MdtEntry): boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** An MDT's client half: opens its screen for the local player. */
|
|
37
|
+
export interface MdtClientAdapter {
|
|
38
|
+
resource: string;
|
|
39
|
+
/** False when it could not open (the MDT checks the player's job itself). */
|
|
40
|
+
open(): boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const KINDS: readonly string[] = ["fine", "warrant", "arrest", "jail"];
|
|
44
|
+
const id = (v: unknown): number | undefined =>
|
|
45
|
+
typeof v === "number" && Number.isInteger(v) && v > 0 ? v : undefined;
|
|
46
|
+
const whole = (v: unknown, max: number): number | undefined =>
|
|
47
|
+
typeof v === "number" && Number.isSafeInteger(v) && v > 0 && v <= max
|
|
48
|
+
? v
|
|
49
|
+
: undefined;
|
|
50
|
+
|
|
51
|
+
/** A record from untrusted input (another resource's export call); null when it is not valid. */
|
|
52
|
+
export function toMdtRecord(value: unknown): MdtRecord | null {
|
|
53
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
54
|
+
return null;
|
|
55
|
+
const v = value as Record<string, unknown>;
|
|
56
|
+
const target = id(v.target);
|
|
57
|
+
const title =
|
|
58
|
+
typeof v.title === "string" && v.title.trim()
|
|
59
|
+
? v.title.trim().slice(0, 120)
|
|
60
|
+
: undefined;
|
|
61
|
+
if (!KINDS.includes(String(v.kind)) || target === undefined || !title)
|
|
62
|
+
return null;
|
|
63
|
+
return {
|
|
64
|
+
kind: v.kind as MdtRecordKind,
|
|
65
|
+
target,
|
|
66
|
+
by: id(v.by),
|
|
67
|
+
title,
|
|
68
|
+
amount: whole(v.amount, 10_000_000),
|
|
69
|
+
minutes: whole(v.minutes, 100_000),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** ai-core's MDT exports (server): whatever MDT runs (none: null / false). */
|
|
74
|
+
export type MdtServerExports = {
|
|
75
|
+
GetMdtSystem(): string | null;
|
|
76
|
+
/** Writes a record into the active MDT; false when it is invalid, no MDT runs or it takes no such record. */
|
|
77
|
+
AddMdtRecord(record: MdtRecord): boolean;
|
|
78
|
+
};
|
package/src/medical.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** One death / ambulance script behind ai-core's medical layer (`resource/server/medical/`). */
|
|
2
|
+
export interface MedicalAdapter {
|
|
3
|
+
resource: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
/** False when the player was not down. */
|
|
6
|
+
revive(source: number): boolean;
|
|
7
|
+
heal(source: number): void;
|
|
8
|
+
isDead(source: number): boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** A death script's client half for ai-core's client medical layer. */
|
|
12
|
+
export interface MedicalClientAdapter {
|
|
13
|
+
resource: string;
|
|
14
|
+
/** The local player is down (dead or last stand). */
|
|
15
|
+
isDead(): boolean;
|
|
16
|
+
/** Calls `changed` when that may have changed (a state bag, player data); registered once at start. */
|
|
17
|
+
watch(changed: () => void): void;
|
|
18
|
+
}
|
package/src/menu.ts
ADDED
|
@@ -0,0 +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;
|
package/src/minigame.ts
ADDED
|
@@ -0,0 +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
|
+
}
|
package/src/multichar.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ActionResult } from "./action";
|
|
2
|
+
import type { Sex } from "./player";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Which character of the player's own account to load: its character id, its slot (ESX `char<slot>`) or its citizen
|
|
6
|
+
* id (QB / Qbox). Another account's character is never found.
|
|
7
|
+
*/
|
|
8
|
+
export type CharacterRef = number | { slot: number } | { citizenid: string };
|
|
9
|
+
|
|
10
|
+
/** A new character from an external character screen; checked like ai-core's create form. */
|
|
11
|
+
export interface ScriptCharacterInput {
|
|
12
|
+
firstname: string;
|
|
13
|
+
lastname: string;
|
|
14
|
+
/** YYYY-MM-DD */
|
|
15
|
+
birthdate: string;
|
|
16
|
+
sex: Sex;
|
|
17
|
+
/** Empty when left out. */
|
|
18
|
+
nationality?: string;
|
|
19
|
+
/** The first free slot when left out; refused past the account's slot limit. */
|
|
20
|
+
slot?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Login entry points for an external character screen (a multichar script through the ESX / QB / Qbox bridge). Each
|
|
25
|
+
* answers once through `done` (`{ ok }` or a `CHAR_ERR_*` lang key); no promise crosses a resource boundary.
|
|
26
|
+
*/
|
|
27
|
+
export type MulticharServerExports = {
|
|
28
|
+
/** "ai-core" (its own screen) or the resource name of the external character screen that runs. */
|
|
29
|
+
GetCharacterScreen(): string;
|
|
30
|
+
/** Loads a character of the player's own account (the player has none loaded). */
|
|
31
|
+
LoginCharacter(
|
|
32
|
+
source: number,
|
|
33
|
+
character: CharacterRef,
|
|
34
|
+
done?: (result: ActionResult) => void,
|
|
35
|
+
): void;
|
|
36
|
+
/** Creates a character on the player's account (slot limit, form rules) and loads it. */
|
|
37
|
+
CreateAndLoginCharacter(
|
|
38
|
+
source: number,
|
|
39
|
+
input: ScriptCharacterInput,
|
|
40
|
+
done?: (result: ActionResult) => void,
|
|
41
|
+
): void;
|
|
42
|
+
/** Lets go of the loaded character (saved, `playerUnloaded` "switch"); the external screen shows itself again. */
|
|
43
|
+
LogoutCharacter(source: number, done?: (result: ActionResult) => void): void;
|
|
44
|
+
};
|
package/src/phone.ts
ADDED
|
@@ -0,0 +1,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
|
+
/** ai-core's phone exports: whatever phone script runs answers (none: null / false). */
|
|
31
|
+
export type PhoneServerExports = {
|
|
32
|
+
GetPhoneNumber(source: number): string | null;
|
|
33
|
+
GetSourceByPhone(number: string): number | null;
|
|
34
|
+
HasPhone(source: number): boolean;
|
|
35
|
+
/** `to`: a player's server id or a phone number. */
|
|
36
|
+
SendPhoneMail(to: number | string, mail: PhoneMail): boolean;
|
|
37
|
+
SendPhoneMessage(from: string, to: number | string, text: string): boolean;
|
|
38
|
+
PhoneNotify(source: number, notification: PhoneNotification): boolean;
|
|
39
|
+
};
|
package/src/player.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/** Player and character contracts shared by ai-core, its NUI and other resources. */
|
|
2
|
+
|
|
3
|
+
export type Sex = "male" | "female";
|
|
4
|
+
|
|
5
|
+
/** A character as other resources see it. */
|
|
6
|
+
export interface CharacterInfo {
|
|
7
|
+
id: number;
|
|
8
|
+
citizenid: string;
|
|
9
|
+
slot: number;
|
|
10
|
+
firstname: string;
|
|
11
|
+
lastname: string;
|
|
12
|
+
birthdate: string;
|
|
13
|
+
sex: Sex;
|
|
14
|
+
/** Free text ("American"); "" for characters made before the field existed. QB `charinfo.nationality`. */
|
|
15
|
+
nationality: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** A card on the character screen. */
|
|
19
|
+
export interface CharacterCard extends CharacterInfo {
|
|
20
|
+
/** Already in the game on another client of the same account. */
|
|
21
|
+
online: boolean;
|
|
22
|
+
/** Primary job label, for the card. */
|
|
23
|
+
job: string | null;
|
|
24
|
+
cash: number;
|
|
25
|
+
bank: number;
|
|
26
|
+
lastPlayed: number | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ScenePoint {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
z: number;
|
|
33
|
+
heading: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** One place in the character screen scene: a character stands there, the camera frames it when it is picked. */
|
|
37
|
+
export interface SceneSpot {
|
|
38
|
+
/** The ped's position (its root, as `GetEntityCoords` reads it) and heading. */
|
|
39
|
+
ped: ScenePoint;
|
|
40
|
+
/** Idle animation dictionary and clip ("" = none). */
|
|
41
|
+
anim: string;
|
|
42
|
+
clip: string;
|
|
43
|
+
/** Metres from the look-at point to the camera. */
|
|
44
|
+
camDistance: number;
|
|
45
|
+
/** Camera height as a slope (0 = level with the look-at point, 0.5 = up by half the distance). */
|
|
46
|
+
camHeight: number;
|
|
47
|
+
/** Degrees around the ped from its front (0 = straight in front). */
|
|
48
|
+
camAngle: number;
|
|
49
|
+
/** Metres above the ped's root the camera looks at. */
|
|
50
|
+
targetHeight: number;
|
|
51
|
+
/** Degrees the camera slowly swings left and right (0 = still). */
|
|
52
|
+
sway: number;
|
|
53
|
+
/** Background blur (depth of field): in focus from `blurNear` to `blurFar` metres, strength 0-100. */
|
|
54
|
+
blur: boolean;
|
|
55
|
+
blurNear: number;
|
|
56
|
+
blurFar: number;
|
|
57
|
+
blurStrength: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The in-world scene behind the character screen (panel setting). */
|
|
61
|
+
export interface CharacterScene {
|
|
62
|
+
/** Camera field of view in degrees. */
|
|
63
|
+
fov: number;
|
|
64
|
+
/** Local time and weather while the screen is open (`enabled: false` keeps the server's). */
|
|
65
|
+
time: { enabled: boolean; hour: number; minute: number; weather: string };
|
|
66
|
+
/** Spot N holds the character of slot N. */
|
|
67
|
+
spots: SceneSpot[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The server's name and look on full-screen menus (panel setting). */
|
|
71
|
+
export interface Branding {
|
|
72
|
+
name: string;
|
|
73
|
+
subtitle: string;
|
|
74
|
+
tagline: string;
|
|
75
|
+
taglineSub: string;
|
|
76
|
+
/** Background image of full-screen menus (files in ai-core's web/public/backgrounds); the character screen shows it only when its scene cannot be built. */
|
|
77
|
+
background: "skyline" | "wet-drive";
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface CharacterScreen {
|
|
81
|
+
branding: Branding;
|
|
82
|
+
slots: number;
|
|
83
|
+
characters: CharacterCard[];
|
|
84
|
+
canDelete: boolean;
|
|
85
|
+
/** Where the characters stand and how the camera frames them (panel setting). */
|
|
86
|
+
scene: CharacterScene;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface CreateCharacterInput {
|
|
90
|
+
slot: number;
|
|
91
|
+
firstname: string;
|
|
92
|
+
lastname: string;
|
|
93
|
+
/** YYYY-MM-DD */
|
|
94
|
+
birthdate: string;
|
|
95
|
+
sex: Sex;
|
|
96
|
+
nationality: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Answer of the character screen actions: `ok`, or a lang key telling why not. */
|
|
100
|
+
export type CharacterActionResult = import("./action").ActionResult;
|
|
101
|
+
|
|
102
|
+
export interface JobMembership {
|
|
103
|
+
job: string;
|
|
104
|
+
grade: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface GangMembership {
|
|
108
|
+
gang: string;
|
|
109
|
+
grade: number;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface SpawnPoint {
|
|
113
|
+
x: number;
|
|
114
|
+
y: number;
|
|
115
|
+
z: number;
|
|
116
|
+
heading: number;
|
|
117
|
+
model: string;
|
|
118
|
+
/** Body armour 0-100 saved with the character (metadata `armor`). */
|
|
119
|
+
armour: number;
|
|
120
|
+
/** Ped health saved with the character (metadata `health`, GTA scale, above 100); 0 = keep the spawn's full health. */
|
|
121
|
+
health: number;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** The local player's often read values, kept by ai-core's one watcher (lib `cache`); `false` = none. */
|
|
125
|
+
export interface PlayerCache {
|
|
126
|
+
ped: number;
|
|
127
|
+
playerId: number;
|
|
128
|
+
serverId: number;
|
|
129
|
+
vehicle: number | false;
|
|
130
|
+
/** Seat in `vehicle` (-1 driver). */
|
|
131
|
+
seat: number | false;
|
|
132
|
+
/** Weapon hash in hand; `false` when unarmed. */
|
|
133
|
+
weapon: number | false;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** What ai-core pushes to a player's own client: one snapshot at load, then `(key, value)` deltas. */
|
|
137
|
+
export interface AiPlayerData {
|
|
138
|
+
character: CharacterInfo | null;
|
|
139
|
+
money: Record<string, number>;
|
|
140
|
+
jobs: JobMembership[];
|
|
141
|
+
duty: string | null;
|
|
142
|
+
/** The job other scripts see as "the" job: on duty, else last on duty, else the first, else unemployed. */
|
|
143
|
+
job: JobMembership;
|
|
144
|
+
gangs: GangMembership[];
|
|
145
|
+
activeGang: string | null;
|
|
146
|
+
/** The character's free-form metadata bag (framework bridges keep QB / ESX metadata here); patched per key. */
|
|
147
|
+
metadata: Record<string, unknown>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export type NotificationKind = "success" | "error" | "info" | "warning";
|
|
151
|
+
|
|
152
|
+
/** A notification card (ai-core draws it); texts are already translated by the sender. */
|
|
153
|
+
export interface Notification {
|
|
154
|
+
text: string;
|
|
155
|
+
title?: string;
|
|
156
|
+
kind: NotificationKind;
|
|
157
|
+
/** Milliseconds on screen (default 4000). */
|
|
158
|
+
duration?: number;
|
|
159
|
+
}
|
package/src/radial.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One item of the radial wheel as a script hands it to ai-core (lib `radial`). The functions run in the resource that
|
|
3
|
+
* added the item; ai-core drops the item when that resource stops.
|
|
4
|
+
*/
|
|
5
|
+
export interface RadialItem {
|
|
6
|
+
/** Unique id; adding an id again replaces the item. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** The text on the card (already translated). */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Font Awesome solid icon name without `fa-` (`car`, `key`), or an image url. */
|
|
11
|
+
icon?: string;
|
|
12
|
+
/** The item id this goes into (a sub menu: the built-in `vehicle`, or another item); left out = the main wheel. */
|
|
13
|
+
parent?: string;
|
|
14
|
+
/** Sub items: the card opens a sub menu (each item with its own `canShow` / `onPressed`). */
|
|
15
|
+
items?: RadialItem[];
|
|
16
|
+
/** Shown only while this returns true (job, duty, a vehicle, an item); read each time the wheel opens or refreshes. */
|
|
17
|
+
canShow?: () => boolean;
|
|
18
|
+
/** Runs when the player picks the item. */
|
|
19
|
+
onPressed?: () => void;
|
|
20
|
+
/** true keeps the wheel open after the press (doors, extras). */
|
|
21
|
+
keepOpen?: boolean;
|
|
22
|
+
/** true keeps the item while the player is down (every other item hides then). */
|
|
23
|
+
whileDead?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The radial built-in category vehicle items go into (`parent: RADIAL_VEHICLE`). */
|
|
27
|
+
export const RADIAL_VEHICLE = "vehicle";
|
|
28
|
+
|
|
29
|
+
/** ai-core's radial client exports (lib `radial`): items reach whichever radial menu runs. */
|
|
30
|
+
export type RadialClientExports = {
|
|
31
|
+
/** Adds or replaces an item of the calling resource (dropped when it stops). */
|
|
32
|
+
AddRadialItem(item: RadialItem): void;
|
|
33
|
+
RemoveRadialItem(id: string): void;
|
|
34
|
+
/** Reads every `canShow` of an open wheel again (call it after what they read changed). */
|
|
35
|
+
RefreshRadial(): void;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** One radial menu behind ai-core's radial layer (client): ai-core hands it every item scripts add. */
|
|
39
|
+
export interface RadialAdapter {
|
|
40
|
+
resource: string;
|
|
41
|
+
add(item: RadialItem): void;
|
|
42
|
+
remove(item: RadialItem): void;
|
|
43
|
+
refresh(): void;
|
|
44
|
+
}
|