@cybermp-community/client-types 2.5.1 → 2.5.3

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.
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Spawns the local player and creates client-only entities not visible to other players.
3
+ */
4
+ export interface MpLocal {
5
+ /**
6
+ * Spawns the local player at the given world position.
7
+ * @param x - World X coordinate.
8
+ * @param y - World Y coordinate.
9
+ * @param z - World Z coordinate (height).
10
+ * @param yaw - Facing angle in degrees.
11
+ * @returns `true` on success, `false` otherwise.
12
+ */
13
+ spawnPlayer(x: number, y: number, z: number, yaw: number): boolean;
14
+
15
+ /**
16
+ * Creates a client-only ped at the given position. Not synced — invisible to other players.
17
+ * @param skinHash - Model hash.
18
+ * @param appHash - Appearance variant hash.
19
+ * @param x - World X coordinate.
20
+ * @param y - World Y coordinate.
21
+ * @param z - World Z coordinate.
22
+ * @param yaw - Facing angle.
23
+ * @param streaming - Whether the engine manages streaming boundaries automatically.
24
+ * @returns Local entity handle.
25
+ */
26
+ spawnPed(
27
+ skinHash: number | bigint,
28
+ appHash: number | bigint,
29
+ x: number,
30
+ y: number,
31
+ z: number,
32
+ yaw: number,
33
+ streaming: boolean,
34
+ ): number;
35
+
36
+ /**
37
+ * Creates a client-only vehicle at the given position. Not synced — invisible to other players.
38
+ * @param skinHash - Model hash.
39
+ * @param appHash - Appearance variant hash.
40
+ * @param x - World X coordinate.
41
+ * @param y - World Y coordinate.
42
+ * @param z - World Z coordinate.
43
+ * @param roll - Roll angle.
44
+ * @param pitch - Pitch angle.
45
+ * @param yaw - Yaw angle.
46
+ * @param streaming - Whether the engine manages streaming boundaries automatically.
47
+ * @returns Local entity handle.
48
+ */
49
+ spawnVehicle(
50
+ skinHash: number | bigint,
51
+ appHash: number | bigint,
52
+ x: number,
53
+ y: number,
54
+ z: number,
55
+ roll: number,
56
+ pitch: number,
57
+ yaw: number,
58
+ streaming: boolean,
59
+ ): number;
60
+
61
+ /**
62
+ * Creates a client-only prop or world object at the given position. Not synced — invisible to other players.
63
+ * @param skinHash - Model hash.
64
+ * @param appHash - Appearance variant hash.
65
+ * @param x - World X coordinate.
66
+ * @param y - World Y coordinate.
67
+ * @param z - World Z coordinate.
68
+ * @param roll - Roll angle.
69
+ * @param pitch - Pitch angle.
70
+ * @param yaw - Yaw angle.
71
+ * @param streaming - Whether the engine manages streaming boundaries automatically.
72
+ * @returns Local entity handle.
73
+ */
74
+ spawnObject(
75
+ skinHash: bigint | number,
76
+ appHash: bigint | number,
77
+ x: number,
78
+ y: number,
79
+ z: number,
80
+ roll: number,
81
+ pitch: number,
82
+ yaw: number,
83
+ streaming: boolean,
84
+ ): number;
85
+
86
+ /**
87
+ * Destroys a client-only ped and frees its engine resources.
88
+ * @param hash - Local entity handle returned by {@link spawnPed}.
89
+ */
90
+ despawnPed(hash: number): void;
91
+
92
+ /**
93
+ * Destroys a client-only vehicle and frees its engine resources.
94
+ * @param hash - Local entity handle returned by {@link spawnVehicle}.
95
+ */
96
+ despawnVehicle(hash: number): void;
97
+
98
+ /**
99
+ * Destroys a client-only object and frees its engine resources.
100
+ * @param hash - Local entity handle returned by {@link spawnObject}.
101
+ */
102
+ despawnObject(hash: number): void;
103
+ }
@@ -1,18 +1,72 @@
1
+ /**
2
+ * Read/write metadata on the global scope, specific players, or network entities, with optional network sync.
3
+ */
1
4
  export interface MpMeta {
5
+ /**
6
+ * Writes a value to the global metadata store.
7
+ * @param key - Metadata key.
8
+ * @param value - Any serializable value.
9
+ * @param sync - If `true`, the value is broadcast to all connected clients.
10
+ */
2
11
  setGlobalMeta(key: string, value: any, sync?: boolean): void;
12
+
13
+ /**
14
+ * Reads a value from the global metadata store.
15
+ * @template T - Expected type of the value.
16
+ * @param key - Metadata key.
17
+ * @returns The stored value cast to `T`, or `undefined` if not set.
18
+ */
3
19
  getGlobalMeta<T = any>(key: string): T;
4
20
 
5
- setPlayerMeta(
6
- playerId: number,
7
- key: string,
8
- value: any,
9
- sync?: boolean,
10
- ): void;
21
+ /**
22
+ * Writes a metadata value to a specific remote player.
23
+ * @param playerId - Target player's network ID.
24
+ * @param key - Metadata key.
25
+ * @param value - Value to attach.
26
+ * @param sync - If `true`, the change is broadcast to all clients.
27
+ */
28
+ setPlayerMeta(playerId: number, key: string, value: any, sync?: boolean): void;
29
+
30
+ /**
31
+ * Reads a metadata value from a specific remote player.
32
+ * @template T - Expected type of the value.
33
+ * @param playerId - Target player's network ID.
34
+ * @param key - Metadata key.
35
+ * @returns The stored value cast to `T`, or `undefined` if not set.
36
+ */
11
37
  getPlayerMeta<T = any>(playerId: number, key: string): T;
12
38
 
13
- setLocalPlayerMeta(key: string, value: any): void;
39
+ /**
40
+ * Writes a metadata value to the local player.
41
+ * @param key - Metadata key.
42
+ * @param value - Value to store.
43
+ * @param sync - If `true`, the value is relayed to the server and other clients.
44
+ */
45
+ setLocalPlayerMeta(key: string, value: any, sync?: boolean): void;
46
+
47
+ /**
48
+ * Reads a metadata value from the local player.
49
+ * @template T - Expected type of the value.
50
+ * @param key - Metadata key.
51
+ * @returns The stored value cast to `T`, or `undefined` if not set.
52
+ */
14
53
  getLocalPlayerMeta<T = any>(key: string): T;
15
54
 
55
+ /**
56
+ * Writes a metadata value to a synced network entity (vehicle, ped, object, etc.).
57
+ * @param netId - Network ID of the target entity.
58
+ * @param key - Metadata key.
59
+ * @param value - Value to attach.
60
+ * @param sync - If `true`, the value is broadcast to all clients tracking this entity.
61
+ */
16
62
  setEntityMeta(netId: number, key: string, value: any, sync?: boolean): void;
63
+
64
+ /**
65
+ * Reads a metadata value from a synced network entity.
66
+ * @template T - Expected type of the value.
67
+ * @param netId - Network ID of the target entity.
68
+ * @param key - Metadata key.
69
+ * @returns The stored value cast to `T`, or `undefined` if not set.
70
+ */
17
71
  getEntityMeta<T = any>(netId: number, key: string): T;
18
72
  }
