@nativewrappers/fivem 0.0.103 → 0.0.104

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.
@@ -11,8 +11,16 @@ export declare class Player {
11
11
  private source;
12
12
  private type;
13
13
  static AllPlayers(excludeLocalPlayer?: boolean): IterableIterator<Player>;
14
- static fromPedHandle(handle: number): Player;
15
- static fromServerId(serverId: number): Player;
14
+ /**
15
+ * @param handle the handoe of the ped to get the player of
16
+ * @returns the player, or null if the player doesn't exist
17
+ */
18
+ static fromPedHandle(handle: number): Player | null;
19
+ /**
20
+ * @param serverId the server id to get the player of
21
+ * @returns the player, or null if the player doesn't exist
22
+ */
23
+ static fromServerId(serverId: number): Player | null;
16
24
  /**
17
25
  * @param [minimumDistance=Number.MAX_VALUE] the minimum distance this should check
18
26
  * @param [fromPlayer=GameConstants.Player] the player to get the distance from
package/models/Player.js CHANGED
@@ -25,11 +25,27 @@ class Player {
25
25
  yield new Player(ply);
26
26
  }
27
27
  }
28
+ /**
29
+ * @param handle the handoe of the ped to get the player of
30
+ * @returns the player, or null if the player doesn't exist
31
+ */
28
32
  static fromPedHandle(handle) {
29
- return new Player(NetworkGetPlayerIndexFromPed(handle));
33
+ const playerHandle = NetworkGetPlayerIndexFromPed(handle);
34
+ if (!handle) {
35
+ return null;
36
+ }
37
+ return new Player(playerHandle);
30
38
  }
39
+ /**
40
+ * @param serverId the server id to get the player of
41
+ * @returns the player, or null if the player doesn't exist
42
+ */
31
43
  static fromServerId(serverId) {
32
- return new Player(GetPlayerFromServerId(serverId));
44
+ const player = GetPlayerFromServerId(serverId);
45
+ if (player === -1) {
46
+ return null;
47
+ }
48
+ return new Player(player);
33
49
  }
34
50
  /**
35
51
  * @param [minimumDistance=Number.MAX_VALUE] the minimum distance this should check
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "type": "module",
11
- "version": "0.0.103",
11
+ "version": "0.0.104",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"