@aifivem/shared 0.5.0 → 0.6.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.
@@ -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/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/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);