@nativewrappers/fivem 0.0.159 → 0.0.160

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.
@@ -0,0 +1,18 @@
1
+ export declare enum State {
2
+ Uninitialized = 0,
3
+ Initialized = 1,
4
+ Enabled = 2
5
+ }
6
+ export declare class BaseScript {
7
+ private state;
8
+ private events;
9
+ private exports;
10
+ private ticks;
11
+ private statebags;
12
+ private convars;
13
+ get IsEnabled(): boolean;
14
+ start(): void;
15
+ stop(): void;
16
+ startTick(name: string): void;
17
+ stopTick(name: string): void;
18
+ }
@@ -0,0 +1,36 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ var State = /* @__PURE__ */ ((State2) => {
4
+ State2[State2["Uninitialized"] = 0] = "Uninitialized";
5
+ State2[State2["Initialized"] = 1] = "Initialized";
6
+ State2[State2["Enabled"] = 2] = "Enabled";
7
+ return State2;
8
+ })(State || {});
9
+ class BaseScript {
10
+ static {
11
+ __name(this, "BaseScript");
12
+ }
13
+ state = 0 /* Uninitialized */;
14
+ events = /* @__PURE__ */ new Map();
15
+ exports = /* @__PURE__ */ new Map();
16
+ ticks = /* @__PURE__ */ new Map();
17
+ statebags = /* @__PURE__ */ new Map();
18
+ convars = /* @__PURE__ */ new Map();
19
+ // TODO:
20
+ // Commands?
21
+ get IsEnabled() {
22
+ return (this.state & 2 /* Enabled */) !== 0;
23
+ }
24
+ start() {
25
+ }
26
+ stop() {
27
+ }
28
+ startTick(name) {
29
+ }
30
+ stopTick(name) {
31
+ }
32
+ }
33
+ export {
34
+ BaseScript,
35
+ State
36
+ };
@@ -1,10 +1,10 @@
1
1
  export type MessageTypeDecoder<T> = {
2
2
  decode: (input: Uint8Array) => T;
3
- name: string;
3
+ __proto_name__: string;
4
4
  };
5
5
  export type MessageTypeEncoder<T> = {
6
6
  encode: (message: T) => any;
7
- name: string;
7
+ __proto_name__: string;
8
8
  };
9
9
  type ProtoCallback<Message> = (message: Message) => Promise<void> | void;
10
10
  type NetProtoCallback<Message> = (message: Message, source: number) => Promise<void> | void;
@@ -7,7 +7,7 @@ function parseSource(source) {
7
7
  }
8
8
  __name(parseSource, "parseSource");
9
9
  function OnProto(messageType, eventName) {
10
- const event = eventName ?? `${messageType.name}`;
10
+ const event = eventName ?? `${messageType.__proto_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 ?? `${messageType.name}`;
29
+ const event = eventName ?? `${messageType.__proto_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
@@ -31,11 +31,11 @@ class NetServer extends Net {
31
31
  }
32
32
  static emitProto(source, message) {
33
33
  const encoded = message.encode(message);
34
- NetServer.emitRawNet(message.name, source, encoded);
34
+ NetServer.emitRawNet(message.__proto_name__, source, encoded);
35
35
  }
36
36
  static broadcastProto(sources, message) {
37
37
  const encoded = message.encode(message);
38
- NetServer.broadcastRaw(sources, message.name, encoded);
38
+ NetServer.broadcastRaw(sources, message.__proto_name__, encoded);
39
39
  }
40
40
  static broadcast(sources, eventName, ...args) {
41
41
  const packed = msgpack_pack(...args);
@@ -61,7 +61,7 @@ class NetClient extends Net {
61
61
  }
62
62
  static emitProto(message) {
63
63
  const encoded = message.encode(message);
64
- NetClient.emitRawNet(message.name, encoded);
64
+ NetClient.emitRawNet(message.__proto_name__, encoded);
65
65
  }
66
66
  static emitRawNet(eventName, data) {
67
67
  TriggerServerEventInternal(eventName, data, data.byteLength);
package/index.d.ts CHANGED
@@ -173,6 +173,7 @@ export * from "./common-game/definitions/index.d";
173
173
  export * from "./common-game/definitions/redm.d";
174
174
  export * from "./common-game/cfx/StateBagChangeHandler";
175
175
  export * from "./common-game/cfx/cfx";
176
+ export * from "./common/BaseScript";
176
177
  export * from "./common/Command";
177
178
  export * from "./common/Convar";
178
179
  export * from "./common/GlobalData";
package/index.js CHANGED
@@ -173,6 +173,7 @@ export * from "./common-game/definitions/index.d";
173
173
  export * from "./common-game/definitions/redm.d";
174
174
  export * from "./common-game/cfx/StateBagChangeHandler";
175
175
  export * from "./common-game/cfx/cfx";
176
+ export * from "./common/BaseScript";
176
177
  export * from "./common/Command";
177
178
  export * from "./common/Convar";
178
179
  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.159",
11
+ "version": "0.0.160",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"