@nativewrappers/server 0.0.44 → 0.0.46

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.
@@ -8,6 +8,7 @@ export declare class BaseEntity {
8
8
  protected handle: number;
9
9
  protected type: ClassTypes;
10
10
  constructor(handle: number);
11
+ replaceHandle(newHandle: number): void;
11
12
  static fromNetworkId(networkId: number): BaseEntity | null;
12
13
  static fromStateBagName(stateBagName: string): BaseEntity | null;
13
14
  get State(): StateBagInterface;
@@ -8,6 +8,28 @@ export class BaseEntity {
8
8
  constructor(handle) {
9
9
  this.handle = handle;
10
10
  }
11
+ // Replaces the current handle for the entity used on, this hsould be used sparringly, mainly
12
+ // in situations where you're going to reuse an entity over and over and don't want to make a
13
+ // new entity every time.
14
+ //
15
+ // **WARNING**: This does no checks, if you provide it an invalid entity it will use it
16
+ //
17
+ // ```ts
18
+ // const REUSABLE_ENTITY = new Entity(entityHandle);
19
+ //
20
+ // onNet("entityHandler", (entNetId: number) => {
21
+ // // if no net entity we should ignore
22
+ // const entId = NetworkGetEntityFromNetworkId(entNetId);
23
+ // if (entId === 0) return;
24
+ //
25
+ // // Reuse our entity so we don't have to initialize a new one
26
+ // REUSABLE_ENTITY.replaceHandle(entId);
27
+ // // Do something with REUSABLE_ENTITY entity
28
+ // })
29
+ // ```
30
+ replaceHandle(newHandle) {
31
+ this.handle = newHandle;
32
+ }
11
33
  static fromNetworkId(networkId) {
12
34
  const ent = NetworkGetEntityFromNetworkId(networkId);
13
35
  if (ent === 0)
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Remco Troost <d0p3t>",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "version": "0.0.44",
7
+ "version": "0.0.46",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/nativewrappers/fivem.git"
@@ -28,6 +28,6 @@
28
28
  ".": "./index.js"
29
29
  },
30
30
  "dependencies": {
31
- "@nativewrappers/common": "0.0.44"
31
+ "@nativewrappers/common": "0.0.46"
32
32
  }
33
33
  }