@@ -2,135 +2,116 @@ import type { MpCef } from './cef.d.ts';
2
2
  import type { MpDiscord } from './discord.d.ts';
3
3
  import type { MpEvents } from './events/index.js';
4
4
  import type { MpLocalStorage } from './local-storage.d.ts';
5
+ import type { MpNetwork } from './network';
5
6
  import type { MpMeta } from './meta.d.ts';
6
7
  import type { MpVoiceChat } from './voice-chat.d.ts';
7
8
  import type { MpExports } from './exports.d.ts';
9
+ import type { MpLocal } from './local.d.ts';
10
+ import type { MpResources } from './resources.js';
11
+ import type { MpCommands } from './commands.js';
8
12
 
9
13
  declare module '../mp.d.ts' {
10
14
  export interface MpClient {
11
- exports: MpExports;
15
+ /**
16
+ * Event bus for client, server, and CEF communication.
17
+ */
12
18
  events: MpEvents;
13
- meta: MpMeta;
14
- voiceChat: MpVoiceChat;
15
- cef: MpCef;
16
- discord: MpDiscord;
17
- localStorage: MpLocalStorage;
18
-
19
- getStreamedPool(
20
- objName: 'CVehicle' | 'CPed' | 'CPickup' | 'CObject',
21
- ): number[];
22
- getStreamedPlayers(): number[];
23
19
 
24
20
  /**
25
- * Mapping between network and game IDs.
21
+ * Metadata store for globals, players, and network entities.
26
22
  */
27
- getVehicleGameIdByNetworkId(id: number): number;
28
-
29
- getPlayerGameIdByNetworkId(id: number): number;
30
-
31
- getObjectGameIdByNetworkId(id: number): number;
32
-
33
- getVehicleNetworkIdByGameId(hash: number): number;
34
-
35
- getPlayerNetworkIdByGameId(hash: number): number;
36
-
37
- getObjectNetworkIdByGameId(hash: number): number;
38
-
39
- getPedNetworkIdByGameId(hash: number): number;
40
-
41
- getPedGameIdByNetworkId(hash: number): number;
23
+ meta: MpMeta;
42
24
 
43
25
  /**
44
- * Local player spawning API.
26
+ * Voice chat controls and device management.
45
27
  */
46
- setSpawnDataLocalPlayer(x: number, y: number, z: number, yaw: number): void;
47
-
48
- spawnLocalPlayer(): boolean;
28
+ voiceChat: MpVoiceChat;
49
29
 
50
30
  /**
51
- * Spawn local-only entities (not synced).
31
+ * CEF browser — focus, cursor, and URL control.
52
32
  */
53
- spawnLocalPed(
54
- skinHash: number,
55
- appHash: number,
56
- x: number,
57
- y: number,
58
- z: number,
59
- yaw: number,
60
- streaming: boolean,
61
- ): number;
62
-
63
- spawnLocalVehicle(
64
- skinHash: number,
65
- appHash: number,
66
- x: number,
67
- y: number,
68
- z: number,
69
- roll: number,
70
- pitch: number,
71
- yaw: number,
72
- streaming: boolean,
73
- ): number;
33
+ cef: MpCef;
74
34
 
75
- spawnLocalObject(
76
- skinHash: bigint | number,
77
- appHash: bigint | number,
78
- x: number,
79
- y: number,
80
- z: number,
81
- roll: number,
82
- pitch: number,
83
- yaw: number,
84
- streaming: boolean,
85
- ): number;
35
+ /**
36
+ * Discord rich presence and OAuth2 integration.
37
+ */
38
+ discord: MpDiscord;
86
39
 
87
- despawnLocalPed(hash: number): void;
40
+ /**
41
+ * Entity streaming and network-to-game-ID utilities.
42
+ */
43
+ network: MpNetwork;
88
44
 
89
- despawnLocalVehicle(hash: number): void;
45
+ /**
46
+ * Spawning and despawning of the local player and client-only entities.
47
+ */
48
+ local: MpLocal;
90
49
 
91
- despawnLocalObject(hash: number): void;
50
+ /**
51
+ * Registration and removal of client-side console commands.
52
+ */
53
+ commands: MpCommands;
92
54
 
93
55
  /**
94
- * Get Discord token via game SDK (unstable).
56
+ * Persistent client-side key-value storage.
95
57
  */
96
- getDiscordOAuth2Token(discordAppId: string): string;
58
+ localStorage: MpLocalStorage;
97
59
 
98
60
  /**
99
- * Get Discord auth code (preferred).
61
+ * Cross-resource function exposure and invocation.
100
62
  */
101
- getDiscordCodeAuthorization(discordAppId: string, scopes: string): string;
63
+ exports: MpExports;
102
64
 
103
65
  /**
104
- * Returns current server IP:PORT string.
66
+ * Resource management, loading, and state tracking.
105
67
  */
106
- getCurrentServerEndpoint(): string;
68
+ resources: MpResources;
107
69
 
108
70
  /**
109
- * Get server ID from player hash.
71
+ * Returns the current server's IP:PORT string.
110
72
  */
111
- getPlayerServerId(playerHash: number): number;
73
+ getCurrentServerEndpoint(): string;
112
74
 
113
75
  /**
114
- * Get src variable value as string.
76
+ * Reads a string config variable from the launcher manifest.
77
+ * @param varName - Variable name.
78
+ * @returns The variable's string value.
115
79
  */
116
80
  getVar(varName: string): string;
117
81
 
118
82
  /**
119
- * Get console variable value as integer.
83
+ * Reads an integer config variable from the launcher manifest.
84
+ * @param varName - Variable name.
85
+ * @returns The variable's value as an integer.
120
86
  */
121
87
  getVarInt(varName: string): number;
122
88
 
123
89
  /**
124
- * Returns time in ms since game start.
90
+ * Returns elapsed time since the game engine started, in milliseconds.
125
91
  */
126
- getTimer(): number;
92
+ getGameTimer(): number;
127
93
 
94
+ /**
95
+ * Returns the raw unparsed launcher settings as a JSON string.
96
+ */
128
97
  getLauncherSettingsJSON(): string;
129
98
 
99
+ /**
100
+ * Returns the parsed launcher settings object.
101
+ */
130
102
  getLauncherSettings(): any;
131
103
 
104
+ /**
105
+ * Registers a callback that runs on every game engine render frame.
106
+ * @param cb - The function to call each frame.
107
+ * @returns A tick ID used to cancel the loop with {@link clearTick}.
108
+ */
132
109
  setTick(cb: () => any): number;
133
110
 
111
+ /**
112
+ * Cancels a render-frame loop registered with {@link setTick}.
113
+ * @param tickId - The tick ID returned by {@link setTick}.
114
+ */
134
115
  clearTick(tickId: number): void;
135
116
  }
136
117
  }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Entity streaming queries and network-to-game-ID translation utilities.
