@sagl/server 0.0.0-stage → 0.1.0-next.51
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/LICENSE +21 -0
- package/README.md +61 -2
- package/dist/actions.d.ts +46 -0
- package/dist/actions.js +80 -0
- package/dist/actions.js.map +1 -0
- package/dist/animations.d.ts +32 -0
- package/dist/animations.js +95 -0
- package/dist/animations.js.map +1 -0
- package/dist/audio.d.ts +180 -0
- package/dist/audio.js +353 -0
- package/dist/audio.js.map +1 -0
- package/dist/audio_effects.d.ts +219 -0
- package/dist/audio_effects.js +84 -0
- package/dist/audio_effects.js.map +1 -0
- package/dist/camera.d.ts +188 -0
- package/dist/camera.js +247 -0
- package/dist/camera.js.map +1 -0
- package/dist/claims.d.ts +27 -0
- package/dist/claims.js +48 -0
- package/dist/claims.js.map +1 -0
- package/dist/commands.d.ts +135 -0
- package/dist/commands.js +373 -0
- package/dist/commands.js.map +1 -0
- package/dist/console.d.ts +21 -0
- package/dist/console.js +100 -0
- package/dist/console.js.map +1 -0
- package/dist/constants.d.ts +654 -0
- package/dist/constants.js +657 -0
- package/dist/constants.js.map +1 -0
- package/dist/cutscene.d.ts +47 -0
- package/dist/cutscene.js +190 -0
- package/dist/cutscene.js.map +1 -0
- package/dist/draw.d.ts +106 -0
- package/dist/draw.js +132 -0
- package/dist/draw.js.map +1 -0
- package/dist/effects.d.ts +91 -0
- package/dist/effects.js +116 -0
- package/dist/effects.js.map +1 -0
- package/dist/gangzones.d.ts +47 -0
- package/dist/gangzones.js +122 -0
- package/dist/gangzones.js.map +1 -0
- package/dist/geo.d.ts +11 -0
- package/dist/geo.js +25 -0
- package/dist/geo.js.map +1 -0
- package/dist/hud.d.ts +159 -0
- package/dist/hud.js +247 -0
- package/dist/hud.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction.d.ts +81 -0
- package/dist/interaction.js +143 -0
- package/dist/interaction.js.map +1 -0
- package/dist/junctions.d.ts +1 -0
- package/dist/junctions.js +330 -0
- package/dist/junctions.js.map +1 -0
- package/dist/map.d.ts +55 -0
- package/dist/map.js +71 -0
- package/dist/map.js.map +1 -0
- package/dist/menu.d.ts +96 -0
- package/dist/menu.js +129 -0
- package/dist/menu.js.map +1 -0
- package/dist/mission.d.ts +482 -0
- package/dist/mission.js +1258 -0
- package/dist/mission.js.map +1 -0
- package/dist/models.d.ts +56 -0
- package/dist/models.js +71 -0
- package/dist/models.js.map +1 -0
- package/dist/modshop.d.ts +229 -0
- package/dist/modshop.js +904 -0
- package/dist/modshop.js.map +1 -0
- package/dist/modshop_data.d.ts +44 -0
- package/dist/modshop_data.js +287 -0
- package/dist/modshop_data.js.map +1 -0
- package/dist/native.d.ts +809 -0
- package/dist/native.js +27 -0
- package/dist/native.js.map +1 -0
- package/dist/objects.d.ts +249 -0
- package/dist/objects.js +455 -0
- package/dist/objects.js.map +1 -0
- package/dist/paint.d.ts +124 -0
- package/dist/paint.js +84 -0
- package/dist/paint.js.map +1 -0
- package/dist/paynspray.d.ts +44 -0
- package/dist/paynspray.js +177 -0
- package/dist/paynspray.js.map +1 -0
- package/dist/ped.d.ts +335 -0
- package/dist/ped.js +536 -0
- package/dist/ped.js.map +1 -0
- package/dist/player.d.ts +685 -0
- package/dist/player.js +1163 -0
- package/dist/player.js.map +1 -0
- package/dist/screeneffects.d.ts +99 -0
- package/dist/screeneffects.js +257 -0
- package/dist/screeneffects.js.map +1 -0
- package/dist/scripts.d.ts +69 -0
- package/dist/scripts.js +125 -0
- package/dist/scripts.js.map +1 -0
- package/dist/server.d.ts +713 -0
- package/dist/server.js +1080 -0
- package/dist/server.js.map +1 -0
- package/dist/shopblips.d.ts +9 -0
- package/dist/shopblips.js +30 -0
- package/dist/shopblips.js.map +1 -0
- package/dist/special.d.ts +33 -0
- package/dist/special.js +26 -0
- package/dist/special.js.map +1 -0
- package/dist/splash.d.ts +42 -0
- package/dist/splash.js +55 -0
- package/dist/splash.js.map +1 -0
- package/dist/text.d.ts +19 -0
- package/dist/text.js +25 -0
- package/dist/text.js.map +1 -0
- package/dist/ui.d.ts +141 -0
- package/dist/ui.js +243 -0
- package/dist/ui.js.map +1 -0
- package/dist/vehicle.d.ts +306 -0
- package/dist/vehicle.js +612 -0
- package/dist/vehicle.js.map +1 -0
- package/dist/vehiclecolors.d.ts +26 -0
- package/dist/vehiclecolors.js +49 -0
- package/dist/vehiclecolors.js.map +1 -0
- package/dist/world.d.ts +222 -0
- package/dist/world.js +227 -0
- package/dist/world.js.map +1 -0
- package/dist/zone.d.ts +89 -0
- package/dist/zone.js +140 -0
- package/dist/zone.js.map +1 -0
- package/package.json +33 -4
package/dist/menu.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
const clean = (s) => s.replace(/[\n\t]/g, " ");
|
|
2
|
+
/** @internal Hints as sent ("" the default, "-" none). */
|
|
3
|
+
export function menuHints(hints) {
|
|
4
|
+
if (!hints)
|
|
5
|
+
return "";
|
|
6
|
+
if (!hints.length)
|
|
7
|
+
return "-";
|
|
8
|
+
return hints.map((h) => `${clean(h.key)}\t${clean(h.label)}`).join("\n");
|
|
9
|
+
}
|
|
10
|
+
/** @internal A row as sent: text, tab, value, tab, swatch. */
|
|
11
|
+
export function menuRow(r) {
|
|
12
|
+
if (typeof r === "string")
|
|
13
|
+
return clean(r);
|
|
14
|
+
if (Array.isArray(r))
|
|
15
|
+
return `${clean(r[0])}\t${clean(r[1])}`;
|
|
16
|
+
const swatch = r.swatch === undefined ? "" : `\t${(r.swatch & 0xffffff).toString(16).padStart(6, "0")}`;
|
|
17
|
+
return `${clean(r.text)}\t${clean(r.value ?? "")}${swatch}`;
|
|
18
|
+
}
|
|
19
|
+
const MAX_ROWS = 4095; // bytes, as sent
|
|
20
|
+
/** @internal The menu showing on one player (one at a time). */
|
|
21
|
+
export class PlayerMenus {
|
|
22
|
+
#native;
|
|
23
|
+
#player;
|
|
24
|
+
#next = 1;
|
|
25
|
+
current = null;
|
|
26
|
+
constructor(native, player) {
|
|
27
|
+
this.#native = native;
|
|
28
|
+
this.#player = player;
|
|
29
|
+
}
|
|
30
|
+
open(options) {
|
|
31
|
+
this.current?.markClosed();
|
|
32
|
+
const id = this.#next;
|
|
33
|
+
this.#next = (this.#next % 0x7fffffff) + 1;
|
|
34
|
+
const menu = new PlayerMenu(this, id, options);
|
|
35
|
+
this.current = menu;
|
|
36
|
+
menu.send();
|
|
37
|
+
return menu;
|
|
38
|
+
}
|
|
39
|
+
send(spec) {
|
|
40
|
+
this.#native.gameMenu(this.#player, spec);
|
|
41
|
+
}
|
|
42
|
+
heard(id, kind, row) {
|
|
43
|
+
const menu = this.current;
|
|
44
|
+
if (!menu || menu.id !== id)
|
|
45
|
+
return;
|
|
46
|
+
menu.heard(kind, row);
|
|
47
|
+
}
|
|
48
|
+
/** Gone (they left, or the server reset them): no more events. */
|
|
49
|
+
forget() {
|
|
50
|
+
this.current?.markClosed();
|
|
51
|
+
this.current = null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A menu on a player's screen, as the game's shops have (and SA-MP's
|
|
56
|
+
* menus): a box at the top left with a title and rows, one chosen. They
|
|
57
|
+
* move with Up/Down, select with Enter and go back with Backspace or
|
|
58
|
+
* Escape. One at a time: opening another replaces it. See `player.menu`.
|
|
59
|
+
*/
|
|
60
|
+
export class PlayerMenu {
|
|
61
|
+
id;
|
|
62
|
+
#menus;
|
|
63
|
+
#o;
|
|
64
|
+
#row;
|
|
65
|
+
#open = true;
|
|
66
|
+
/** @internal */
|
|
67
|
+
constructor(menus, id, options) {
|
|
68
|
+
this.#menus = menus;
|
|
69
|
+
this.id = id;
|
|
70
|
+
this.#o = { ...options };
|
|
71
|
+
this.#row = options.row ?? 0;
|
|
72
|
+
}
|
|
73
|
+
/** The row chosen. */
|
|
74
|
+
get row() {
|
|
75
|
+
return this.#row;
|
|
76
|
+
}
|
|
77
|
+
/** Still on their screen. */
|
|
78
|
+
get isOpen() {
|
|
79
|
+
return this.#open;
|
|
80
|
+
}
|
|
81
|
+
/** Changes what it shows (rows, title, footer, hints, the row chosen), in place. */
|
|
82
|
+
update(changes) {
|
|
83
|
+
if (!this.#open)
|
|
84
|
+
return this;
|
|
85
|
+
Object.assign(this.#o, changes);
|
|
86
|
+
if (changes.row !== undefined)
|
|
87
|
+
this.#row = changes.row;
|
|
88
|
+
this.#row = Math.max(0, Math.min(this.#row, this.#o.rows.length - 1));
|
|
89
|
+
this.send();
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
/** Takes it off their screen. */
|
|
93
|
+
close() {
|
|
94
|
+
if (!this.#open)
|
|
95
|
+
return;
|
|
96
|
+
this.markClosed();
|
|
97
|
+
if (this.#menus.current === this)
|
|
98
|
+
this.#menus.current = null;
|
|
99
|
+
this.#menus.send({ id: this.id, hide: true });
|
|
100
|
+
}
|
|
101
|
+
/** @internal */
|
|
102
|
+
markClosed() {
|
|
103
|
+
this.#open = false;
|
|
104
|
+
}
|
|
105
|
+
/** @internal */
|
|
106
|
+
send() {
|
|
107
|
+
const rows = this.#o.rows.map(menuRow).join("\n");
|
|
108
|
+
if (Buffer.byteLength(rows) > MAX_ROWS)
|
|
109
|
+
throw new RangeError(`menu rows too long (${Buffer.byteLength(rows)} bytes, at most ${MAX_ROWS})`);
|
|
110
|
+
this.#menus.send({
|
|
111
|
+
id: this.id, title: this.#o.title ?? "", rows, row: this.#row, footer: menuRow(this.#o.footer ?? ""), hints: menuHints(this.#o.hints),
|
|
112
|
+
columns: this.#o.columns ?? 0, image: this.#o.image ?? "",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** @internal */
|
|
116
|
+
heard(kind, row) {
|
|
117
|
+
if (!this.#open)
|
|
118
|
+
return;
|
|
119
|
+
if (row >= 0 && row < this.#o.rows.length)
|
|
120
|
+
this.#row = row;
|
|
121
|
+
if (kind === 0)
|
|
122
|
+
this.#o.onChoose?.(this.#row, this);
|
|
123
|
+
else if (kind === 1)
|
|
124
|
+
this.#o.onSelect?.(this.#row, this);
|
|
125
|
+
else if (kind === 2)
|
|
126
|
+
this.#o.onBack?.(this);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=menu.js.map
|
package/dist/menu.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAcA,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AAEvD,0DAA0D;AAC1D,MAAM,UAAU,SAAS,CAAC,KAA6B;IACrD,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,GAAG,CAAC;IAC9B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3E,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,OAAO,CAAC,CAAU;IAChC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9D,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC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E,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE;SAC1D,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB;IAChB,KAAK,CAAC,IAAY,EAAE,GAAW;QAC7B,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO;QACxB,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM;YAAE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAC3D,IAAI,IAAI,KAAK,CAAC;YAAE,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aAC/C,IAAI,IAAI,KAAK,CAAC;YAAE,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aACpD,IAAI,IAAI,KAAK,CAAC;YAAE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
import type { BlipOptions, HudCounter } from "./hud.js";
|
|
2
|
+
import type { MapColor } from "./map.js";
|
|
3
|
+
import type { Ped } from "./ped.js";
|
|
4
|
+
import type { Player, Vector3 } from "./player.js";
|
|
5
|
+
import type { PedOptions, Server, ServerEvents, VehicleOptions } from "./server.js";
|
|
6
|
+
import type { CameraShot } from "./camera.js";
|
|
7
|
+
import type { SpeakOptions } from "./audio.js";
|
|
8
|
+
import type { Population } from "./world.js";
|
|
9
|
+
import type { CutsceneOptions, CutsceneResult } from "./cutscene.js";
|
|
10
|
+
import type { GameObject, ObjectOptions, Pickup, PickupOptions, Rotation } from "./objects.js";
|
|
11
|
+
import type { Vehicle } from "./vehicle.js";
|
|
12
|
+
/**
|
|
13
|
+
* What happens to something the mission made when it ends: `"release"`
|
|
14
|
+
* (the default: left to the game's cleanup), `"destroy"` (gone at once),
|
|
15
|
+
* `"keep"` (left for good).
|
|
16
|
+
*/
|
|
17
|
+
export type OnEnd = "release" | "destroy" | "keep";
|
|
18
|
+
export interface EndOptions {
|
|
19
|
+
onEnd?: OnEnd;
|
|
20
|
+
/** As `onEnd: "keep"`. */
|
|
21
|
+
keep?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A mission: what it's called, who may play it, and its script. Pass it to
|
|
25
|
+
* `server.missions.start()` or `server.missions.marker()`.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* A named step of a mission (`steps`): run in order, each a checkpoint the
|
|
29
|
+
* mission can be started from (`server.missions.start(def, players, { from })`).
|
|
30
|
+
* Starting from a step runs its `setup` first: whatever earlier steps would
|
|
31
|
+
* have left behind (a ped in a car, the party somewhere), into the state.
|
|
32
|
+
*/
|
|
33
|
+
export interface MissionStep<S> {
|
|
34
|
+
name: string;
|
|
35
|
+
/** Only when the mission starts from this step. */
|
|
36
|
+
setup?: (m: Mission, s: S) => Promise<void> | void;
|
|
37
|
+
run: (m: Mission, s: S) => Promise<void> | void;
|
|
38
|
+
}
|
|
39
|
+
export interface MissionDefinition<S = any> {
|
|
40
|
+
/** Shown nowhere by itself; used for cooldowns and `missionEvent`. */
|
|
41
|
+
name: string;
|
|
42
|
+
/** Party size. Default 1. */
|
|
43
|
+
maxPlayers?: number;
|
|
44
|
+
/** After a pass, the same player can't start it again for this long (ms). */
|
|
45
|
+
cooldown?: number;
|
|
46
|
+
/** A pass sooner than this after the start (ms) is refused, with no reward. */
|
|
47
|
+
minDuration?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Checked for each player when they start or join it, and again on pass.
|
|
50
|
+
* Return a reason (shown to them) to refuse, or nothing to allow.
|
|
51
|
+
*/
|
|
52
|
+
requires?: (player: Player) => string | void | undefined | null | false;
|
|
53
|
+
/** One player dying fails it for everyone. Default false: they respawn at the section start. */
|
|
54
|
+
deathFails?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* How far (m) from a new section's start a player can be before they're
|
|
57
|
+
* faded out and brought there. Default 150.
|
|
58
|
+
*/
|
|
59
|
+
catchUpDistance?: number;
|
|
60
|
+
/**
|
|
61
|
+
* The mission's script. When it returns without `pass()` or `fail()`, the
|
|
62
|
+
* mission passes. Or `steps` instead.
|
|
63
|
+
*/
|
|
64
|
+
run?(m: Mission): Promise<void> | void;
|
|
65
|
+
/**
|
|
66
|
+
* Or the script as named steps, run in order, sharing `state()` (made
|
|
67
|
+
* fresh for each run). Each step is a checkpoint: the mission can be
|
|
68
|
+
* started from it (testing), and `m.stage` is logged as it starts.
|
|
69
|
+
*/
|
|
70
|
+
steps?: MissionStep<S>[];
|
|
71
|
+
state?: () => S;
|
|
72
|
+
}
|
|
73
|
+
/** Defines a mission (it only adds types). */
|
|
74
|
+
export declare function defineMission<S = any>(definition: MissionDefinition<S>): MissionDefinition<S>;
|
|
75
|
+
export type MissionEndReason = "passed" | "failed" | "abandoned" | "tooFast" | "requirements" | "error";
|
|
76
|
+
export interface MissionOutcome {
|
|
77
|
+
passed: boolean;
|
|
78
|
+
reason: MissionEndReason;
|
|
79
|
+
/** The fail reason, or the pass subtitle. */
|
|
80
|
+
text: string;
|
|
81
|
+
/** Who was in it at the end. */
|
|
82
|
+
players: Player[];
|
|
83
|
+
ms: number;
|
|
84
|
+
}
|
|
85
|
+
/** What `server.on("missionEvent")` gets: every start, join, leave, pass, fail and refusal. */
|
|
86
|
+
export interface MissionEvent {
|
|
87
|
+
/** `"stage"`: the script reached a stage or step (`m.stage`), its name in `reason`. */
|
|
88
|
+
type: "start" | "join" | "leave" | "pass" | "fail" | "refused" | "stage";
|
|
89
|
+
name: string;
|
|
90
|
+
mission: Mission | null;
|
|
91
|
+
/** The player who joined, left or was refused. */
|
|
92
|
+
player: Player | null;
|
|
93
|
+
/** Why it failed or was refused. */
|
|
94
|
+
reason: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Thrown into the script's pending waits when the mission ends (a fail
|
|
98
|
+
* condition, every player leaving, ...). The helper catches it: let it go.
|
|
99
|
+
*/
|
|
100
|
+
export declare class MissionEnded extends Error {
|
|
101
|
+
readonly outcome: MissionOutcome;
|
|
102
|
+
constructor(outcome: MissionOutcome);
|
|
103
|
+
}
|
|
104
|
+
/** Starting or joining a mission was refused. `reason` says why. */
|
|
105
|
+
export declare class MissionRefused extends Error {
|
|
106
|
+
readonly reason: string;
|
|
107
|
+
constructor(reason: string);
|
|
108
|
+
}
|
|
109
|
+
export interface WaitOptions {
|
|
110
|
+
/** The first player completes it for everyone (the default). */
|
|
111
|
+
anyPlayer?: boolean;
|
|
112
|
+
/** A waiting point: every player in the party must do it. */
|
|
113
|
+
allPlayers?: boolean;
|
|
114
|
+
}
|
|
115
|
+
export interface ReachOptions extends WaitOptions {
|
|
116
|
+
/** Default 3 m. */
|
|
117
|
+
radius?: number;
|
|
118
|
+
/** They must be in this vehicle (driving or riding). */
|
|
119
|
+
vehicle?: Vehicle;
|
|
120
|
+
/** Show the spot with a blip and the game's marker while it's waited for. Default true. */
|
|
121
|
+
marker?: boolean | BlipOptions;
|
|
122
|
+
}
|
|
123
|
+
export interface SectionOptions {
|
|
124
|
+
/** Where it starts: one spot, or one per party member (in party order). */
|
|
125
|
+
at: Vector3 | Vector3[];
|
|
126
|
+
/** Degrees. */
|
|
127
|
+
heading?: number;
|
|
128
|
+
/** Override the mission's `catchUpDistance`. */
|
|
129
|
+
catchUpDistance?: number;
|
|
130
|
+
}
|
|
131
|
+
/** A blip every party member has, players who join later included. */
|
|
132
|
+
export declare class MissionBlip {
|
|
133
|
+
#private;
|
|
134
|
+
/** @internal */
|
|
135
|
+
constructor(target: Parameters<Player["hud"]["blip"]>[0], options: BlipOptions);
|
|
136
|
+
/** Changes its options. */
|
|
137
|
+
set(options: BlipOptions): this;
|
|
138
|
+
remove(): void;
|
|
139
|
+
/** @internal */
|
|
140
|
+
add(player: Player): void;
|
|
141
|
+
/** @internal */
|
|
142
|
+
drop(player: Player): void;
|
|
143
|
+
get removed(): boolean;
|
|
144
|
+
}
|
|
145
|
+
/** A HUD counter or timer every party member has. */
|
|
146
|
+
export declare class MissionCounter {
|
|
147
|
+
#private;
|
|
148
|
+
/** @internal */
|
|
149
|
+
constructor(label: string, value: number, endsAt: number | null, make: (p: Player, label: string, value: number) => HudCounter);
|
|
150
|
+
/** The number (a counter), the time left (a timer, ms), or how full (a bar). */
|
|
151
|
+
get value(): number;
|
|
152
|
+
/** A timer: whether it's held still (`pause()`). */
|
|
153
|
+
get paused(): boolean;
|
|
154
|
+
/** Holds a timer still (it doesn't run out meanwhile); `resume()` counts on from there. */
|
|
155
|
+
pause(): void;
|
|
156
|
+
resume(): void;
|
|
157
|
+
/** @internal Is it a timer (counting down or up)? */
|
|
158
|
+
get isTimer(): boolean;
|
|
159
|
+
set value(value: number);
|
|
160
|
+
set label(label: string);
|
|
161
|
+
remove(): void;
|
|
162
|
+
get removed(): boolean;
|
|
163
|
+
/** @internal */
|
|
164
|
+
add(player: Player): void;
|
|
165
|
+
/** @internal */
|
|
166
|
+
drop(player: Player): void;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* A running mission: its party, what it created (removed when it ends), its
|
|
170
|
+
* HUD, fail conditions and waits. The script gets it as `m`.
|
|
171
|
+
*
|
|
172
|
+
* Every wait (`reach`, `until`, `wait`, `step`, ...) rejects with
|
|
173
|
+
* `MissionEnded` when the mission ends, so the script stops where it is;
|
|
174
|
+
* the helper catches it. Mission calls made after the end throw it too.
|
|
175
|
+
*/
|
|
176
|
+
export declare class Mission {
|
|
177
|
+
#private;
|
|
178
|
+
readonly name: string;
|
|
179
|
+
readonly definition: MissionDefinition;
|
|
180
|
+
/** Free-form storage for the script. */
|
|
181
|
+
readonly data: Record<string, unknown>;
|
|
182
|
+
/** When it started (Date.now()). */
|
|
183
|
+
readonly startedAt: number;
|
|
184
|
+
/** Resolves when it ends, passed or not (never rejects). */
|
|
185
|
+
readonly done: Promise<MissionOutcome>;
|
|
186
|
+
/** @internal */
|
|
187
|
+
constructor(missions: Missions, server: Server, definition: MissionDefinition, players: Player[]);
|
|
188
|
+
/** The party, leader first. */
|
|
189
|
+
get players(): readonly Player[];
|
|
190
|
+
/** Who started it, or the next in line once they leave. */
|
|
191
|
+
get leader(): Player;
|
|
192
|
+
/** Whether it's still running. */
|
|
193
|
+
get running(): boolean;
|
|
194
|
+
/** How it ended, or null while it runs. */
|
|
195
|
+
get outcome(): MissionOutcome | null;
|
|
196
|
+
/**
|
|
197
|
+
* Adds a player to the party (an invitation). They get its HUD and see its
|
|
198
|
+
* peds. Throws `MissionRefused` if they're in another mission, it's full,
|
|
199
|
+
* they don't meet `requires`, or they're cooling down.
|
|
200
|
+
*/
|
|
201
|
+
addPlayer(player: Player): void;
|
|
202
|
+
/** Takes a player out of the party (their HUD for it goes). The last one leaving abandons it. */
|
|
203
|
+
removePlayer(player: Player): void;
|
|
204
|
+
/**
|
|
205
|
+
* A ped for the mission. When it ends, it fades out, or if it's dead its
|
|
206
|
+
* body is released (`ped.release()`: it lies there until the cleanup
|
|
207
|
+
* takes it); with `keep` it stays for good. Seen by the party (players joining later
|
|
208
|
+
* too) unless `visibleTo` says otherwise.
|
|
209
|
+
*/
|
|
210
|
+
createPed(model: number | string, position: Vector3, heading?: number, options?: PedOptions & EndOptions): Ped;
|
|
211
|
+
/**
|
|
212
|
+
* A vehicle for the mission, released when it ends (it stays until nobody
|
|
213
|
+
* is around, as the game's), `onEnd: "destroy"` removed at once, or
|
|
214
|
+
* `onEnd: "keep"` (or `keep`) left for good.
|
|
215
|
+
*/
|
|
216
|
+
createVehicle(model: number, position: Vector3, heading?: number, options?: VehicleOptions & EndOptions): Vehicle;
|
|
217
|
+
/** An object for the mission (the party sees it), removed when it ends. See `server.createObject`. */
|
|
218
|
+
createObject(model: number, position: Vector3, rotation?: Rotation, options?: ObjectOptions): GameObject;
|
|
219
|
+
/** A pickup for the mission (the party sees it), removed when it ends. See `server.createPickup`. */
|
|
220
|
+
createPickup(options: PickupOptions): Pickup;
|
|
221
|
+
/** Objective text at the bottom of the party's screens, for `ms` (left out: as long as reading takes). */
|
|
222
|
+
objective(text: string, ms?: number): void;
|
|
223
|
+
clearObjective(): void;
|
|
224
|
+
/** Big text in the middle of the party's screens. */
|
|
225
|
+
bigText(text: string, ms?: number): void;
|
|
226
|
+
/** A blip (and marker) on a spot, ped, vehicle or player, for the whole party. */
|
|
227
|
+
blip(target: Vector3 | Ped | Vehicle | Player, options?: BlipOptions): MissionBlip;
|
|
228
|
+
/** A counter on the party's HUD ("Crates 2/6"). */
|
|
229
|
+
counter(label: string, options?: {
|
|
230
|
+
value?: number;
|
|
231
|
+
max?: number;
|
|
232
|
+
bar?: boolean;
|
|
233
|
+
color?: MapColor;
|
|
234
|
+
}): MissionCounter;
|
|
235
|
+
/**
|
|
236
|
+
* A countdown on the party's HUD (or counting up with `countUp`). With
|
|
237
|
+
* `fail`, the mission fails with that reason when a countdown reaches 0.
|
|
238
|
+
*/
|
|
239
|
+
timer(label: string, ms: number, options?: {
|
|
240
|
+
countUp?: boolean;
|
|
241
|
+
color?: MapColor;
|
|
242
|
+
fail?: string;
|
|
243
|
+
}): MissionCounter;
|
|
244
|
+
/**
|
|
245
|
+
* While anyone in the party is wanted, the mission's timers stand still
|
|
246
|
+
* and `message` stays as the objective (default "Lose the ~r~cops~w~.");
|
|
247
|
+
* once they're all clear, the timers run on and the objective is back.
|
|
248
|
+
* For a mission that shouldn't be failed by a chase it didn't mean.
|
|
249
|
+
*
|
|
250
|
+
* ```ts
|
|
251
|
+
* m.holdWhileWanted();
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
holdWhileWanted(message?: string): void;
|
|
255
|
+
/**
|
|
256
|
+
* Fails it when `target` dies (a ped: `"died"`), is wrecked (a vehicle:
|
|
257
|
+
* `"wrecked"`), or is removed; or when `condition()` becomes true.
|
|
258
|
+
*/
|
|
259
|
+
failWhen(target: Ped, event: "died", reason: string): {
|
|
260
|
+
stop(): void;
|
|
261
|
+
};
|
|
262
|
+
failWhen(target: Vehicle, event: "wrecked", reason: string): {
|
|
263
|
+
stop(): void;
|
|
264
|
+
};
|
|
265
|
+
failWhen(condition: () => boolean, reason: string): {
|
|
266
|
+
stop(): void;
|
|
267
|
+
};
|
|
268
|
+
/** Fails it for everyone: "MISSION FAILED!" with `reason` under it. */
|
|
269
|
+
fail(reason?: string): void;
|
|
270
|
+
/**
|
|
271
|
+
* Passes it: each player gets `money` (once) and "MISSION PASSED!" with
|
|
272
|
+
* `text` under it (default: the money, as "$2500"). Refused, with no
|
|
273
|
+
* reward, if it's sooner than `minDuration` or a player doesn't meet
|
|
274
|
+
* `requires` any more.
|
|
275
|
+
*/
|
|
276
|
+
pass(reward?: {
|
|
277
|
+
money?: number;
|
|
278
|
+
text?: string;
|
|
279
|
+
}): void;
|
|
280
|
+
/** Resolves after `ms`. */
|
|
281
|
+
wait(ms: number): Promise<void>;
|
|
282
|
+
/**
|
|
283
|
+
* Resolves once `condition()` is true (checked four times a second), with
|
|
284
|
+
* `true`; with `timeout` (ms), with `false` if that passes first. A wait
|
|
285
|
+
* with a limit can't leave a scene stuck when something gets in the way.
|
|
286
|
+
*
|
|
287
|
+
* ```ts
|
|
288
|
+
* if (!await m.until(() => benny.vehicle === cab, { timeout: 8000 })) benny.putInVehicle(cab, 2);
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
until(condition: () => boolean, options?: {
|
|
292
|
+
timeout?: number;
|
|
293
|
+
}): Promise<boolean>;
|
|
294
|
+
/**
|
|
295
|
+
* Waits for any promise (a ped's order, ...) but rejects with
|
|
296
|
+
* `MissionEnded` if the mission ends first. With `timeout` (ms), resolves
|
|
297
|
+
* with `undefined` if that passes first (the promise is left to finish).
|
|
298
|
+
*
|
|
299
|
+
* ```ts
|
|
300
|
+
* await m.step(benny.walkTo(OUTSIDE, { pace: "run" }), { timeout: 4000 }); // knocked down: on anyway
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
step<T>(promise: Promise<T>): Promise<T>;
|
|
304
|
+
step<T>(promise: Promise<T>, options: {
|
|
305
|
+
timeout: number;
|
|
306
|
+
}): Promise<T | undefined>;
|
|
307
|
+
/**
|
|
308
|
+
* Listens to a server event while the mission runs: removed when it ends
|
|
309
|
+
* (however it ends), or earlier with the function it returns.
|
|
310
|
+
*
|
|
311
|
+
* ```ts
|
|
312
|
+
* m.on("playerExitVehicle", (player, vehicle) => { if (vehicle === getaway) ... });
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
on<E extends keyof ServerEvents>(event: E, listener: ServerEvents[E]): () => void;
|
|
316
|
+
/**
|
|
317
|
+
* Calls `fn` every `ms` while the mission runs (stopped when it ends, or
|
|
318
|
+
* with the function it returns). An error is logged, not fatal.
|
|
319
|
+
*/
|
|
320
|
+
every(ms: number, fn: () => void): () => void;
|
|
321
|
+
/**
|
|
322
|
+
* Changes the population (peds, traffic, police, fire...) of the leader's
|
|
323
|
+
* world until the mission ends (or the function it returns is called):
|
|
324
|
+
* then the settings it changed are as they were.
|
|
325
|
+
*
|
|
326
|
+
* ```ts
|
|
327
|
+
* const fireBack = m.population({ fire: false }); // no fire engines to the car we torch
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
population(settings: Partial<Population>): () => void;
|
|
331
|
+
/**
|
|
332
|
+
* A recorded line with its subtitles timed to it (as speech: the radio
|
|
333
|
+
* ducks under it), shown to the party. Resolves when it's been said;
|
|
334
|
+
* stopped if the mission ends. `at` a ped (or vehicle): from them; left
|
|
335
|
+
* out, at the party's ears (`effects: "phone"` for a caller).
|
|
336
|
+
*
|
|
337
|
+
* ```ts
|
|
338
|
+
* await m.say("audio/voice-call2.mp3", { effects: "phone", subtitle: VOICE.call2, prefix: "~y~" });
|
|
339
|
+
* await m.say("audio/benny-my-car.mp3", { at: benny, subtitle: "My car! That's my car!" });
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
say(file: string, options?: SpeakOptions): Promise<void>;
|
|
343
|
+
/**
|
|
344
|
+
* A cinematic shot for the party (or `players`): black bars, the camera
|
|
345
|
+
* on `shot`, everyone frozen and their weapons put away, while `scene`
|
|
346
|
+
* runs; then the camera's back behind them, they can move and their
|
|
347
|
+
* weapons are back, however the scene ends (the mission ending too).
|
|
348
|
+
* `cut(shot)` changes the shot during it; `cut(null)` back to the first.
|
|
349
|
+
*
|
|
350
|
+
* ```ts
|
|
351
|
+
* await m.cinematic({ position: ACROSS_STREET, lookAt: car.position }, async (cut) => {
|
|
352
|
+
* await m.wait(3000);
|
|
353
|
+
* cut({ position: car.offset({ right: 3 }), lookAt: { vehicle: car } });
|
|
354
|
+
* await m.wait(2000);
|
|
355
|
+
* });
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
cinematic(shot: CameraShot, scene: (cut: (shot: CameraShot | null) => void) => Promise<void> | void, options?: {
|
|
359
|
+
players?: readonly Player[];
|
|
360
|
+
freeze?: boolean;
|
|
361
|
+
holster?: boolean;
|
|
362
|
+
}): Promise<void>;
|
|
363
|
+
/**
|
|
364
|
+
* Marks where the script is (logged, and a `missionEvent` of type
|
|
365
|
+
* `"stage"`). Steps (`steps`) do it themselves.
|
|
366
|
+
*/
|
|
367
|
+
stage(name: string): void;
|
|
368
|
+
/** The stage (or step) it's at. */
|
|
369
|
+
get currentStage(): string;
|
|
370
|
+
/** @internal Starts the steps from this one (`missions.start(..., { from })`). */
|
|
371
|
+
startFrom(step: string | null): void;
|
|
372
|
+
/** Resolves once every one of these peds is dead or gone. */
|
|
373
|
+
allDead(peds: readonly Ped[]): Promise<void>;
|
|
374
|
+
/**
|
|
375
|
+
* Waits for the party to reach a spot: the first player (the default), or
|
|
376
|
+
* all of them (`allPlayers`, a waiting point: each counts once they've
|
|
377
|
+
* been there, and the rest are waited for). Shows it with a blip and the
|
|
378
|
+
* game's marker meanwhile, for those who haven't reached it. Resolves
|
|
379
|
+
* with the player who completed it (the last, for `allPlayers`).
|
|
380
|
+
*/
|
|
381
|
+
reach(spot: Vector3, options?: ReachOptions): Promise<Player>;
|
|
382
|
+
/** Waits for the party to get in a vehicle: the first player (the default), or all of them at once. */
|
|
383
|
+
enter(vehicle: Vehicle, options?: WaitOptions & {
|
|
384
|
+
driver?: boolean;
|
|
385
|
+
}): Promise<Player>;
|
|
386
|
+
/**
|
|
387
|
+
* Waits until `condition(player)` holds for the first player (the default),
|
|
388
|
+
* or for every player at once (`allPlayers`). Resolves with that player.
|
|
389
|
+
*/
|
|
390
|
+
untilPlayer(condition: (player: Player) => boolean, options?: WaitOptions): Promise<Player>;
|
|
391
|
+
/**
|
|
392
|
+
* Keeps the party near someone (a ped to escort or follow, a vehicle):
|
|
393
|
+
* a player further than `warnAt` (m) gets `warning` instead of the
|
|
394
|
+
* objective until they're back in range (then the objective returns);
|
|
395
|
+
* with `failAt`, the mission fails (`fail`) when every player is further
|
|
396
|
+
* than that. Lasts until the mission ends or `stop()`.
|
|
397
|
+
*/
|
|
398
|
+
keepClose(target: Ped | Vehicle | Player, options?: {
|
|
399
|
+
warnAt?: number;
|
|
400
|
+
warning?: string;
|
|
401
|
+
failAt?: number;
|
|
402
|
+
fail?: string;
|
|
403
|
+
}): {
|
|
404
|
+
stop(): void;
|
|
405
|
+
};
|
|
406
|
+
/** True if `key` was used in the last `ms` (and starts it again if not): throttles repeated actions. */
|
|
407
|
+
cooldown(key: string, ms: number): boolean;
|
|
408
|
+
/**
|
|
409
|
+
* Plays one of the game's cutscenes (e.g. `"ryder2a"`) for the party
|
|
410
|
+
* together; resolves when everyone's has finished. The leader's skip ends
|
|
411
|
+
* it for everyone (see `CutsceneOptions`). Ending the mission stops it.
|
|
412
|
+
*/
|
|
413
|
+
cutscene(name: string, options?: CutsceneOptions): Promise<CutsceneResult>;
|
|
414
|
+
/**
|
|
415
|
+
* Starts a section: where the party respawns if they die, and where
|
|
416
|
+
* anyone far behind (more than `catchUpDistance`, or in another world)
|
|
417
|
+
* is brought, faded out and back in. Resolves once they're there.
|
|
418
|
+
*/
|
|
419
|
+
section(name: string, options: SectionOptions): Promise<void>;
|
|
420
|
+
/** @internal Runs the script. */
|
|
421
|
+
run(): Promise<void>;
|
|
422
|
+
/** @internal A party member respawned: back to the section start. */
|
|
423
|
+
respawned(player: Player): void;
|
|
424
|
+
/** @internal A party member died. */
|
|
425
|
+
died(player: Player): void;
|
|
426
|
+
}
|
|
427
|
+
export interface MarkerOptions {
|
|
428
|
+
/** Default 1.5 m. */
|
|
429
|
+
radius?: number;
|
|
430
|
+
/** Virtual world. Default 0. */
|
|
431
|
+
world?: number;
|
|
432
|
+
/** The blip and marker; `false` for none (detection only). Default: the game's yellow. */
|
|
433
|
+
blip?: BlipOptions | false;
|
|
434
|
+
/** Who's refused hears why: default an objective line for 3 s. */
|
|
435
|
+
onRefused?: (player: Player, reason: string) => void;
|
|
436
|
+
}
|
|
437
|
+
/** A spot that starts a mission when a player walks into it (`server.missions.marker()`). */
|
|
438
|
+
export declare class MissionMarker {
|
|
439
|
+
#private;
|
|
440
|
+
readonly definition: MissionDefinition;
|
|
441
|
+
readonly position: Vector3;
|
|
442
|
+
/** @internal */
|
|
443
|
+
constructor(definition: MissionDefinition, position: Vector3, remove: () => void);
|
|
444
|
+
remove(): void;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Starts and tracks missions (`server.missions`). A player is in one
|
|
448
|
+
* mission at a time.
|
|
449
|
+
*/
|
|
450
|
+
export declare class Missions {
|
|
451
|
+
#private;
|
|
452
|
+
/** @internal */
|
|
453
|
+
constructor(server: Server, emit: (e: MissionEvent) => void);
|
|
454
|
+
/** The missions running now. */
|
|
455
|
+
get running(): Mission[];
|
|
456
|
+
/** The mission a player is in, or null. */
|
|
457
|
+
of(player: Player): Mission | null;
|
|
458
|
+
/**
|
|
459
|
+
* Starts a mission for these players (the first is the leader). Throws
|
|
460
|
+
* `MissionRefused` if any of them is in a mission, cooling down or
|
|
461
|
+
* doesn't meet `requires`, or there are too many.
|
|
462
|
+
*/
|
|
463
|
+
start(definition: MissionDefinition, players: Player | readonly Player[], options?: {
|
|
464
|
+
from?: string;
|
|
465
|
+
}): Mission;
|
|
466
|
+
/**
|
|
467
|
+
* A start marker: a blip and the game's yellow marker for everyone not in
|
|
468
|
+
* a mission. Walking into it on foot starts the mission with everyone
|
|
469
|
+
* else standing in it (up to `maxPlayers`).
|
|
470
|
+
*/
|
|
471
|
+
marker(definition: MissionDefinition, at: Vector3, options?: MarkerOptions): MissionMarker;
|
|
472
|
+
/** @internal Throws MissionRefused if the player can't start or join it. */
|
|
473
|
+
admit(definition: MissionDefinition, player: Player): void;
|
|
474
|
+
/** @internal */
|
|
475
|
+
refuse(definition: MissionDefinition, player: Player, reason: string): never;
|
|
476
|
+
/** @internal */
|
|
477
|
+
bind(player: Player, mission: Mission | null): void;
|
|
478
|
+
/** @internal */
|
|
479
|
+
finished(mission: Mission, outcome: MissionOutcome): void;
|
|
480
|
+
/** @internal */
|
|
481
|
+
event(e: MissionEvent): void;
|
|
482
|
+
}
|