@cybermp/client-types 1.8.1 → 2.0.1

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/out/mp.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { MpGame } from "./game.d.ts";
2
+
3
+ // THIS CODE IS GENERATED, PLEASE DO NOT EDIT THIS
4
+ export interface MpClient {
5
+ game: MpGame;
6
+ }
7
+
8
+ export * from "./precomputed/mp.d.ts";
@@ -1,5 +1,5 @@
1
- interface MpCef {
2
- setFocus(focus: boolean, cursor?: boolean): void;
3
- isInFocus(): boolean;
4
- setUrl(url: string): void;
5
- }
1
+ export interface MpCef {
2
+ setFocus(focus: boolean, cursor?: boolean): void;
3
+ isInFocus(): boolean;
4
+ setUrl(url: string): void;
5
+ }
@@ -1,3 +1,3 @@
1
- interface MpDiscord {
2
- updateRichPresence(state?: string, details?: string): void;
3
- }
1
+ export interface MpDiscord {
2
+ updateRichPresence(state?: string, details?: string): void;
3
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * See {@link worldWeatherState#name}
3
3
  */
4
- export enum WeatherState {
4
+ export enum EWeatherState {
5
5
  SUNNY = '24h_weather_sunny',
6
6
  LIGHT_CLOUDS = '24h_weather_light_clouds',
7
7
  CLOUDY = '24h_weather_cloudy',
@@ -19,7 +19,7 @@ export enum WeatherState {
19
19
  COURIER_CLOUDS = 'sa_courier_clouds',
20
20
  }
21
21
 
22
- export enum VoiceActivationType {
22
+ export enum EVoiceActivationType {
23
23
  UNDEFINED = 0,
24
24
  VOICE = 1,
25
25
  PUSH_TO_TALK = 2,
@@ -1,14 +1,4 @@
1
- interface MpEvents {
2
- on(
3
- eventName: 'onResourceStarted',
4
- callback: (resourceName: string) => void,
5
- ): void;
6
-
7
- on(
8
- eventName: 'onResourceStopped',
9
- callback: (resourceName: string) => void,
10
- ): void;
11
-
1
+ export interface MpEvents {
12
2
  /**
13
3
  * Register a custom event listener.
14
4
  * @param eventName Name of the event.
@@ -1,12 +1,11 @@
1
- /// <reference path="./enums.d.ts" />
2
- /// <reference path="../enums.d.ts" />
3
- /// <reference path="./primitives.d.ts" />
4
- /// <reference path="./classes.d.ts" />
5
- /// <reference path="../classes.d.ts" />
1
+ import type * as CyberEnums from '../enums';
2
+ import type { MpClasses, Vector3 } from '../game';
3
+
4
+ type UnwrapClass<T> = T extends { new (): infer U } ? U : T;
6
5
 
7
6
  type OverrideFunction = <
8
7
  C extends keyof MpClasses,
9
- I extends UnwrapMpClass<MpClasses[C]>,
8
+ I extends UnwrapClass<MpClasses[C]>,
10
9
  M extends keyof I extends never ? string : keyof I,
11
10
  >(
12
11
  className: C,
@@ -19,7 +18,7 @@ type OverrideFunction = <
19
18
 
20
19
  type ObserveFunction = <
21
20
  C extends keyof MpClasses,
22
- I extends UnwrapMpClass<MpClasses[C]>,
21
+ I extends UnwrapClass<MpClasses[C]>,
23
22
  M extends keyof I extends never ? string : keyof I,
24
23
  >(
25
24
  className: C,
@@ -39,122 +38,208 @@ interface TweakDB {
39
38
  createRecord(key: string, value: string): boolean;
40
39
  }
41
40
 
42
- interface MpGamePrecomputed {
43
- CyberMP: CyberMP;
44
- TweakDB: TweakDB;
45
-
46
- /**
47
- * Method to retrieve input events.
48
- */
49
- onInputKeyEvent(
50
- callback: (
51
- action: CyberEnums.EInputAction,
52
- key: CyberEnums.EInputKey,
53
- ) => void,
54
- ): void;
55
-
56
- getDisplayResolution(): [number, number];
57
-
58
- /**
59
- * Event when the game is started.
60
- */
61
- onGameLoaded(callback: () => void): void;
62
-
63
- /**
64
- * Event when tweaks is loaded.
65
- */
66
- onTweak(callback: () => void): void;
67
-
68
- /**
69
- * Event when tweaks is loaded.
70
- */
71
- onInit(callback: () => void): void;
72
-
73
- /**
74
- * Event when local player has been spawned.
75
- */
76
- onLocalPlayerSpawned(callback: () => void): void;
77
-
78
- /**
79
- * Get singleton.
80
- */
81
- getSingleton<T extends keyof MpClasses>(name: T): UnwrapMpClass<MpClasses[T]>;
82
-
41
+ interface CyberMP {
83
42
  /**
84
- * Add something to inventory.
43
+ * Removes game object classes (e.g., T extends gameObject, playerPuppet, NpcPuppet) from the map.
44
+ * @param objectClassMap Array of class names to delete.
85
45
  */
86
- AddToInventory(itemName: string, count: number): void;
46
+ DeclareDeletedObjects(objectClassMap: Array<keyof MpClasses>): void;
87
47
 
88
48
  /**
89
- * Returns model hash convertable to number.
90
- * @param name Model name
91
- * @param type Model name type
92
- * @returns Model hash
49
+ * Removes game objects by their unique hashes from the map.
50
+ * @param objectHashMap Array of unique game object hashes to delete.
93
51
  */
94
- getHashFromName(name: string, type: 'tweakdbid' | 'cname'): string;
52
+ DeletedObjectsByUniqueHash(objectHashMap: string[]): void;
95
53
 
96
54
  /**
97
- * Overrides method function inside selected class.
98
- * @param className Class name
99
- * @param methodName Method name inside of class
100
- * @param {selfFunction} func Function to override instead
55
+ * Enables or disables synchronization of default effects, as defined by the CyberMP platform.
56
+ * @param value Whether to use the default effects.
101
57
  */
102
- override: OverrideFunction;
58
+ UseDefaultEffectsByPlatform(value: boolean): void;
103
59
 
104
- /**
105
- * Observes method inside selected class.
106
- * @param className Class name
107
- * @param methodName Method name inside of class
108
- * @param {selfFunction} callback Callback of method function.
109
- */
110
- observeAfter: ObserveFunction;
111
-
112
- /**
113
- * Observes method inside selected class.
114
- * @param className Class name
115
- * @param methodName Method name inside of class
116
- * @param {selfFunction} callback Callback of method function.
117
- */
118
- observeBefore: ObserveFunction;
119
-
120
- /**
121
- * Alias for {@link observeBefore}.
122
- * @param className Class name
123
- * @param methodName Method name inside of class
124
- * @param {selfFunction} callback Callback of method function.
125
- */
126
- observe: ObserveFunction;
127
-
128
- /**
129
- * Observes method inside selected class. Can only call methods from {@link MpGame}.
130
- * Should be used when it's important for the function to execute quickly (as fast as V8 allows).
131
- * @param className Class name
132
- * @param methodName Method name inside of class
133
- * @param {selfFunction} callback Callback of method function.
134
- */
135
- observeAfterRaw: ObserveFunction;
136
-
137
- /**
138
- * Observes method inside selected class. Can only call methods from {@link MpGame}.
139
- * Should be used when it's important for the function to execute quickly (as fast as V8 allows).
140
- * @param className Class name
141
- * @param methodName Method name inside of class
142
- * @param {selfFunction} callback Callback of method function.
143
- */
144
- observeBeforeRaw: ObserveFunction;
145
-
146
- /**
147
- * Alias for {@link observeBeforeRaw}.
148
- * @param className Class name
149
- * @param methodName Method name inside of class
150
- * @param {selfFunction} callback Callback of method function.
151
- */
152
- observeRaw: ObserveFunction;
153
-
154
- toVariant<R = {}>(obj: any, str: string): R;
155
- fromVariant<R = any>(obj: any): R;
156
-
157
- isBlackScreenStarted(): boolean;
60
+ SetDefaultSpawnPosition(position: Vector3, yaw: number): void;
61
+ }
158
62
 
159
- isBlackScreenEnded(): boolean;
63
+ import '../game.d.ts';
64
+
65
+ declare module '../game.d.ts' {
66
+ export interface worldWeatherScriptInterface extends IScriptable {
67
+ SetWeather(
68
+ weather: CyberEnums.EWeatherState,
69
+ blendTime?: number,
70
+ priority?: number,
71
+ ): void;
72
+ ResetWeather(forceRestore?: boolean, blendTime?: number): void;
73
+ GetWeatherState(): worldWeatherState;
74
+ GetEnvironmentDefinition(): worldEnvironmentDefinition;
75
+ }
76
+
77
+ export interface vehicleBaseObject extends gameObject {
78
+ HasGravity(): boolean;
79
+ EnableGravity(enable: boolean): boolean;
80
+ AddLinelyVelocity(velocity: Vector3, angularVelocity: Vector3): boolean;
81
+ ChangeLinelyVelocity(
82
+ velocity: Vector3,
83
+ angularVelocity: Vector3,
84
+ switchIndex: number,
85
+ ): boolean;
86
+ GetVelocity(): Vector3;
87
+ GetAngularVelocity(): Vector3;
88
+ GetPhysicsState(): number;
89
+ IsOnGround(): boolean;
90
+ GetBoundaryBox(): Box;
91
+ VehicleOwnerWasChanged(): void;
92
+ }
93
+
94
+ export interface gameMappinSystem extends gamemappinsIMappinSystem {
95
+ TrackMappin(id: gameNewMappinID): void;
96
+ }
97
+
98
+ type OnlyExtendingScriptableSystem<T> = {
99
+ [K in keyof T as T[K] extends typeof gameScriptableSystem
100
+ ? K
101
+ : never]: T[K];
102
+ };
103
+
104
+ export interface gameScriptableSystemsContainer<
105
+ Map = OnlyExtendingScriptableSystem<MpClasses>,
106
+ > {
107
+ Get<N extends keyof Map>(systemName: N): UnwrapClass<Map[N]>;
108
+ }
109
+
110
+ export namespace ScriptGameInstance {
111
+ export function GetLoadingScreenSystem(): LoadingScreenSystem;
112
+ }
113
+
114
+ export class LoadingScreenSystem {
115
+ GetLoadingScreenState(): CyberEnums.ELoadingScreenState;
116
+ GetLoadingScreenProgress(): number;
117
+ OnLoadingScreenStateChange(newState: CyberEnums.ELoadingScreenState): void;
118
+ }
119
+
120
+ export interface inkISystemRequestsHandler {
121
+ StartMainMenu(): void;
122
+ }
123
+
124
+ export interface gameuiICharacterCustomizationSystem {
125
+ SetPlayerGender(gender: CyberEnums.EPlayerGender, savedPos?: boolean): void;
126
+ OnPlayerGenderChanged(gender: CyberEnums.EPlayerGender): void;
127
+ }
128
+
129
+ export interface MpClasses {
130
+ LoadingScreenSystem: typeof LoadingScreenSystem;
131
+ }
132
+
133
+ export interface MpGame {
134
+ CyberMP: CyberMP;
135
+ TweakDB: TweakDB;
136
+
137
+ onInputKeyEvent(
138
+ callback: (
139
+ action: CyberEnums.EInputAction,
140
+ key: CyberEnums.EInputKey,
141
+ ) => void,
142
+ ): void;
143
+
144
+ getDisplayResolution(): [width: number, height: number];
145
+
146
+ /**
147
+ * Event when the game is started.
148
+ */
149
+ onGameLoaded(callback: () => void): void;
150
+
151
+ /**
152
+ * Event when tweaks is loaded.
153
+ */
154
+ onTweak(callback: () => void): void;
155
+
156
+ /**
157
+ * Event when tweaks is loaded.
158
+ */
159
+ onInit(callback: () => void): void;
160
+
161
+ /**
162
+ * Event when local player has been spawned.
163
+ */
164
+ onLocalPlayerSpawned(callback: () => void): void;
165
+
166
+ /**
167
+ * Get singleton.
168
+ */
169
+ getSingleton<T extends keyof MpClasses>(name: T): UnwrapClass<MpClasses[T]>;
170
+
171
+ /**
172
+ * Add something to inventory.
173
+ */
174
+ AddToInventory(itemName: string, count: number): void;
175
+
176
+ /**
177
+ * Returns model hash convertable to number.
178
+ * @param name Model name
179
+ * @param type Model name type
180
+ * @returns Model hash
181
+ */
182
+ getHashFromName(name: string, type: 'tweakdbid' | 'cname'): string;
183
+
184
+ /**
185
+ * Overrides method function inside selected class.
186
+ * @param className Class name
187
+ * @param methodName Method name inside of class
188
+ * @param {selfFunction} func Function to override instead
189
+ */
190
+ override: OverrideFunction;
191
+
192
+ /**
193
+ * Observes method inside selected class.
194
+ * @param className Class name
195
+ * @param methodName Method name inside of class
196
+ * @param {selfFunction} callback Callback of method function.
197
+ */
198
+ observeAfter: ObserveFunction;
199
+
200
+ /**
201
+ * Observes method inside selected class.
202
+ * @param className Class name
203
+ * @param methodName Method name inside of class
204
+ * @param {selfFunction} callback Callback of method function.
205
+ */
206
+ observeBefore: ObserveFunction;
207
+
208
+ /**
209
+ * Alias for {@link observeBefore}.
210
+ * @param className Class name
211
+ * @param methodName Method name inside of class
212
+ * @param {selfFunction} callback Callback of method function.
213
+ */
214
+ observe: ObserveFunction;
215
+
216
+ /**
217
+ * Observes method inside selected class. Can only call methods from {@link MpGame}.
218
+ * Should be used when it's important for the function to execute quickly (as fast as V8 allows).
219
+ * @param className Class name
220
+ * @param methodName Method name inside of class
221
+ * @param {selfFunction} callback Callback of method function.
222
+ */
223
+ observeAfterRaw: ObserveFunction;
224
+
225
+ /**
226
+ * Observes method inside selected class. Can only call methods from {@link MpGame}.
227
+ * Should be used when it's important for the function to execute quickly (as fast as V8 allows).
228
+ * @param className Class name
229
+ * @param methodName Method name inside of class
230
+ * @param {selfFunction} callback Callback of method function.
231
+ */
232
+ observeBeforeRaw: ObserveFunction;
233
+
234
+ /**
235
+ * Alias for {@link observeBeforeRaw}.
236
+ * @param className Class name
237
+ * @param methodName Method name inside of class
238
+ * @param {selfFunction} callback Callback of method function.
239
+ */
240
+ observeRaw: ObserveFunction;
241
+
242
+ toVariant<R = Record<string, unknown>>(obj: any, str: string): R;
243
+ fromVariant<R = any>(obj: any): R;
244
+ }
160
245
  }
@@ -1,7 +1,11 @@
1
- /// <reference path="./primitives.d.ts" />
2
- /// <reference path="./classes.d.ts" />
3
- /// <reference path="./global.d.ts" />
4
- /// <reference path="./game.d.ts" />
5
- /// <reference path="./events.d.ts" />
6
- /// <reference path="./meta.d.ts" />
7
- /// <reference path="./enums.d.ts" />
1
+ export * from './cef';
2
+ export * from './classes';
3
+ export * from './discord';
4
+ export * from './enums';
5
+ export * from './events';
6
+ export * from './game';
7
+ export * from './local-storage';
8
+ export * from './meta';
9
+ export * from './mp';
10
+ export * from './primitives';
11
+ export * from './voice-chat';
@@ -1,7 +1,9 @@
1
- interface MpLocalStorage {
1
+ export interface MpLocalStorage {
2
2
  set(key: string, value: string): void;
3
3
  get(key: string): string;
4
+
4
5
  delete(key: string): void;
5
6
  deleteAll(): void;
7
+
6
8
  save(): void;
7
9
  }
@@ -1,15 +1,18 @@
1
- interface MpMeta {
2
- setGlobalMeta(key: string, value: any, sync?: boolean): void;
3
- getGlobalMeta<T = any>(key: string): T;
4
- setPlayerMeta(
5
- playerId: number,
6
- key: string,
7
- value: any,
8
- sync?: boolean,
9
- ): void;
10
- getPlayerMeta<T = any>(playerId: number, key: string): T;
11
- setEntityMeta(netId: number, key: string, value: any, sync?: boolean): void;
12
- getEntityMeta<T = any>(netId: number, key: string): T;
13
- setLocalPlayerMeta(key: string, value: any): void;
14
- getLocalPlayerMeta<T = any>(key: string): T;
15
- }
1
+ export interface MpMeta {
2
+ setGlobalMeta(key: string, value: any, sync?: boolean): void;
3
+ getGlobalMeta<T = any>(key: string): T;
4
+
5
+ setPlayerMeta(
6
+ playerId: number,
7
+ key: string,
8
+ value: any,
9
+ sync?: boolean,
10
+ ): void;
11
+ getPlayerMeta<T = any>(playerId: number, key: string): T;
12
+
13
+ setLocalPlayerMeta(key: string, value: any): void;
14
+ getLocalPlayerMeta<T = any>(key: string): T;
15
+
16
+ setEntityMeta(netId: number, key: string, value: any, sync?: boolean): void;
17
+ getEntityMeta<T = any>(netId: number, key: string): T;
18
+ }
@@ -0,0 +1,138 @@
1
+ import type { MpDiscord } from './discord';
2
+ import type { MpEvents } from './events';
3
+ import type { MpLocalStorage } from './local-storage';
4
+ import type { MpMeta } from './meta';
5
+ import type { MpVoiceChat } from './voice-chat';
6
+
7
+ type ServerVector3 = [number, number, number];
8
+ type ServerVector4 = [number, number, number, number];
9
+
10
+ import '../mp.d.ts';
11
+
12
+ declare module '../mp.d.ts' {
13
+ export interface MpClient {
14
+ events: MpEvents;
15
+ meta: MpMeta;
16
+ voiceChat: MpVoiceChat;
17
+ cef: MpCef;
18
+ discord: MpDiscord;
19
+ localStorage: MpLocalStorage;
20
+
21
+ getStreamedPool(
22
+ objName: 'CVehicle' | 'CPed' | 'CPickup' | 'CObject',
23
+ ): number[];
24
+ getStreamedPlayers(): number[];
25
+
26
+ /**
27
+ * Mapping between network and game IDs.
28
+ */
29
+ getVehicleGameIdByNetworkId(id: number): number;
30
+
31
+ getPlayerGameIdByNetworkId(id: number): number;
32
+
33
+ getObjectGameIdByNetworkId(id: number): number;
34
+
35
+ getVehicleNetworkIdByGameId(hash: number): number;
36
+
37
+ getPlayerNetworkIdByGameId(hash: number): number;
38
+
39
+ getObjectNetworkIdByGameId(hash: number): number;
40
+
41
+ getPedNetworkIdByGameId(hash: number): number;
42
+
43
+ getPedGameIdByNetworkId(hash: number): number;
44
+
45
+ /**
46
+ * Local player spawning API.
47
+ */
48
+ setSpawnDataLocalPlayer(x: number, y: number, z: number, yaw: number): void;
49
+
50
+ spawnLocalPlayer(): boolean;
51
+
52
+ /**
53
+ * Spawn local-only entities (not synced).
54
+ */
55
+ spawnLocalPed(
56
+ skinHash: number,
57
+ appHash: number,
58
+ x: number,
59
+ y: number,
60
+ z: number,
61
+ yaw: number,
62
+ streaming: boolean,
63
+ ): number;
64
+
65
+ spawnLocalVehicle(
66
+ skinHash: number,
67
+ appHash: number,
68
+ x: number,
69
+ y: number,
70
+ z: number,
71
+ roll: number,
72
+ pitch: number,
73
+ yaw: number,
74
+ streaming: boolean,
75
+ ): number;
76
+
77
+ spawnLocalObject(
78
+ skinHash: bigint | number,
79
+ appHash: bigint | number,
80
+ x: number,
81
+ y: number,
82
+ z: number,
83
+ roll: number,
84
+ pitch: number,
85
+ yaw: number,
86
+ streaming: boolean,
87
+ ): number;
88
+
89
+ despawnLocalPed(hash: number): void;
90
+
91
+ despawnLocalVehicle(hash: number): void;
92
+
93
+ despawnLocalObject(hash: number): void;
94
+
95
+ /**
96
+ * Get Discord token via game SDK (unstable).
97
+ */
98
+ getDiscordOAuth2Token(discordAppId: string): string;
99
+
100
+ /**
101
+ * Get Discord auth code (preferred).
102
+ */
103
+ getDiscordCodeAuthorization(discordAppId: string, scopes: string): string;
104
+
105
+ /**
106
+ * Returns current server IP:PORT string.
107
+ */
108
+ getCurrentServerEndpoint(): string;
109
+
110
+ /**
111
+ * Get server ID from player hash.
112
+ */
113
+ getPlayerServerId(playerHash: number): number;
114
+
115
+ /**
116
+ * Get src variable value as string.
117
+ */
118
+ getVar(varName: string): string;
119
+
120
+ /**
121
+ * Get console variable value as integer.
122
+ */
123
+ getVarInt(varName: string): number;
124
+
125
+ /**
126
+ * Returns time in ms since game start.
127
+ */
128
+ getGameTimer(): number;
129
+
130
+ getLauncherSettingsJSON(): string;
131
+
132
+ getLauncherSettings(): any;
133
+
134
+ setTick(cb: () => any): number;
135
+
136
+ clearTick(tickId: number): void;
137
+ }
138
+ }
@@ -1,19 +1,23 @@
1
- import * as CyberEnums from '../enums';
1
+ import type * as CyberEnums from '../enums';
2
2
 
3
- declare global {
4
- interface MpVoiceChat {
5
- enable(state: boolean): void;
6
- changeActivationType(type: CyberEnums.VoiceActivationType): void;
7
- bindPushToTalkKey(key: number | CyberEnums.EInputKey): void;
8
- setOutputVolume(value: number): void;
9
- setInputVolume(value: number): void;
10
- setMicrophoneSensitivity(value: number): void;
11
- getOutputDevices(): string[];
12
- getInputDevices(): string[];
13
- setOutputDevice(index: number): void;
14
- setInputDevice(index: number): void;
15
- setVoiceInputDistance(distance: number): void;
16
- setVoiceOutputDistance(distance: number): void;
17
- isActive(): boolean;
18
- }
3
+ export interface MpVoiceChat {
4
+ enable(state: boolean): void;
5
+
6
+ changeActivationType(type: CyberEnums.EVoiceActivationType): void;
7
+ bindPushToTalkKey(key: number | CyberEnums.EInputKey): void;
8
+
9
+ setOutputVolume(value: number): void;
10
+ setInputVolume(value: number): void;
11
+ setMicrophoneSensitivity(value: number): void;
12
+
13
+ getOutputDevices(): string[];
14
+ getInputDevices(): string[];
15
+
16
+ setOutputDevice(index: number): void;
17
+ setInputDevice(index: number): void;
18
+
19
+ setVoiceInputDistance(distance: number): void;
20
+ setVoiceOutputDistance(distance: number): void;
21
+
22
+ isActive(): boolean;
19
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cybermp/client-types",
3
- "version": "1.8.1",
3
+ "version": "2.0.1",
4
4
  "description": "",
5
5
  "types": "./out/index.d.ts",
6
6
  "files": [
@@ -13,8 +13,12 @@
13
13
  ],
14
14
  "exports": {
15
15
  ".": {
16
- "import": "./out/index.d.ts",
17
- "types": "./out/index.d.ts"
16
+ "import": "./out/mp.d.ts",
17
+ "types": "./out/mp.d.ts"
18
+ },
19
+ "./game": {
20
+ "import": "./out/game.d.ts",
21
+ "types": "./out/game.d.ts"
18
22
  },
19
23
  "./enums": {
20
24
  "import": "./out/enums.d.ts",