@nativewrappers/server 0.0.175 → 0.0.176

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.
@@ -1,5 +1,6 @@
1
1
  import { ClassTypes } from "../common/utils/ClassTypes";
2
2
  import { Vector3 } from "../common/utils/Vector";
3
+ import { PeerStatistics } from "../enum/PeerStatistics";
3
4
  import { Ped } from "./Ped";
4
5
  export declare class Player {
5
6
  private readonly source;
@@ -57,6 +58,14 @@ export declare class Player {
57
58
  * @returns the players round trip ping
58
59
  */
59
60
  get Ping(): number;
61
+ /**
62
+ * @returns the raw value of the specified ENet peer statistic for the player
63
+ */
64
+ getPeerStatistic(statistic: PeerStatistics): number;
65
+ /**
66
+ * @returns the players packet loss as a fraction (0.0 - 1.0), this only updates once every 10 seconds
67
+ */
68
+ get PacketLoss(): number;
60
69
  /**
61
70
  * @returns the current routhing bucket the player is in, default is 0
62
71
  */
@@ -4,6 +4,7 @@ import { ClassTypes } from "../common/utils/ClassTypes";
4
4
  import { Vector3 } from "../common/utils/Vector";
5
5
  import { cleanPlayerName } from "../common/utils/cleanPlayerName";
6
6
  import cfx from "../cfx";
7
+ import { ENET_PACKET_LOSS_SCALE, PeerStatistics } from "../enum/PeerStatistics";
7
8
  import { Ped } from "./Ped";
8
9
  class Player {
9
10
  constructor(source) {
@@ -111,6 +112,18 @@ class Player {
111
112
  get Ping() {
112
113
  return GetPlayerPing(this.Src);
113
114
  }
115
+ /**
116
+ * @returns the raw value of the specified ENet peer statistic for the player
117
+ */
118
+ getPeerStatistic(statistic) {
119
+ return GetPlayerPeerStatistics(this.Src, statistic);
120
+ }
121
+ /**
122
+ * @returns the players packet loss as a fraction (0.0 - 1.0), this only updates once every 10 seconds
123
+ */
124
+ get PacketLoss() {
125
+ return this.getPeerStatistic(PeerStatistics.PacketLoss) / ENET_PACKET_LOSS_SCALE;
126
+ }
114
127
  /**
115
128
  * @returns the current routhing bucket the player is in, default is 0
116
129
  */
@@ -0,0 +1,11 @@
1
+ export declare const ENET_PACKET_LOSS_SCALE = 65536;
2
+ export declare enum PeerStatistics {
3
+ PacketLoss = 0,
4
+ PacketLossVariance = 1,
5
+ PacketLossEpoch = 2,
6
+ RoundTripTime = 3,
7
+ RoundTripTimeVariance = 4,
8
+ LastRoundTripTime = 5,
9
+ LastRoundTripTimeVariance = 6,
10
+ PacketThrottleEpoch = 7
11
+ }
@@ -0,0 +1,16 @@
1
+ const ENET_PACKET_LOSS_SCALE = 65536;
2
+ var PeerStatistics = /* @__PURE__ */ ((PeerStatistics2) => {
3
+ PeerStatistics2[PeerStatistics2["PacketLoss"] = 0] = "PacketLoss";
4
+ PeerStatistics2[PeerStatistics2["PacketLossVariance"] = 1] = "PacketLossVariance";
5
+ PeerStatistics2[PeerStatistics2["PacketLossEpoch"] = 2] = "PacketLossEpoch";
6
+ PeerStatistics2[PeerStatistics2["RoundTripTime"] = 3] = "RoundTripTime";
7
+ PeerStatistics2[PeerStatistics2["RoundTripTimeVariance"] = 4] = "RoundTripTimeVariance";
8
+ PeerStatistics2[PeerStatistics2["LastRoundTripTime"] = 5] = "LastRoundTripTime";
9
+ PeerStatistics2[PeerStatistics2["LastRoundTripTimeVariance"] = 6] = "LastRoundTripTimeVariance";
10
+ PeerStatistics2[PeerStatistics2["PacketThrottleEpoch"] = 7] = "PacketThrottleEpoch";
11
+ return PeerStatistics2;
12
+ })(PeerStatistics || {});
13
+ export {
14
+ ENET_PACKET_LOSS_SCALE,
15
+ PeerStatistics
16
+ };
package/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from "./type/Anticheat";
5
5
  export * from "./type/Hash";
6
6
  export * from "./game/generateHash";
7
7
  export * from "./enum/OrphanMode";
8
+ export * from "./enum/PeerStatistics";
8
9
  export * from "./enum/PopulationType";
9
10
  export * from "./enum/VehicleLockStatus";
10
11
  export * from "./enum/VehicleType";
package/index.js CHANGED
@@ -5,6 +5,7 @@ export * from "./type/Anticheat";
5
5
  export * from "./type/Hash";
6
6
  export * from "./game/generateHash";
7
7
  export * from "./enum/OrphanMode";
8
+ export * from "./enum/PeerStatistics";
8
9
  export * from "./enum/PopulationType";
9
10
  export * from "./enum/VehicleLockStatus";
10
11
  export * from "./enum/VehicleType";
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "type": "module",
11
- "version": "0.0.175",
11
+ "version": "0.0.176",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"