@nativewrappers/fivem 0.0.145 → 0.0.147

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.
@@ -6,8 +6,8 @@ export type MessageTypeEncoder<T> = {
6
6
  encode: (message: T) => any;
7
7
  name: string;
8
8
  };
9
- type ProtoCallback<Message> = (message: Message) => Promise<void>;
10
- type NetProtoCallback<Message> = (source: number, message: Message) => Promise<void>;
9
+ type ProtoCallback<Message> = (message: Message) => Promise<void> | void;
10
+ type NetProtoCallback<Message> = (source: number, message: Message) => Promise<void> | void;
11
11
  /**
12
12
  * PMA uses ts-proto to define our types, you can see that here: https://github.com/stephenh/ts-proto
13
13
  * You will have to modify the generator to add `name` or just use {@param eventName}
@@ -7,7 +7,7 @@ function parseSource(source) {
7
7
  }
8
8
  __name(parseSource, "parseSource");
9
9
  function OnProto(messageType, eventName) {
10
- const event = eventName ?? `pb:${messageType.name}`;
10
+ const event = eventName ?? `${messageType.name}`;
11
11
  return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
12
12
  if (context.private) {
13
13
  throw new Error("OnProto does not work on private methods");
@@ -26,7 +26,7 @@ function OnProto(messageType, eventName) {
26
26
  }
27
27
  __name(OnProto, "OnProto");
28
28
  function OnProtoNet(messageType, eventName) {
29
- const event = eventName ?? `pb:${messageType.name}`;
29
+ const event = eventName ?? `${messageType.name}`;
30
30
  return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
31
31
  if (context.private) {
32
32
  throw new Error("OnProto does not work on private methods");
package/common/net/Net.js CHANGED
@@ -18,8 +18,8 @@ class Net {
18
18
  addRawEventListener(eventName, cb);
19
19
  }
20
20
  static onRawNet(eventName, cb) {
21
- RegisterNetEvent(eventName);
22
21
  Net.onRaw(eventName, cb);
22
+ RegisterNetEvent(eventName);
23
23
  }
24
24
  }
25
25
  class NetServer extends Net {
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @param stateBag the state bag name to try to get the entity from
3
+ * @param [timeoutInMs=5000] the timeout we should wait before giving up.
4
+ */
5
+ export declare function WaitForEntityFromStateBagToExist(stateBag: string, timeoutInMs?: number): Promise<number | undefined>;
6
+ /**
7
+ * @param stateBag the state bag name to try to get the entity from
8
+ * @param [timeoutInMs=5000] the timeout we should wait before giving up.
9
+ */
10
+ export declare function WaitForPlayerFromStateBagToExist(stateBag: string, timeoutInMs?: number): Promise<number | undefined>;
@@ -0,0 +1,29 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Delay } from "../../common/utils/Delay";
4
+ async function WaitForEntityFromStateBagToExist(stateBag, timeoutInMs = 5e3) {
5
+ const timeout = GetGameTimer() + timeoutInMs;
6
+ let ent = GetEntityFromStateBagName(stateBag);
7
+ while (ent === 0) {
8
+ if (timeout < GetGameTimer()) break;
9
+ ent = GetEntityFromStateBagName(stateBag);
10
+ await Delay(150);
11
+ }
12
+ return ent !== 0 ? ent : void 0;
13
+ }
14
+ __name(WaitForEntityFromStateBagToExist, "WaitForEntityFromStateBagToExist");
15
+ async function WaitForPlayerFromStateBagToExist(stateBag, timeoutInMs = 5e3) {
16
+ const timeout = GetGameTimer() + timeoutInMs;
17
+ let ply = GetPlayerFromStateBagName(stateBag);
18
+ while (ply === 0) {
19
+ if (timeout < GetGameTimer()) break;
20
+ ply = GetPlayerFromStateBagName(stateBag);
21
+ await Delay(150);
22
+ }
23
+ return ply !== 0 ? ply : void 0;
24
+ }
25
+ __name(WaitForPlayerFromStateBagToExist, "WaitForPlayerFromStateBagToExist");
26
+ export {
27
+ WaitForEntityFromStateBagToExist,
28
+ WaitForPlayerFromStateBagToExist
29
+ };
package/index.d.ts CHANGED
@@ -152,6 +152,7 @@ export * from "./common-game/CommonGameConstants";
152
152
  export * from "./common-game/CommonModel";
153
153
  export * from "./common-game/CommonTasks";
154
154
  export * from "./common-game/utils/Animations";
155
+ export * from "./common-game/utils/StateBagWaits";
155
156
  export * from "./common-game/interfaces/Dimension";
156
157
  export * from "./common-game/enums/VehicleSeat";
157
158
  export * from "./common-game/entities/CommonBaseEntity";
@@ -172,7 +173,6 @@ export * from "./common-game/definitions/index.d";
172
173
  export * from "./common-game/definitions/redm.d";
173
174
  export * from "./common-game/cfx/StateBagChangeHandler";
174
175
  export * from "./common-game/cfx/cfx";
175
- export * from "./common/BaseScript";
176
176
  export * from "./common/Command";
177
177
  export * from "./common/Convar";
178
178
  export * from "./common/GlobalData";
package/index.js CHANGED
@@ -152,6 +152,7 @@ export * from "./common-game/CommonGameConstants";
152
152
  export * from "./common-game/CommonModel";
153
153
  export * from "./common-game/CommonTasks";
154
154
  export * from "./common-game/utils/Animations";
155
+ export * from "./common-game/utils/StateBagWaits";
155
156
  export * from "./common-game/interfaces/Dimension";
156
157
  export * from "./common-game/enums/VehicleSeat";
157
158
  export * from "./common-game/entities/CommonBaseEntity";
@@ -172,7 +173,6 @@ export * from "./common-game/definitions/index.d";
172
173
  export * from "./common-game/definitions/redm.d";
173
174
  export * from "./common-game/cfx/StateBagChangeHandler";
174
175
  export * from "./common-game/cfx/cfx";
175
- export * from "./common/BaseScript";
176
176
  export * from "./common/Command";
177
177
  export * from "./common/Convar";
178
178
  export * from "./common/GlobalData";
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "type": "module",
11
- "version": "0.0.145",
11
+ "version": "0.0.147",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"
@@ -1,2 +0,0 @@
1
- export declare abstract class BaseScript {
2
- }
@@ -1,10 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- class BaseScript {
4
- static {
5
- __name(this, "BaseScript");
6
- }
7
- }
8
- export {
9
- BaseScript
10
- };