@nativewrappers/redm 0.0.96 → 0.0.98

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/entities/Ped.d.ts CHANGED
@@ -7,7 +7,7 @@ import { Attributes } from "../Attribute";
7
7
  import type { KnockOffVehicle, TamingState, eDamageCleanliness } from "../enums/Ped";
8
8
  import type { VehicleSeat } from "../enums/VehicleSeat";
9
9
  import { BaseEntity } from "./BaseEntity";
10
- import type { Player } from "./Player";
10
+ import { Player } from "./Player";
11
11
  import { Vehicle } from "./Vehicle";
12
12
  export declare class Ped extends BaseEntity {
13
13
  private attributes;
@@ -24,6 +24,7 @@ export declare class Ped extends BaseEntity {
24
24
  static fromNetworkId(netId: number): Ped | null;
25
25
  static fromStateBagName(bagName: string): Ped | null;
26
26
  constructor(handle: number);
27
+ get Player(): Player | null;
27
28
  /**
28
29
  * @returns the current horse or vehicle the ped is on, or null if they're not on either
29
30
  */
package/entities/Ped.js CHANGED
@@ -5,6 +5,7 @@ import { ItemAddReason } from "../inventory/InventoryTypes";
5
5
  import { _N } from "../utils/Native";
6
6
  import { Attributes } from "../Attribute";
7
7
  import { BaseEntity } from "./BaseEntity";
8
+ import { Player } from "./Player";
8
9
  import { Vehicle } from "./Vehicle";
9
10
  class Ped extends BaseEntity {
10
11
  static {
@@ -42,6 +43,13 @@ class Ped extends BaseEntity {
42
43
  constructor(handle) {
43
44
  super(handle);
44
45
  }
46
+ get Player() {
47
+ const playerId = NetworkGetPlayerIndexFromPed(this.handle);
48
+ if (playerId !== 255) {
49
+ return new Player(playerId);
50
+ }
51
+ return null;
52
+ }
45
53
  /**
46
54
  * @returns the current horse or vehicle the ped is on, or null if they're not on either
47
55
  */
@@ -13,19 +13,20 @@ export declare class Player {
13
13
  * @param [fromPlayer=GameConstants.Player] the player to get the distance from
14
14
  * @returns the closest player from {@param fromPlayer} and the distance the player was
15
15
  */
16
- static getClosestPlayerPedWithDistance(minimumDistance?: number, fromPlayer?: Player): [Ped | null, number];
16
+ static getClosestPlayerWithDistance(minimumDistance?: number, fromPlayer?: Player): [Player | null, number];
17
17
  /**
18
18
  * @param [minimumDistance=Number.MAX_VALUE] the minimum distance this should check
19
19
  * @param [fromPlayer=GameConstants.Player] the player to get the distance from
20
20
  * @returns the closest player from {@param fromPlayer} and the distance the player was
21
21
  */
22
- static getClosestPlayerPed(minimumDistance?: number, fromPlayer?: Player): Ped | null;
22
+ static getClosestPlayer(minimumDistance?: number, fromPlayer?: Player): Player | null;
23
23
  /**
24
24
  * @param handle the player handle
25
25
  */
26
26
  constructor(handle: number);
27
27
  get Handle(): number;
28
28
  get Ped(): Ped;
29
+ get ServerId(): number;
29
30
  /**
30
31
  * Adds the amount of stamina player has on the hud
31
32
  * @param amount the amount of upgrade to give 6 is half the bar while 12 is the full bar
@@ -43,7 +43,7 @@ class Player {
43
43
  * @param [fromPlayer=GameConstants.Player] the player to get the distance from
44
44
  * @returns the closest player from {@param fromPlayer} and the distance the player was
45
45
  */
46
- static getClosestPlayerPedWithDistance(minimumDistance = Number.MAX_VALUE, fromPlayer = GameConstants.Player) {
46
+ static getClosestPlayerWithDistance(minimumDistance = Number.MAX_VALUE, fromPlayer = GameConstants.Player) {
47
47
  const ped = fromPlayer.Ped;
48
48
  const pos = ped.Position;
49
49
  const data = [null, Number.MAX_VALUE];
@@ -51,7 +51,7 @@ class Player {
51
51
  const tgtPed = ply.Ped;
52
52
  const dist = pos.distance(tgtPed.Position);
53
53
  if (dist < data[1] && dist < minimumDistance) {
54
- data[0] = tgtPed;
54
+ data[0] = ply;
55
55
  data[1] = dist;
56
56
  }
57
57
  }
@@ -62,8 +62,8 @@ class Player {
62
62
  * @param [fromPlayer=GameConstants.Player] the player to get the distance from
63
63
  * @returns the closest player from {@param fromPlayer} and the distance the player was
64
64
  */
65
- static getClosestPlayerPed(minimumDistance = Number.MAX_VALUE, fromPlayer = GameConstants.Player) {
66
- const data = this.getClosestPlayerPedWithDistance(minimumDistance, fromPlayer);
65
+ static getClosestPlayer(minimumDistance = Number.MAX_VALUE, fromPlayer = GameConstants.Player) {
66
+ const data = this.getClosestPlayerWithDistance(minimumDistance, fromPlayer);
67
67
  return data[0];
68
68
  }
69
69
  /**
@@ -78,6 +78,9 @@ class Player {
78
78
  get Ped() {
79
79
  return new Ped(GetPlayerPed(this.handle));
80
80
  }
81
+ get ServerId() {
82
+ return GetPlayerServerId(this.handle);
83
+ }
81
84
  /**
82
85
  * Adds the amount of stamina player has on the hud
83
86
  * @param amount the amount of upgrade to give 6 is half the bar while 12 is the full bar
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "type": "module",
11
- "version": "0.0.96",
11
+ "version": "0.0.98",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"