3
+ */
4
+ export interface MpNetwork {
5
+ /**
6
+ * Returns the current server's address string.
7
+ * @returns Connection endpoint, e.g. `"127.0.0.1:4430"`.
8
+ */
9
+ getServerAddress(): string;
10
+
11
+ /**
12
+ * Returns all engine entities of the given pool type within the local player's stream range.
13
+ * @param objName - Entity pool class to query.
14
+ * @returns Array of local game engine handles.
15
+ */
16
+ getStreamedPool(objName: 'CVehicle' | 'CPed' | 'CPickup' | 'CObject'): number[];
17
+
18
+ /**
19
+ * Returns all remote players currently within the local player's stream zone.
20
+ * @returns Array of native game engine entity IDs.
21
+ */
22
+ getStreamedPlayers(): number[];
23
+
24
+ /**
25
+ * Converts a vehicle's network ID to its local game engine handle.
26
+ * @param networkId - Server-assigned network ID.
27
+ * @returns Local game engine vehicle handle.
28
+ */
29
+ getVehicleGameId(networkId: number): number;
30
+
31
+ /**
32
+ * Converts a vehicle's local game engine handle to its network ID.
33
+ * @param gameId - Local game engine handle.
34
+ * @returns Network ID of the vehicle.
35
+ */
36
+ getVehicleId(gameId: number): number;
37
+
38
+ /**
39
+ * Converts a ped's local game engine handle to its network ID.
40
+ * @param gameId - Local game engine handle.
41
+ * @returns Network ID of the ped.
42
+ */
43
+ getPedId(gameId: number): number;
44
+
45
+ /**
46
+ * Converts a ped's network ID to its local game engine handle.
47
+ * @param networkId - Server-assigned network ID.
48
+ * @returns Local game engine ped handle.
49
+ */
50
+ getPedGameId(networkId: number): number;
51
+
52
+ /**
53
+ * Converts an object's network ID to its local game engine handle.
54
+ * @param networkId - Server-assigned network ID.
55
+ * @returns Local game engine object handle.
56
+ */
57
+ getObjectGameId(networkId: number): number;
58
+
59
+ /**
60
+ * Converts an object's local game engine handle to its network ID.
61
+ * @param gameId - Local game engine handle.
62
+ * @returns Network ID of the object.
63
+ */
64
+ getObjectId(gameId: number): number;
65
+
66
+ /**
67
+ * Converts a player's network ID to their local game engine handle.
68
+ * @param networkId - Server-assigned network ID.
69
+ * @returns Local game engine player handle.
70
+ */
71
+ getPlayerGameId(networkId: number): number;
72
+
73
+ /**
74
+ * Converts a player's local game engine handle to their network ID.
75
+ * @param gameId - Local game engine handle.
76
+ * @returns Network ID of the player.
77
+ */
78
+ getPlayerId(gameId: number): number;
79
+ }
@@ -0,0 +1,64 @@
1
+ import type * as CyberEnums from '../enums';
2
+
3
+ /**
4
+ * Interface for managing, loading, and tracking resources.
5
+ *
6
+ * Provides utilities for reading configuration files (TOML), loading raw file contents,
7
+ * querying the lifecycle status of specific assets, and identifying the active resource container.
8
+ */
9
+ export interface MpResources {
10
+ /**
11
+ * Retrieves the raw string contents of a specified TOML configuration file.
12
+ * @param name - The name or identifier key of the target TOML resource.
13
+ * @returns The raw TOML formatted configuration string.
14
+ */
15
+ getTOML(name: string): string;
16
+
17
+ /**
18
+ * Reads a file inside a resource and returns its contents.
19
+ * @param resourceName Name of the resource.
20
+ * @param pathToResource Path to the file.
21
+ * @returns File content as string.
22
+ */
23
+ loadFile(resourceName: string, pathToResource: string): string;
24
+
25
+ /**
26
+ * Queries the current loading or runtime execution state of a specific resource.
27
+ * @param name - The name of the target resource to check.
28
+ * @returns The current operational state enumeration value.
29
+ */
30
+ getState(name: string): CyberEnums.EResourceState;
31
+
32
+ /**
33
+ * Gets the name identifier of the current resource or script execution context.
34
+ * @returns The name string of the active resource bundle.
35
+ */
36
+ getCurrentName(): string;
37
+
38
+ /**
39
+ * Starts a specific resource by name.
40
+ * @param resourceName Name of the resource to start.
41
+ */
42
+ start(resourceName: string): void;
43
+
44
+ /**
45
+ * Stops a specific resource by name.
46
+ * @param resourceName Name of the resource to stop.
47
+ */
48
+ stop(resourceName: string): void;
49
+
50
+ /**
51
+ * Restarts a specific resource by name.
52
+ * @param resourceName Name of the resource to restart.
53
+ */
54
+ restart(resourceName: string): void;
55
+
56
+ /**
57
+ * Gets metadata from a resource manifest.
58
+ * @param resourceName Resource name.
59
+ * @param keyName Metadata key.
60
+ * @param index Index (if multiple values exist).
61
+ * @returns Metadata string.
62
+ */
63
+ getMetadata(resourceName: string, keyName: string, index: number): string;
64
+ }
@@ -3,25 +3,89 @@
3
3
  import * as CyberEnums from '../enums';
