@cybermp-community/server-types 1.0.3 → 1.0.5
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/events/events.d.ts +52 -0
- package/src/events/index.d.ts +2 -52
- package/src/hashes.d.ts +20 -0
- package/src/mp/index.d.ts +2 -38
- package/src/mp/internal-multiplayer.d.ts +13 -0
- package/src/mp/multiplayer.d.ts +38 -0
- package/src/resources.d.ts +4 -0
- package/src/voice-chat.d.ts +18 -1
package/package.json
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { MpPlayer } from "../entities";
|
|
2
|
+
import { MpEventsMap } from "./map";
|
|
3
|
+
|
|
4
|
+
export interface MpEvents {
|
|
5
|
+
/**
|
|
6
|
+
* Listen for a shared (server or client) custom event.
|
|
7
|
+
* @param eventName The name of the custom event.
|
|
8
|
+
* @param callback The callback to run when triggered.
|
|
9
|
+
*/
|
|
10
|
+
on<E extends keyof MpEventsMap>(eventName: E, callback: MpEventsMap[E]): void;
|
|
11
|
+
on(eventName: string, callback: (...args: any[]) => void): void;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Listen for a client-side event on the server.
|
|
15
|
+
* @param eventName The name of the event.
|
|
16
|
+
* @param callback Function triggered when the event is received.
|
|
17
|
+
*/
|
|
18
|
+
onClient(
|
|
19
|
+
eventName: string,
|
|
20
|
+
callback: (player: MpPlayer, ...args: any[]) => void,
|
|
21
|
+
): void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Unregister a custom event listener.
|
|
25
|
+
* @param eventName Name of the event.
|
|
26
|
+
* @param callback Callback function.
|
|
27
|
+
*/
|
|
28
|
+
off<E extends keyof MpEventsMap>(
|
|
29
|
+
eventName: E,
|
|
30
|
+
callback: MpEventsMap[E],
|
|
31
|
+
): void;
|
|
32
|
+
off(eventName: string, callback: (...args: any[]) => void): void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Emit a shared custom event.
|
|
36
|
+
* @param eventName The event name to emit.
|
|
37
|
+
* @param args Arguments to pass to the handler.
|
|
38
|
+
*/
|
|
39
|
+
emit(eventName: string, ...args: any[]): void;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Emit a client-side event from the server.
|
|
43
|
+
* @param eventName Resource name to emit from.
|
|
44
|
+
* @param playerId Target player entity/network ID.
|
|
45
|
+
* @param args Arguments to send with the event.
|
|
46
|
+
*/
|
|
47
|
+
emitClient(
|
|
48
|
+
player: MpPlayer | number,
|
|
49
|
+
eventName: string,
|
|
50
|
+
...args: any[]
|
|
51
|
+
): void;
|
|
52
|
+
}
|
package/src/events/index.d.ts
CHANGED
|
@@ -1,52 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export interface MpEvents {
|
|
5
|
-
/**
|
|
6
|
-
* Listen for a shared (server or client) custom event.
|
|
7
|
-
* @param eventName The name of the custom event.
|
|
8
|
-
* @param callback The callback to run when triggered.
|
|
9
|
-
*/
|
|
10
|
-
on<E extends keyof MpEventsMap>(eventName: E, callback: MpEventsMap[E]): void;
|
|
11
|
-
on(eventName: string, callback: (...args: any[]) => void): void;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Listen for a client-side event on the server.
|
|
15
|
-
* @param eventName The name of the event.
|
|
16
|
-
* @param callback Function triggered when the event is received.
|
|
17
|
-
*/
|
|
18
|
-
onClient(
|
|
19
|
-
eventName: string,
|
|
20
|
-
callback: (player: MpPlayer, ...args: any[]) => void,
|
|
21
|
-
): void;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Unregister a custom event listener.
|
|
25
|
-
* @param eventName Name of the event.
|
|
26
|
-
* @param callback Callback function.
|
|
27
|
-
*/
|
|
28
|
-
off<E extends keyof MpEventsMap>(
|
|
29
|
-
eventName: E,
|
|
30
|
-
callback: MpEventsMap[E],
|
|
31
|
-
): void;
|
|
32
|
-
off(eventName: string, callback: (...args: any[]) => void): void;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Emit a shared custom event.
|
|
36
|
-
* @param eventName The event name to emit.
|
|
37
|
-
* @param args Arguments to pass to the handler.
|
|
38
|
-
*/
|
|
39
|
-
emit(eventName: string, ...args: any[]): void;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Emit a client-side event from the server.
|
|
43
|
-
* @param eventName Resource name to emit from.
|
|
44
|
-
* @param playerId Target player entity/network ID.
|
|
45
|
-
* @param args Arguments to send with the event.
|
|
46
|
-
*/
|
|
47
|
-
emitClient(
|
|
48
|
-
player: MpPlayer | number,
|
|
49
|
-
eventName: string,
|
|
50
|
-
...args: any[]
|
|
51
|
-
): void;
|
|
52
|
-
}
|
|
1
|
+
export * from "./events";
|
|
2
|
+
export * from "./map";
|
package/src/hashes.d.ts
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
import type { CName, ResRef, TweakDBID } from './shared';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Interface providing utility methods to hash object paths into internal types.
|
|
5
|
+
*/
|
|
3
6
|
export interface MpHashes {
|
|
7
|
+
/**
|
|
8
|
+
* Converts a string path into a TweakDBID hash.
|
|
9
|
+
* @param path - The string path of entry.
|
|
10
|
+
* @returns The corresponding TweakDBID.
|
|
11
|
+
*/
|
|
4
12
|
tweakdbid(path: string): TweakDBID;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Converts a string path into a CName hash.
|
|
16
|
+
* @param path - The string path of entry.
|
|
17
|
+
* @returns The corresponding CName.
|
|
18
|
+
*/
|
|
5
19
|
cname(path: string): CName;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Converts a string path into a ResRef hash.
|
|
23
|
+
* @param path - The string path of entry.
|
|
24
|
+
* @returns The corresponding ResRef.
|
|
25
|
+
*/
|
|
6
26
|
resref(path: string): ResRef;
|
|
7
27
|
}
|
package/src/mp/index.d.ts
CHANGED
|
@@ -1,38 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { MpEvents } from '../events';
|
|
4
|
-
import type { MpHashes } from '../hashes';
|
|
5
|
-
import type { MpMeta } from '../meta';
|
|
6
|
-
import type { MpObjects } from '../objects';
|
|
7
|
-
import type { MpPeds } from '../peds';
|
|
8
|
-
import type { MpPickups } from '../pickups';
|
|
9
|
-
import type { MpPlayers } from '../entities/player';
|
|
10
|
-
import type { MpResources } from '../resources';
|
|
11
|
-
import type { MpVehicles } from '../vehicles';
|
|
12
|
-
import type { MpServer as MpServ } from './config';
|
|
13
|
-
import type { MpExports } from '../exports';
|
|
14
|
-
|
|
15
|
-
export interface MpServer {
|
|
16
|
-
events: MpEvents;
|
|
17
|
-
exports: MpExports;
|
|
18
|
-
meta: MpMeta;
|
|
19
|
-
resources: MpResources;
|
|
20
|
-
commands: MpCommands;
|
|
21
|
-
entities: MpEntities;
|
|
22
|
-
vehicles: MpVehicles;
|
|
23
|
-
players: MpPlayers;
|
|
24
|
-
objects: MpObjects;
|
|
25
|
-
pickups: MpPickups;
|
|
26
|
-
peds: MpPeds;
|
|
27
|
-
hashes: MpHashes;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Checks if the code is running on the server.
|
|
31
|
-
* @returns True if running on server, false otherwise.
|
|
32
|
-
*/
|
|
33
|
-
isServer(): boolean;
|
|
34
|
-
|
|
35
|
-
config: MpServ.ServerConfig;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const mp: MpServer;
|
|
1
|
+
export * from "./multiplayer"
|
|
2
|
+
export * from "./internal-multiplayer";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MpVoiceChat } from '../voice-chat';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated This interface will be removed in future versions.
|
|
5
|
+
*/
|
|
6
|
+
export interface InternalMpServer {
|
|
7
|
+
voiceChat: MpVoiceChat
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated This variable will be removed in future versions.
|
|
12
|
+
*/
|
|
13
|
+
export const internalMp: InternalMpServer;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { MpCommands } from '../commands';
|
|
2
|
+
import type { MpEntities } from '../entities';
|
|
3
|
+
import type { MpEvents } from '../events';
|
|
4
|
+
import type { MpHashes } from '../hashes';
|
|
5
|
+
import type { MpMeta } from '../meta';
|
|
6
|
+
import type { MpObjects } from '../objects';
|
|
7
|
+
import type { MpPeds } from '../peds';
|
|
8
|
+
import type { MpPickups } from '../pickups';
|
|
9
|
+
import type { MpPlayers } from '../entities/player';
|
|
10
|
+
import type { MpResources } from '../resources';
|
|
11
|
+
import type { MpVehicles } from '../vehicles';
|
|
12
|
+
import type { MpServer as MpServ } from './config';
|
|
13
|
+
import type { MpExports } from '../exports';
|
|
14
|
+
|
|
15
|
+
export interface MpServer {
|
|
16
|
+
events: MpEvents;
|
|
17
|
+
exports: MpExports;
|
|
18
|
+
meta: MpMeta;
|
|
19
|
+
resources: MpResources;
|
|
20
|
+
commands: MpCommands;
|
|
21
|
+
entities: MpEntities;
|
|
22
|
+
vehicles: MpVehicles;
|
|
23
|
+
players: MpPlayers;
|
|
24
|
+
objects: MpObjects;
|
|
25
|
+
pickups: MpPickups;
|
|
26
|
+
peds: MpPeds;
|
|
27
|
+
hashes: MpHashes;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Checks if the code is running on the server.
|
|
31
|
+
* @returns True if running on server, false otherwise.
|
|
32
|
+
*/
|
|
33
|
+
isServer(): boolean;
|
|
34
|
+
|
|
35
|
+
config: MpServ.ServerConfig & Record<string, string>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const mp: MpServer;
|
package/src/resources.d.ts
CHANGED
package/src/voice-chat.d.ts
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import type { MpPlayer } from './entities';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing the voice chat management system on the server.
|
|
5
|
+
*/
|
|
3
6
|
export interface MpVoiceChat {
|
|
4
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Mutes or unmutes a specific player.
|
|
9
|
+
* @param player - The player instance or their unique ID.
|
|
10
|
+
* @param state - Set to `true` to mute, `false` to unmute.
|
|
11
|
+
*/
|
|
12
|
+
mutePlayer(player: MpPlayer | number, state: boolean): void;
|
|
5
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new voice chat channel.
|
|
16
|
+
* @param voiceId - The unique identifier for the voice channel.
|
|
17
|
+
*/
|
|
6
18
|
createChannel(voiceId: number): void;
|
|
7
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Checks whether a specific player is currently muted in the voice chat.
|
|
22
|
+
* @param player - The player instance or their unique ID.
|
|
23
|
+
* @returns `true` if the player is muted, `false` otherwise.
|
|
24
|
+
*/
|
|
8
25
|
isPlayerMuted(player: MpPlayer | number): boolean;
|
|
9
26
|
}
|