@nativewrappers/server 0.0.159 → 0.0.161

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);
@@ -51,6 +51,12 @@ export declare class Player {
51
51
  * @returns the current routhing bucket the player is in, default is 0
52
52
  */
53
53
  get RoutingBucket(): number;
54
+ /**
55
+ * Sets the players routing bucket to {@see routingBucket}
56
+ * You can use onPlayerBucketChange to listen for routing bucket changes
57
+ * {@link https://github.com/citizenfx/fivem/blob/cfed16afb4ba2d920cfd31adb0c27d758988aac3/code/components/citizen-server-impl/src/state/ServerGameState_Scripting.cpp#L1675C1-L1686C25}
58
+ */
59
+ set RoutingBucket(routingBucket: number);
54
60
  get Team(): number;
55
61
  get WantedPosition(): Vector3;
56
62
  get WantedLevel(): number;
@@ -106,6 +106,14 @@ class Player {
106
106
  get RoutingBucket() {
107
107
  return GetPlayerRoutingBucket(this.Src);
108
108
  }
109
+ /**
110
+ * Sets the players routing bucket to {@see routingBucket}
111
+ * You can use onPlayerBucketChange to listen for routing bucket changes
112
+ * {@link https://github.com/citizenfx/fivem/blob/cfed16afb4ba2d920cfd31adb0c27d758988aac3/code/components/citizen-server-impl/src/state/ServerGameState_Scripting.cpp#L1675C1-L1686C25}
113
+ */
114
+ set RoutingBucket(routingBucket) {
115
+ SetPlayerRoutingBucket(this.Handle, routingBucket);
116
+ }
109
117
  get Team() {
110
118
  return GetPlayerTeam(this.Src);
111
119
  }
package/index.d.ts CHANGED
@@ -38,6 +38,7 @@ export * from "./common-game/definitions/index.d";
38
38
  export * from "./common-game/definitions/redm.d";
39
39
  export * from "./common-game/cfx/StateBagChangeHandler";
40
40
  export * from "./common-game/cfx/cfx";
41
+ export * from "./common/BaseScript";
41
42
  export * from "./common/Command";
42
43
  export * from "./common/Convar";
43
44
  export * from "./common/GlobalData";
package/index.js CHANGED
@@ -38,6 +38,7 @@ export * from "./common-game/definitions/index.d";
38
38
  export * from "./common-game/definitions/redm.d";
39
39
  export * from "./common-game/cfx/StateBagChangeHandler";
40
40
  export * from "./common-game/cfx/cfx";
41
+ export * from "./common/BaseScript";
41
42
  export * from "./common/Command";
42
43
  export * from "./common/Convar";
43
44
  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.161",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"