@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/vehicleKeys.ts
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
/** A vehicle as key systems know it: the server entity (when it exists), its network id and its trimmed plate. */
|
|
2
|
-
export interface KeyTarget {
|
|
3
|
-
vehicle: number | null;
|
|
4
|
-
netId: number | null;
|
|
5
|
-
plate: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Why a player gets a vehicle's key; key systems treat each one differently (tgiann-hotwire: a bought vehicle gets a
|
|
10
|
-
* new key item, a garage vehicle its stored ignition state, a job or rented vehicle a key fixed in the ignition).
|
|
11
|
-
* - `purchase`: the player now owns the vehicle (dealer, admin give): a new key, older copies stop working.
|
|
12
|
-
* - `garage`: an owned vehicle taken out of storage: the owner already has the key.
|
|
13
|
-
* - `job`: a work vehicle for the shift.
|
|
14
|
-
* - `rental`: a rented vehicle for the rental time.
|
|
15
|
-
* - `temporary`: anything else short-lived (admin spawn, test drive, robbery vehicle); the default.
|
|
16
|
-
*/
|
|
17
|
-
export type KeyPurpose = "purchase" | "garage" | "job" | "rental" | "temporary";
|
|
18
|
-
export const KEY_PURPOSES: readonly KeyPurpose[] = [
|
|
19
|
-
"purchase",
|
|
20
|
-
"garage",
|
|
21
|
-
"job",
|
|
22
|
-
"rental",
|
|
23
|
-
"temporary",
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
/** A purpose from untrusted input; `temporary` for anything else. */
|
|
27
|
-
export function toKeyPurpose(value: unknown): KeyPurpose {
|
|
28
|
-
return KEY_PURPOSES.find((p) => p === value) ?? "temporary";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* One key system behind ai-core's vehicle key layer (server side). A system with only a client API is reached through
|
|
33
|
-
* ai-core's client (`clientKeys` adapters); then `give` / `remove` forward to the player's client.
|
|
34
|
-
*/
|
|
35
|
-
export interface VehicleKeysAdapter {
|
|
36
|
-
resource: string;
|
|
37
|
-
give(source: number, target: KeyTarget, purpose: KeyPurpose): void;
|
|
38
|
-
remove(source: number, target: KeyTarget): void;
|
|
39
|
-
/** Absent when the system cannot answer: ai-core then counts the key as held. */
|
|
40
|
-
has?(source: number, target: KeyTarget): boolean;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** The client half of a key system that only has a client API. */
|
|
44
|
-
export interface VehicleKeysClientAdapter {
|
|
45
|
-
resource: string;
|
|
46
|
-
give(vehicle: number, plate: string, purpose: KeyPurpose): void;
|
|
47
|
-
remove(vehicle: number, plate: string): void;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** GlobalState key holding the resource name of the active key system (null while none runs). */
|
|
51
|
-
export const VEHICLE_KEYS_STATE_KEY = "ai:vehicleKeys";
|
|
52
|
-
/** Server -> client: ("give" | "remove", netId, plate, purpose) for key systems with a client API only. */
|
|
53
|
-
export const VEHICLE_KEYS_CLIENT_EVENT = "ai-core:client:vehicleKeys";
|
|
54
|
-
|
|
55
|
-
/** ai-core's vehicle key exports: a vehicle is a server entity handle or a plate; `purpose` defaults to `temporary`. */
|
|
56
|
-
export type VehicleKeysServerExports = {
|
|
57
|
-
GiveVehicleKeys(
|
|
58
|
-
source: number,
|
|
59
|
-
vehicle: number | string,
|
|
60
|
-
purpose?: KeyPurpose,
|
|
61
|
-
): void;
|
|
62
|
-
RemoveVehicleKeys(source: number, vehicle: number | string): void;
|
|
63
|
-
HasVehicleKeys(source: number, vehicle: number | string): boolean;
|
|
64
|
-
};
|
|
1
|
+
/** A vehicle as key systems know it: the server entity (when it exists), its network id and its trimmed plate. */
|
|
2
|
+
export interface KeyTarget {
|
|
3
|
+
vehicle: number | null;
|
|
4
|
+
netId: number | null;
|
|
5
|
+
plate: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Why a player gets a vehicle's key; key systems treat each one differently (tgiann-hotwire: a bought vehicle gets a
|
|
10
|
+
* new key item, a garage vehicle its stored ignition state, a job or rented vehicle a key fixed in the ignition).
|
|
11
|
+
* - `purchase`: the player now owns the vehicle (dealer, admin give): a new key, older copies stop working.
|
|
12
|
+
* - `garage`: an owned vehicle taken out of storage: the owner already has the key.
|
|
13
|
+
* - `job`: a work vehicle for the shift.
|
|
14
|
+
* - `rental`: a rented vehicle for the rental time.
|
|
15
|
+
* - `temporary`: anything else short-lived (admin spawn, test drive, robbery vehicle); the default.
|
|
16
|
+
*/
|
|
17
|
+
export type KeyPurpose = "purchase" | "garage" | "job" | "rental" | "temporary";
|
|
18
|
+
export const KEY_PURPOSES: readonly KeyPurpose[] = [
|
|
19
|
+
"purchase",
|
|
20
|
+
"garage",
|
|
21
|
+
"job",
|
|
22
|
+
"rental",
|
|
23
|
+
"temporary",
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
/** A purpose from untrusted input; `temporary` for anything else. */
|
|
27
|
+
export function toKeyPurpose(value: unknown): KeyPurpose {
|
|
28
|
+
return KEY_PURPOSES.find((p) => p === value) ?? "temporary";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* One key system behind ai-core's vehicle key layer (server side). A system with only a client API is reached through
|
|
33
|
+
* ai-core's client (`clientKeys` adapters); then `give` / `remove` forward to the player's client.
|
|
34
|
+
*/
|
|
35
|
+
export interface VehicleKeysAdapter {
|
|
36
|
+
resource: string;
|
|
37
|
+
give(source: number, target: KeyTarget, purpose: KeyPurpose): void;
|
|
38
|
+
remove(source: number, target: KeyTarget): void;
|
|
39
|
+
/** Absent when the system cannot answer: ai-core then counts the key as held. */
|
|
40
|
+
has?(source: number, target: KeyTarget): boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The client half of a key system that only has a client API. */
|
|
44
|
+
export interface VehicleKeysClientAdapter {
|
|
45
|
+
resource: string;
|
|
46
|
+
give(vehicle: number, plate: string, purpose: KeyPurpose): void;
|
|
47
|
+
remove(vehicle: number, plate: string): void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** GlobalState key holding the resource name of the active key system (null while none runs). */
|
|
51
|
+
export const VEHICLE_KEYS_STATE_KEY = "ai:vehicleKeys";
|
|
52
|
+
/** Server -> client: ("give" | "remove", netId, plate, purpose) for key systems with a client API only. */
|
|
53
|
+
export const VEHICLE_KEYS_CLIENT_EVENT = "ai-core:client:vehicleKeys";
|
|
54
|
+
|
|
55
|
+
/** ai-core's vehicle key exports: a vehicle is a server entity handle or a plate; `purpose` defaults to `temporary`. */
|
|
56
|
+
export type VehicleKeysServerExports = {
|
|
57
|
+
GiveVehicleKeys(
|
|
58
|
+
source: number,
|
|
59
|
+
vehicle: number | string,
|
|
60
|
+
purpose?: KeyPurpose,
|
|
61
|
+
): void;
|
|
62
|
+
RemoveVehicleKeys(source: number, vehicle: number | string): void;
|
|
63
|
+
HasVehicleKeys(source: number, vehicle: number | string): boolean;
|
|
64
|
+
};
|
|
65
65
|
|
|
66
66
|
/** Client -> server callback `(netId | plate)`: whether the local player holds that vehicle's keys (the server layer's answer). */
|
|
67
67
|
export const VEHICLE_KEYS_HAS_CALLBACK = "ai-core:vehicleKeys:has";
|
package/src/vehicles.ts
CHANGED
|
@@ -41,6 +41,23 @@ export const VEHICLE_BAGS = {
|
|
|
41
41
|
fuel: "fuel",
|
|
42
42
|
} as const;
|
|
43
43
|
|
|
44
|
+
/** `DeleteVehicleByPlate`'s answer: `entities` = world entities with that plate that were deleted. */
|
|
45
|
+
export type DeleteByPlateResult =
|
|
46
|
+
| { ok: true; id: number; entities: number }
|
|
47
|
+
| { ok: false; error: "invalid_plate" | "not_found" | "failed" };
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* `AdoptVehicle`'s answer: `owned` = the entity is already an owned vehicle, `plate_owned` = its plate belongs to an
|
|
51
|
+
* owned vehicle (owner online or not), `model` = the model name is not the entity's, `invalid` = no vehicle entity, a
|
|
52
|
+
* wrong owner or props that are not the entity's.
|
|
53
|
+
*/
|
|
54
|
+
export type AdoptVehicleResult =
|
|
55
|
+
| { ok: true; id: number; plate: string }
|
|
56
|
+
| {
|
|
57
|
+
ok: false;
|
|
58
|
+
error: "invalid" | "model" | "owned" | "plate_owned" | "failed";
|
|
59
|
+
};
|
|
60
|
+
|
|
44
61
|
/** ai-vehicles' server exports. */
|
|
45
62
|
export type AiVehiclesServerExports = {
|
|
46
63
|
CreateVehicle(
|
|
@@ -95,6 +112,24 @@ export type AiVehiclesServerExports = {
|
|
|
95
112
|
StoreVehicle(id: number, garage: string | null, state?: VehicleState): void;
|
|
96
113
|
SetOwner(id: number, owner: VehicleOwner): void;
|
|
97
114
|
DeleteVehicle(id: number): void;
|
|
115
|
+
/** Deletes an owned vehicle completely by plate (row and every world entity with the plate), owner online or not. */
|
|
116
|
+
DeleteVehicleByPlate(
|
|
117
|
+
plate: string,
|
|
118
|
+
done?: (result: DeleteByPlateResult) => void,
|
|
119
|
+
): void;
|
|
120
|
+
/**
|
|
121
|
+
* Makes an existing world vehicle an owned one, "out" and tracked like a spawned one (admin `/admincar`). `model` is
|
|
122
|
+
* the entity's model name (the server cannot read it; checked against the entity), `props` its look read on a client
|
|
123
|
+
* (lib VehicleProps or ox_lib / qb-core's shape, of the entity's model). The entity keeps its plate when that is a
|
|
124
|
+
* valid custom plate (`SetPlate`'s rules), else it gets the generated one.
|
|
125
|
+
*/
|
|
126
|
+
AdoptVehicle(
|
|
127
|
+
owner: VehicleOwner,
|
|
128
|
+
entity: number,
|
|
129
|
+
model: string,
|
|
130
|
+
props: unknown,
|
|
131
|
+
done?: (result: AdoptVehicleResult) => void,
|
|
132
|
+
): void;
|
|
98
133
|
/**
|
|
99
134
|
* Creates the entity; `cb` gets its net id (null when it failed). `asker` is a player whose client answers the model
|
|
100
135
|
* type. `setup` (lib VehicleSetup, e.g. `{ colors }`) is kept with a vehicle that has no props yet and applied on every
|
package/src/vrp.ts
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ai-core's vRP layer (bridge/vrp in ai-core): the panel's permission mapping (`data/vrp.json`) as the Lua bridge
|
|
3
|
-
* reads it (export `GetVrpConfig`, local event `VRP.configEvent` with the same shape after a change).
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* One permission rule: grants `permission` (exact, or a prefix when it ends with `*`) to whoever matches any filled
|
|
8
|
-
* target. `grade` is the minimum job / gang grade; `onDuty` makes the job count only while on duty in it.
|
|
9
|
-
*/
|
|
10
|
-
export interface VrpPermissionRule {
|
|
11
|
-
permission: string;
|
|
12
|
-
job: string;
|
|
13
|
-
gang: string;
|
|
14
|
-
/** An extra vRP group the character holds (groups vRP scripts add that are no job or gang). */
|
|
15
|
-
group: string;
|
|
16
|
-
grade: number;
|
|
17
|
-
onDuty: boolean;
|
|
18
|
-
admin: boolean;
|
|
19
|
-
everyone: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** A vRP group name that means a job / gang grade or admin (vRPex style ranks such as "Coronel"). */
|
|
23
|
-
export interface VrpGroupAlias {
|
|
24
|
-
job: string;
|
|
25
|
-
gang: string;
|
|
26
|
-
grade: number;
|
|
27
|
-
admin: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface VrpConfig {
|
|
31
|
-
/**
|
|
32
|
-
* Built-in rules used when no rule of `permissions` names the permission: `<job>.*` = member of that job (on duty
|
|
33
|
-
* with `jobOnDuty`), `admin.*` = admin (`ai.admin`), `player.*` = everyone.
|
|
34
|
-
*/
|
|
35
|
-
defaults: {
|
|
36
|
-
jobPrefix: boolean;
|
|
37
|
-
jobOnDuty: boolean;
|
|
38
|
-
adminPrefix: boolean;
|
|
39
|
-
playerPrefix: boolean;
|
|
40
|
-
};
|
|
41
|
-
permissions: VrpPermissionRule[];
|
|
42
|
-
/** vRP group name -> what it means in ai-core. */
|
|
43
|
-
groups: Record<string, VrpGroupAlias>;
|
|
44
|
-
/** vRP item id (`edible|tacos`, `wbody|WEAPON_PISTOL`) -> inventory item name. */
|
|
45
|
-
items: Record<string, string>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const VRP = {
|
|
49
|
-
/** Server local: (config: VrpConfig) the panel changed the vRP mapping. */
|
|
50
|
-
configEvent: "ai-core:vrp:config",
|
|
51
|
-
} as const;
|
|
1
|
+
/**
|
|
2
|
+
* ai-core's vRP layer (bridge/vrp in ai-core): the panel's permission mapping (`data/vrp.json`) as the Lua bridge
|
|
3
|
+
* reads it (export `GetVrpConfig`, local event `VRP.configEvent` with the same shape after a change).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One permission rule: grants `permission` (exact, or a prefix when it ends with `*`) to whoever matches any filled
|
|
8
|
+
* target. `grade` is the minimum job / gang grade; `onDuty` makes the job count only while on duty in it.
|
|
9
|
+
*/
|
|
10
|
+
export interface VrpPermissionRule {
|
|
11
|
+
permission: string;
|
|
12
|
+
job: string;
|
|
13
|
+
gang: string;
|
|
14
|
+
/** An extra vRP group the character holds (groups vRP scripts add that are no job or gang). */
|
|
15
|
+
group: string;
|
|
16
|
+
grade: number;
|
|
17
|
+
onDuty: boolean;
|
|
18
|
+
admin: boolean;
|
|
19
|
+
everyone: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** A vRP group name that means a job / gang grade or admin (vRPex style ranks such as "Coronel"). */
|
|
23
|
+
export interface VrpGroupAlias {
|
|
24
|
+
job: string;
|
|
25
|
+
gang: string;
|
|
26
|
+
grade: number;
|
|
27
|
+
admin: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface VrpConfig {
|
|
31
|
+
/**
|
|
32
|
+
* Built-in rules used when no rule of `permissions` names the permission: `<job>.*` = member of that job (on duty
|
|
33
|
+
* with `jobOnDuty`), `admin.*` = admin (`ai.admin`), `player.*` = everyone.
|
|
34
|
+
*/
|
|
35
|
+
defaults: {
|
|
36
|
+
jobPrefix: boolean;
|
|
37
|
+
jobOnDuty: boolean;
|
|
38
|
+
adminPrefix: boolean;
|
|
39
|
+
playerPrefix: boolean;
|
|
40
|
+
};
|
|
41
|
+
permissions: VrpPermissionRule[];
|
|
42
|
+
/** vRP group name -> what it means in ai-core. */
|
|
43
|
+
groups: Record<string, VrpGroupAlias>;
|
|
44
|
+
/** vRP item id (`edible|tacos`, `wbody|WEAPON_PISTOL`) -> inventory item name. */
|
|
45
|
+
items: Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const VRP = {
|
|
49
|
+
/** Server local: (config: VrpConfig) the panel changed the vRP mapping. */
|
|
50
|
+
configEvent: "ai-core:vrp:config",
|
|
51
|
+
} as const;
|
package/src/warrants.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { ActionResult } from "./action";
|
|
2
|
+
|
|
3
|
+
/** ai-core's own warrants (`ai_core_warrants`): set by admins, the police job menu or any script through lib `warrants`. */
|
|
4
|
+
export interface Warrant {
|
|
5
|
+
id: number;
|
|
6
|
+
charId: number;
|
|
7
|
+
reason: string;
|
|
8
|
+
/** Who issued it: an officer's character, an admin or a resource name. */
|
|
9
|
+
by: string;
|
|
10
|
+
/** Epoch ms. */
|
|
11
|
+
created: number;
|
|
12
|
+
/** Epoch ms; null = until cleared. */
|
|
13
|
+
expires: number | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** A row of the active list: the warrant and its character. */
|
|
17
|
+
export interface WarrantRow extends Warrant {
|
|
18
|
+
citizenid: string;
|
|
19
|
+
name: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** A page of active warrants, newest first; `next` is the cursor of the next page (null: last page). */
|
|
23
|
+
export interface WarrantPage {
|
|
24
|
+
warrants: WarrantRow[];
|
|
25
|
+
next: number | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** A character: a loaded player's server id, a citizenid or `{ charId }`. */
|
|
29
|
+
export type WarrantTarget = number | string | { charId: number };
|
|
30
|
+
|
|
31
|
+
/** A new warrant; `minutes` left out or null = until cleared, `by` an officer's server id or a name. */
|
|
32
|
+
export interface WarrantAdd {
|
|
33
|
+
target: WarrantTarget;
|
|
34
|
+
reason: string;
|
|
35
|
+
minutes?: number | null;
|
|
36
|
+
by?: number | string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** `AddWarrant`'s answer: the new id, or an ai-core lang key. */
|
|
40
|
+
export type WarrantResult = ActionResult<{ id: number }>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* How ai-core's MDT layer answers a warrant check (panel setting `warrants`): `auto` = the MDT's warrants while it
|
|
44
|
+
* answers warrant checks, else ai-core's own; `both` = either; `mdt` = only the MDT's.
|
|
45
|
+
*/
|
|
46
|
+
export type WarrantMode = "auto" | "both" | "mdt";
|
|
47
|
+
|
|
48
|
+
/** Lengths offered by the admin panel and the police menu (lang `..._D_<id>`); null = until cleared. */
|
|
49
|
+
export const WARRANT_DURATIONS = [
|
|
50
|
+
{ id: "1H", minutes: 60 },
|
|
51
|
+
{ id: "6H", minutes: 360 },
|
|
52
|
+
{ id: "1D", minutes: 1440 },
|
|
53
|
+
{ id: "3D", minutes: 4320 },
|
|
54
|
+
{ id: "1W", minutes: 10_080 },
|
|
55
|
+
{ id: "CLEARED", minutes: null },
|
|
56
|
+
] as const satisfies ReadonlyArray<{ id: string; minutes: number | null }>;
|
|
57
|
+
|
|
58
|
+
/** Active warrants one character may hold; a full list refuses new ones. */
|
|
59
|
+
export const MAX_WARRANTS = 20;
|
|
60
|
+
|
|
61
|
+
/** ai-core's warrant exports (server). Callbacks: no promise crosses a resource boundary. */
|
|
62
|
+
export type WarrantServerExports = {
|
|
63
|
+
/** Issues a warrant; `done` gets `{ ok, id }` or `{ ok: false, error }` (an ai-core lang key). */
|
|
64
|
+
AddWarrant(warrant: WarrantAdd, done?: (result: WarrantResult) => void): void;
|
|
65
|
+
/** Clears one active warrant; `done(false)` when no active warrant has that id. */
|
|
66
|
+
ClearWarrant(
|
|
67
|
+
id: number,
|
|
68
|
+
by?: number | string,
|
|
69
|
+
done?: (cleared: boolean) => void,
|
|
70
|
+
): void;
|
|
71
|
+
/** Clears every active warrant of a character; `done` gets how many. */
|
|
72
|
+
ClearWarrants(
|
|
73
|
+
target: WarrantTarget,
|
|
74
|
+
by?: number | string,
|
|
75
|
+
done?: (count: number) => void,
|
|
76
|
+
): void;
|
|
77
|
+
/** A character's active warrants, newest first; null when the target names no character. */
|
|
78
|
+
GetWarrants(
|
|
79
|
+
target: WarrantTarget,
|
|
80
|
+
done: (warrants: Warrant[] | null) => void,
|
|
81
|
+
): void;
|
|
82
|
+
/** Every active warrant, newest first, 25 a page (`cursor` = the last page's `next`). */
|
|
83
|
+
ListWarrants(
|
|
84
|
+
cursor: number | null | undefined,
|
|
85
|
+
done: (page: WarrantPage) => void,
|
|
86
|
+
): void;
|
|
87
|
+
};
|
package/src/world.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/** The weather types of the qb-weathersync contract (ai-core's world layer passes them on). */
|
|
2
|
-
export const WEATHERS = [
|
|
3
|
-
"EXTRASUNNY",
|
|
4
|
-
"CLEAR",
|
|
5
|
-
"NEUTRAL",
|
|
6
|
-
"SMOG",
|
|
7
|
-
"FOGGY",
|
|
8
|
-
"OVERCAST",
|
|
9
|
-
"CLOUDS",
|
|
10
|
-
"CLEARING",
|
|
11
|
-
"RAIN",
|
|
12
|
-
"THUNDER",
|
|
13
|
-
"SNOW",
|
|
14
|
-
"BLIZZARD",
|
|
15
|
-
"SNOWLIGHT",
|
|
16
|
-
"XMAS",
|
|
17
|
-
"HALLOWEEN",
|
|
18
|
-
] as const;
|
|
19
|
-
|
|
20
|
-
export type Weather = (typeof WEATHERS)[number];
|
|
21
|
-
|
|
22
|
-
const WEATHER_SET: ReadonlySet<string> = new Set(WEATHERS);
|
|
23
|
-
|
|
24
|
-
/** A known weather type (exact upper-case name). */
|
|
25
|
-
export const isWeather = (value: unknown): value is Weather =>
|
|
26
|
-
typeof value === "string" && WEATHER_SET.has(value);
|
|
1
|
+
/** The weather types of the qb-weathersync contract (ai-core's world layer passes them on). */
|
|
2
|
+
export const WEATHERS = [
|
|
3
|
+
"EXTRASUNNY",
|
|
4
|
+
"CLEAR",
|
|
5
|
+
"NEUTRAL",
|
|
6
|
+
"SMOG",
|
|
7
|
+
"FOGGY",
|
|
8
|
+
"OVERCAST",
|
|
9
|
+
"CLOUDS",
|
|
10
|
+
"CLEARING",
|
|
11
|
+
"RAIN",
|
|
12
|
+
"THUNDER",
|
|
13
|
+
"SNOW",
|
|
14
|
+
"BLIZZARD",
|
|
15
|
+
"SNOWLIGHT",
|
|
16
|
+
"XMAS",
|
|
17
|
+
"HALLOWEEN",
|
|
18
|
+
] as const;
|
|
19
|
+
|
|
20
|
+
export type Weather = (typeof WEATHERS)[number];
|
|
21
|
+
|
|
22
|
+
const WEATHER_SET: ReadonlySet<string> = new Set(WEATHERS);
|
|
23
|
+
|
|
24
|
+
/** A known weather type (exact upper-case name). */
|
|
25
|
+
export const isWeather = (value: unknown): value is Weather =>
|
|
26
|
+
typeof value === "string" && WEATHER_SET.has(value);
|