@cybermp-community/server-types 1.0.2 → 1.0.4
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 +3 -4
- package/src/events/events.d.ts +52 -0
- package/src/events/index.d.ts +2 -52
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cybermp-community/server-types",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "TypeScript type definitions for the CyberMP server-side environment.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -17,12 +17,11 @@
|
|
|
17
17
|
"publishConfig": {
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
|
-
"main": "./src/index.d.ts",
|
|
21
20
|
"types": "./src/index.d.ts",
|
|
22
21
|
"exports": {
|
|
23
22
|
".": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
23
|
+
"import": "./src/index.d.ts",
|
|
24
|
+
"types": "./src/index.d.ts"
|
|
26
25
|
}
|
|
27
26
|
},
|
|
28
27
|
"files": [
|
|
@@ -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/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;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const mp: MpServer;
|