@cybermp-community/server-types 1.2.2 โ†’ 1.2.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.
package/README.md CHANGED
@@ -1,33 +1,48 @@
1
1
  # CyberMP Server Types
2
2
 
3
- This repository contains the TypeScript type definitions for the **[CyberMP](https://cyber.mp) multiplayer server**, providing comprehensive type safety and IntelliSense support for server-side development.
3
+ `@cybermp-community/server-types` types the global `mp` of the dedicated server: players, entities, vehicles, events, commands, and resource exports.
4
4
 
5
- These types are designed to work seamlessly with the CyberMP server environment, offering full typing for server events, player management, world state synchronization, and all server-side APIs exposed by the CyberMP multiplayer modification.
6
-
7
- ## ๐Ÿ“ฆ Installation
8
-
9
- Using NPM:
5
+ ## Installation
10
6
 
11
7
  ```bash
8
+ # npm
12
9
  npm install -D @cybermp-community/server-types
10
+
11
+ # pnpm
12
+ pnpm add -D @cybermp-community/server-types
13
+
14
+ # bun
15
+ bun add -d @cybermp-community/server-types
13
16
  ```
14
17
 
15
- Using PNPM:
18
+ ## Usage
16
19
 
17
- ```bash
18
- pnpm install -D @cybermp-community/server-types
20
+ `server/global.d.ts`:
21
+
22
+ ```ts
23
+ import type { MpServer } from "@cybermp-community/server-types";
24
+
25
+ declare global {
26
+ const mp: MpServer;
27
+ }
19
28
  ```
20
29
 
21
- Using Bun:
30
+ `server/index.ts` runs only on the dedicated server. Keep shared player state here. The first argument of `onClient` is the player who sent the event:
22
31
 
23
- ```bash
24
- bun add -d @cybermp-community/server-types
32
+ ```ts
33
+ mp.events.onClient("requestItem", (player, itemName: string) => {
34
+ player.emit("giveItem", itemName);
35
+ });
25
36
  ```
26
37
 
27
- ## ๐Ÿ“œ Disclaimer
38
+ `player.emit` is delivered to that player's client as `mp.events.onServer`.
39
+
40
+ Put `global.d.ts` next to the server scripts so `include` in `tsconfig.json` picks it up.
41
+
42
+ ## Disclaimer
28
43
 
29
- This repository is developed by [CyberMP Community Developers](https://gitlab.com/cybermp) and is not directly related to CyberMP (cyber.mp).
44
+ This repository is developed by [CyberMP Community Developers](https://gitlab.com/cybermp) and is separate from CyberMP (cyber.mp).
30
45
 
31
- ## โš–๏ธ License
46
+ ## License
32
47
 
33
- This project is licensed under the ะกะก BY-SA 4.0 License - see the [LICENSE](LICENSE) file for details.
48
+ CC BY-SA 4.0. See the [LICENSE](LICENSE) file for details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cybermp-community/server-types",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "TypeScript type definitions for the CyberMP server-side environment.",
5
5
  "license": "CC BY-SA 4.0",
6
6
  "author": {
@@ -48,3 +48,4 @@
48
48
  "@biomejs/biome": "^2.0.0"
49
49
  }
50
50
  }
51
+
package/src/commands.ts CHANGED
@@ -4,9 +4,9 @@ export interface MpCommands {
4
4
  /**
5
5
  * Register a command in the server scope.
6
6
  * @param commandName Command name without "/".
7
- * @param callback Callback with player and args.
7
+ * @param callback Callback with the player, or `null` from the server console, and args.
8
8
  */
9
- add(commandName: string, callback: (player: MpPlayer, args: string[]) => void): void;
9
+ add(commandName: string, callback: (player: MpPlayer | null, args: string[]) => void): void;
10
10
 
11
11
  /**
12
12
  * Unregister a command.