4
4
 
5
5
  export interface MpVoiceChat {
6
+ /**
7
+ * Enables or disables the voice chat system entirely.
8
+ * @param state - `true` to connect and start capture, `false` to shut down.
9
+ */
6
10
  enable(state: boolean): void;
7
11
 
12
+ /**
13
+ * Sets how the microphone is activated (continuous, voice activity, or push-to-talk).
14
+ * @param type - The desired activation mode.
15
+ */
8
16
  changeActivationType(type: CyberEnums.EVoiceActivationType): void;
17
+
18
+ /**
19
+ * Assigns a key to trigger microphone transmission in push-to-talk mode.
20
+ * @param key - Key code or input key enum value.
21
+ */
9
22
  bindPushToTalkKey(key: number | CyberEnums.EInputKey): void;
10
23
 
24
+ /**
25
+ * Sets the playback volume for incoming remote voice streams.
26
+ * @param value - Volume multiplier (`0.0` = muted, `1.0` = normal, higher = boosted).
27
+ */
11
28
  setOutputVolume(value: number): void;
29
+
30
+ /**
31
+ * Sets the recording gain applied to the local microphone before broadcasting.
32
+ * @param value - Volume multiplier (`0.0` to `1.0`).
33
+ */
12
34
  setInputVolume(value: number): void;
35
+
36
+ /**
37
+ * Sets the voice activity detection threshold.
38
+ * Audio below this level is silenced and not transmitted.
39
+ * @param value - Sensitivity cutoff value.
40
+ */
13
41
  setMicrophoneSensitivity(value: number): void;
14
42
 
43
+ /**
44
+ * Returns the names of all available audio output devices.
45
+ * @returns Array of device name strings.
46
+ */
15
47
  getOutputDevices(): string[];
48
+
49
+ /**
50
+ * Returns the names of all available audio input devices.
51
+ * @returns Array of device name strings.
52
+ */
16
53
  getInputDevices(): string[];
17
54
 
55
+ /**
56
+ * Selects the audio output device by its index in {@link getOutputDevices}.
57
+ * @param index - Device index.
58
+ */
18
59
  setOutputDevice(index: number): void;
60
+
61
+ /**
62
+ * Selects the microphone input device by its index in {@link getInputDevices}.
63
+ * @param index - Device index.
64
+ */
19
65
  setInputDevice(index: number): void;
20
66
 
67
+ /**
68
+ * Sets the maximum distance at which the local microphone transmits.
69
+ * @param distance - Transmission radius in world units.
70
+ */
21
71
  setInputDistance(distance: number): void;
72
+
73
+ /**
74
+ * Sets the maximum distance over which a remote player's voice attenuates to silence.
75
+ * @param distance - Audible radius in world units.
76
+ */
22
77
  setOutputDistance(distance: number): void;
23
78
 
79
+ /**
80
+ * Returns whether the voice chat system is initialized and connected.
81
+ * @returns `true` if active and ready, `false` otherwise.
82
+ */
24
83
  isActive(): boolean;
25
84
 
85
+ /**
86
+ * Returns whether the given player is currently transmitting voice audio.
87
+ * @param playerId - Target player's network ID.
88
+ * @returns `true` if the player is talking, `false` otherwise.
89
+ */
26
90
  isPlayerTalking(playerId: number): boolean;
27
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cybermp-community/client-types",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
4
4
  "description": "TypeScript type definitions for the CyberMP client-side environment.",
5
5
  "license": "CC BY-SA 4.0",
6
6
  "author": {
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "repository": {
15
15
  "type": "gitlab",
16
- "url": "https://gitlab.com/cybermp/types/client"
16
+ "url": "git+https://gitlab.com/cybermp/types/client.git"
17
17
  },
18
18
  "publishConfig": {
19
19
  "access": "public"
@@ -42,6 +42,8 @@
42
42
  "types:apply-modified": "tsx ./scripts/apply-modified.ts",
43
43
  "types:generate": "tsx ./src",
44
44
  "generate": "bun run dumps:generate && bun run types:apply-modified && bun run types:generate",
45
+ "build": "bun run generate",
46
+ "prepublishOnly": "bun run generate",
45
47
  "bump": "npm version patch --no-git-tag-version",
46
48
  "pub": "npm publish --access public"
47
49
  },