@cybermp/client-types 1.8.0 → 2.0.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/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,9 @@
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';
6
3
 
7
4
  type OverrideFunction = <
8
5
  C extends keyof MpClasses,
9
- I extends UnwrapMpClass<MpClasses[C]>,
6
+ I extends UnwrapClass<MpClasses[C]>,
10
7
  M extends keyof I extends never ? string : keyof I,
11
8
  >(
12
9
  className: C,
@@ -19,7 +16,7 @@ type OverrideFunction = <
19
16
 
20
17
  type ObserveFunction = <
21
18
  C extends keyof MpClasses,
22
- I extends UnwrapMpClass<MpClasses[C]>,
19
+ I extends UnwrapClass<MpClasses[C]>,
23
20
  M extends keyof I extends never ? string : keyof I,
24
21
  >(
25
22
  className: C,
@@ -39,122 +36,208 @@ interface TweakDB {
39
36
  createRecord(key: string, value: string): boolean;
40
37
  }
41
38
 
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
-
39
+ interface CyberMP {
83
40
  /**
84
- * Add something to inventory.
41
+ * Removes game object classes (e.g., T extends gameObject, playerPuppet, NpcPuppet) from the map.
42
+ * @param objectClassMap Array of class names to delete.
85
43
  */
86
- AddToInventory(itemName: string, count: number): void;
44
+ DeclareDeletedObjects(objectClassMap: Array<keyof MpClasses>): void;
87
45
 
88
46
  /**
89
- * Returns model hash convertable to number.
90
- * @param name Model name
91
- * @param type Model name type
92
- * @returns Model hash
47
+ * Removes game objects by their unique hashes from the map.
48
+ * @param objectHashMap Array of unique game object hashes to delete.
93
49
  */
94
- getHashFromName(name: string, type: 'tweakdbid' | 'cname'): string;
50
+ DeletedObjectsByUniqueHash(objectHashMap: string[]): void;
95
51
 
96
52
  /**
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
53
+ * Enables or disables synchronization of default effects, as defined by the CyberMP platform.
54
+ * @param value Whether to use the default effects.
101
55
  */
102
- override: OverrideFunction;
56
+ UseDefaultEffectsByPlatform(value: boolean): void;
103
57
 
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;
58
+ SetDefaultSpawnPosition(position: Vector3, yaw: number): void;
59
+ }
158
60
 
159
- isBlackScreenEnded(): boolean;
61
+ import '../game.d.ts';
62
+
63
+ declare module '../game.d.ts' {
64
+ export interface worldWeatherScriptInterface extends IScriptable {
65
+ SetWeather(
66
+ weather: CyberEnums.EWeatherState,
67
+ blendTime?: number,
68
+ priority?: number,
69
+ ): void;
70
+ ResetWeather(forceRestore?: boolean, blendTime?: number): void;
71
+ GetWeatherState(): worldWeatherState;
72
+ GetEnvironmentDefinition(): worldEnvironmentDefinition;
73
+ }
74
+
75
+ export interface vehicleBaseObject extends gameObject {
76
+ HasGravity(): boolean;
77
+ EnableGravity(enable: boolean): boolean;
78
+ AddLinelyVelocity(velocity: Vector3, angularVelocity: Vector3): boolean;
79
+ ChangeLinelyVelocity(
80
+ velocity: Vector3,
81
+ angularVelocity: Vector3,
82
+ switchIndex: number,
83
+ ): boolean;
84
+ GetVelocity(): Vector3;
85
+ GetAngularVelocity(): Vector3;
86
+ GetPhysicsState(): number;
87
+ IsOnGround(): boolean;
88
+ GetBoundaryBox(): Box;
89
+ VehicleOwnerWasChanged(): void;
90
+ }
91
+
92
+ export interface gameMappinSystem extends gamemappinsIMappinSystem {
93
+ TrackMappin(id: gameNewMappinID): void;
94
+ }
95
+
96
+ type OnlyExtendingScriptableSystem<T> = {
97
+ [K in keyof T as T[K] extends typeof gameScriptableSystem
98
+ ? K
99
+ : never]: T[K];
100
+ };
101
+
102
+ export interface gameScriptableSystemsContainer<
103
+ Map = OnlyExtendingScriptableSystem<MpClasses>,
104
+ > {
105
+ Get<N extends keyof Map>(systemName: N): UnwrapClass<Map[N]>;
106
+ }
107
+
108
+ export namespace ScriptGameInstance {
109
+ export function GetLoadingScreenSystem(): LoadingScreenSystem;
110
+ }
111
+
112
+ export class LoadingScreenSystem {
113
+ GetLoadingScreenState(): CyberEnums.ELoadingScreenState;
114
+ GetLoadingScreenProgress(): number;
115
+ OnLoadingScreenStateChange(newState: CyberEnums.ELoadingScreenState): void;
116
+ }
117
+
118
+ export interface inkISystemRequestsHandler {
119
+ StartMainMenu(): void;
120
+ }
121
+
122
+ export interface gameuiICharacterCustomizationSystem {
123
+ SetPlayerGender(gender: CyberEnums.EPlayerGender, savedPos?: boolean): void;
124
+ OnPlayerGenderChanged(gender: CyberEnums.EPlayerGender): void;
125
+ }
126
+
127
+ export interface MpClasses {
128
+ LoadingScreenSystem: typeof LoadingScreenSystem;
129
+ }
130
+
131
+ export interface MpGame {
132
+ CyberMP: CyberMP;
133
+ TweakDB: TweakDB;
134
+
135
+ onInputKeyEvent(
136
+ callback: (
137
+ action: CyberEnums.EInputAction,
138
+ key: CyberEnums.EInputKey,
139
+ ) => void,
140
+ ): void;
141
+
142
+ getDisplayResolution(): [width: number, height: number];
143
+
144
+ /**
145
+ * Event when the game is started.
146
+ */
147
+ onGameLoaded(callback: () => void): void;
148
+
149
+ /**
150
+ * Event when tweaks is loaded.
151
+ */
152
+ onTweak(callback: () => void): void;
153
+
154
+ /**
155
+ * Event when tweaks is loaded.
156
+ */
157
+ onInit(callback: () => void): void;
158
+
159
+ /**
160
+ * Event when local player has been spawned.
161
+ */
162
+ onLocalPlayerSpawned(callback: () => void): void;
163
+
164
+ /**
165
+ * Get singleton.
166
+ */
167
+ getSingleton<T extends keyof MpClasses>(name: T): UnwrapClass<MpClasses[T]>;
168
+
169
+ /**
170
+ * Add something to inventory.
171
+ */
172
+ AddToInventory(itemName: string, count: number): void;
173
+
174
+ /**
175
+ * Returns model hash convertable to number.
176
+ * @param name Model name
177
+ * @param type Model name type
178
+ * @returns Model hash
179
+ */
180
+ getHashFromName(name: string, type: 'tweakdbid' | 'cname'): string;
181
+
182
+ /**
183
+ * Overrides method function inside selected class.
184
+ * @param className Class name
185
+ * @param methodName Method name inside of class
186
+ * @param {selfFunction} func Function to override instead
187
+ */
188
+ override: OverrideFunction;
189
+
190
+ /**
191
+ * Observes method inside selected class.
192
+ * @param className Class name
193
+ * @param methodName Method name inside of class
194
+ * @param {selfFunction} callback Callback of method function.
195
+ */
196
+ observeAfter: ObserveFunction;
197
+
198
+ /**
199
+ * Observes method inside selected class.
200
+ * @param className Class name
201
+ * @param methodName Method name inside of class
202
+ * @param {selfFunction} callback Callback of method function.
203
+ */
204
+ observeBefore: ObserveFunction;
205
+
206
+ /**
207
+ * Alias for {@link observeBefore}.
208
+ * @param className Class name
209
+ * @param methodName Method name inside of class
210
+ * @param {selfFunction} callback Callback of method function.
211
+ */
212
+ observe: ObserveFunction;
213
+
214
+ /**
215
+ * Observes method inside selected class. Can only call methods from {@link MpGame}.
216
+ * Should be used when it's important for the function to execute quickly (as fast as V8 allows).
217
+ * @param className Class name
218
+ * @param methodName Method name inside of class
219
+ * @param {selfFunction} callback Callback of method function.
220
+ */
221
+ observeAfterRaw: ObserveFunction;
222
+
223
+ /**
224
+ * Observes method inside selected class. Can only call methods from {@link MpGame}.
225
+ * Should be used when it's important for the function to execute quickly (as fast as V8 allows).
226
+ * @param className Class name
227
+ * @param methodName Method name inside of class
228
+ * @param {selfFunction} callback Callback of method function.
229
+ */
230
+ observeBeforeRaw: ObserveFunction;
231
+
232
+ /**
233
+ * Alias for {@link observeBeforeRaw}.
234
+ * @param className Class name
235
+ * @param methodName Method name inside of class
236
+ * @param {selfFunction} callback Callback of method function.
237
+ */
238
+ observeRaw: ObserveFunction;
239
+
240
+ toVariant<R = Record<string, unknown>>(obj: any, str: string): R;
241
+ fromVariant<R = any>(obj: any): R;
242
+ }
160
243
  }
@@ -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,25 +1,13 @@
1
- type UnwrapMpClass<T> = T extends { new (): infer U } ? U : T;
2
- type CName = string;
3
- type Handle<T = any> = T;
4
- type WeakHandle<T = any> = T;
5
- type ScriptRef<T = any> = T;
6
- type NodeRef<T = any> = T;
7
- type TweakDBID = string;
8
- type CRUID = any;
9
- type CGUID = any;
10
- type Variant = any;
11
- type LocalizationString = string;
12
- type Uint16 = number;
13
- type Uint8 = number;
14
- type Int8 = number;
15
- type Int16 = number;
16
- type Int32 = number;
17
- type DataBuffer = any;
18
- type serializationDeferredDataBuffer = any;
19
- type SharedDataBuffer = any;
20
- type EditorObjectID = any;
21
- type MessageResourcePath = any;
22
- type ResAsyncRef<T> = T;
23
- type CurveData<T> = T;
24
- type ResRef<T> = T;
25
- type MultiChannelCurve<T> = T;
1
+ declare global {
2
+ type UnwrapClass<T> = T extends { new (): infer U } ? U : T;
3
+ type Handle<T = any> = T;
4
+ type WeakHandle<T = any> = T;
5
+ type ScriptRef<T = any> = T;
6
+ type NodeRef<T = any> = T;
7
+ type ResAsyncRef<T> = T;
8
+ type CurveData<T> = T;
9
+ type ResRef<T> = T;
10
+ type MultiChannelCurve<T> = T;
11
+ }
12
+
13
+ export {};
@@ -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
  }