@nativewrappers/redm 0.0.80 → 0.0.82

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.
Files changed (82) hide show
  1. package/Attribute.js +143 -0
  2. package/Controls.js +22 -0
  3. package/Game.d.ts +2 -2
  4. package/Game.js +18 -0
  5. package/GameConstants.d.ts +1 -1
  6. package/GameConstants.js +24 -0
  7. package/Model.js +153 -0
  8. package/RawControls.d.ts +1 -1
  9. package/RawControls.js +22 -0
  10. package/RelationshipGroup.js +72 -0
  11. package/Volume.d.ts +1 -1
  12. package/Volume.js +32 -0
  13. package/common/Command.js +111 -0
  14. package/common/Convar.js +58 -0
  15. package/common/GlobalData.js +16 -0
  16. package/common/Kvp.js +137 -0
  17. package/common/Resource.js +54 -0
  18. package/common/decors/Events.js +170 -0
  19. package/common/net/NetworkedMap.js +225 -0
  20. package/common/utils/ClassTypes.js +15 -0
  21. package/common/utils/Color.js +33 -0
  22. package/common/utils/Delay.d.ts +1 -0
  23. package/common/utils/Delay.js +6 -0
  24. package/common/utils/Maths.js +18 -0
  25. package/common/utils/Point.d.ts +9 -0
  26. package/common/utils/Point.js +36 -0
  27. package/common/utils/PointF.d.ts +1 -1
  28. package/common/utils/PointF.js +18 -0
  29. package/common/utils/Quaternion.d.ts +1 -1
  30. package/common/utils/Quaternion.js +33 -0
  31. package/common/utils/Vector.js +589 -0
  32. package/common/utils/cleanPlayerName.js +17 -0
  33. package/common/utils/enumValues.js +20 -0
  34. package/common/utils/getStringFromUInt8Array.js +6 -0
  35. package/common/utils/getUInt32FromUint8Array.js +6 -0
  36. package/definitions/Citizen.d.js +0 -0
  37. package/definitions/index.d.js +0 -0
  38. package/definitions/redm.d.js +0 -0
  39. package/entities/BaseEntity.d.ts +1 -1
  40. package/entities/BaseEntity.js +99 -0
  41. package/entities/Entity.d.ts +1 -1
  42. package/entities/Entity.js +99 -0
  43. package/entities/Ped.d.ts +1 -1
  44. package/entities/Ped.js +336 -0
  45. package/entities/Pickup.d.ts +4 -0
  46. package/entities/Pickup.js +14 -0
  47. package/entities/Player.js +57 -0
  48. package/entities/Prop.js +11 -0
  49. package/entities/Vehicle.d.ts +1 -1
  50. package/entities/Vehicle.js +23 -0
  51. package/enums/Attributes.js +56 -0
  52. package/enums/Entity.js +20 -0
  53. package/enums/Keys.js +809 -0
  54. package/enums/Ped.js +31 -0
  55. package/enums/RawKeys.js +234 -0
  56. package/enums/Relationship.js +13 -0
  57. package/enums/VehicleSeat.js +17 -0
  58. package/index.js +52 -3762
  59. package/interfaces/Dimensions.d.ts +1 -1
  60. package/interfaces/Dimensions.js +0 -0
  61. package/package.json +2 -2
  62. package/types/Throwable.js +0 -0
  63. package/utils/Native.js +8 -0
  64. package/world/createDraftVehicle.d.ts +2 -2
  65. package/world/createDraftVehicle.js +32 -0
  66. package/world/createPed.d.ts +2 -2
  67. package/world/createPed.js +28 -0
  68. package/world/createProp.d.ts +1 -1
  69. package/world/createProp.js +28 -0
  70. package/world/createVehicle.d.ts +2 -2
  71. package/world/createVehicle.js +28 -0
  72. package/common/index.d.ts +0 -8
  73. package/common/utils/Vector2.d.ts +0 -1
  74. package/common/utils/Vector3.d.ts +0 -1
  75. package/common/utils/Vector4.d.ts +0 -1
  76. package/common/utils/index.d.ts +0 -12
  77. package/entities/index.d.ts +0 -4
  78. package/enums/index.d.ts +0 -6
  79. package/index.d.ts +0 -12
  80. package/utils/index.d.ts +0 -2
  81. package/world/index.d.ts +0 -4
  82. /package/{game/index.d.ts → common/types.js} +0 -0
package/Attribute.js ADDED
@@ -0,0 +1,143 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { _N } from "./utils/Native";
4
+ class CoreAttribute {
5
+ static {
6
+ __name(this, "CoreAttribute");
7
+ }
8
+ handle;
9
+ attribute;
10
+ constructor(ped, attribute) {
11
+ this.handle = ped.Handle;
12
+ this.attribute = attribute;
13
+ }
14
+ /**
15
+ * This doesn't seem to actually do anything
16
+ * @todo maybe remove unless theres a valid use case
17
+ * @param amount
18
+ * @param makeSound
19
+ */
20
+ enableOverpower(amount, makeSound = false) {
21
+ _N("0x4AF5A4C7B9157D14", this.handle, this.attribute, amount, makeSound);
22
+ }
23
+ get Overpowered() {
24
+ return _N("0x200373A8DF081F22", this.attribute, Citizen.resultAsInteger());
25
+ }
26
+ /**
27
+ * @returns the amount of overpower time left in seconds
28
+ */
29
+ get OverpoweredTimeLeft() {
30
+ return _N("0xB429F58803D285B1", this.handle, this.attribute, Citizen.resultAsInteger());
31
+ }
32
+ /**
33
+ * Returns how full the core is
34
+ */
35
+ get CoreValue() {
36
+ return GetAttributeCoreValue(this.handle, this.attribute);
37
+ }
38
+ set CoreValue(amount) {
39
+ _N("0xC6258F41D86676E0", this.handle, this.attribute, amount);
40
+ }
41
+ }
42
+ class PedAttribute {
43
+ static {
44
+ __name(this, "PedAttribute");
45
+ }
46
+ handle;
47
+ attribute;
48
+ constructor(ped, attribute) {
49
+ this.handle = ped.Handle;
50
+ this.attribute = attribute;
51
+ }
52
+ /**
53
+ *
54
+ * @param amount the amount of points to add to the attribute
55
+ */
56
+ addPoints(amount) {
57
+ AddAttributePoints(this.handle, this.attribute, amount);
58
+ }
59
+ /**
60
+ * Disables the overpower state on this attribute, see {@link enableOverpower} on how to enable
61
+ */
62
+ disableOverpower() {
63
+ DisableAttributeOverpower(this.handle, this.attribute);
64
+ }
65
+ /**
66
+ *
67
+ * @param amount the amount to overpower this attribute by
68
+ * @param makeSound if activating the overpower should play sound
69
+ */
70
+ enableOverpower(amount, makeSound = false) {
71
+ _N("0xF6A7C08DF2E28B28", this.handle, this.attribute, amount, makeSound);
72
+ }
73
+ /**
74
+ * Gets the amount of attribute points the ped has
75
+ */
76
+ get Points() {
77
+ return GetAttributePoints(this.handle, this.attribute);
78
+ }
79
+ set Points(amount) {
80
+ SetAttributePoints(this.handle, this.attribute, amount);
81
+ }
82
+ get Rank() {
83
+ return GetAttributeRank(this.handle, this.attribute);
84
+ }
85
+ set BaseRank(amount) {
86
+ SetAttributeBaseRank(this.handle, this.attribute, amount);
87
+ }
88
+ get BaseRank() {
89
+ return GetAttributeBaseRank(this.handle, this.attribute);
90
+ }
91
+ set BonusRank(amount) {
92
+ SetAttributeBonusRank(this.handle, this.attribute, amount);
93
+ }
94
+ get BonusRank() {
95
+ return GetAttributeBonusRank(this.handle, this.attribute);
96
+ }
97
+ get MaxRank() {
98
+ return _N("0x704674A0535A471D", this.attribute, Citizen.resultAsInteger());
99
+ }
100
+ get Overpowered() {
101
+ return _N("0x103C2F885ABEB00B", this.attribute, Citizen.resultAsInteger());
102
+ }
103
+ }
104
+ class Attributes {
105
+ static {
106
+ __name(this, "Attributes");
107
+ }
108
+ pedAttributes = [];
109
+ coreAttributes = [];
110
+ constructor(ped) {
111
+ for (let i = 0; i <= 21; i++) {
112
+ this.pedAttributes[i] = new PedAttribute(ped, i);
113
+ }
114
+ for (let i = 0; i <= 2; i++) {
115
+ this.coreAttributes[i] = new CoreAttribute(ped, i);
116
+ }
117
+ }
118
+ getCore(attribute) {
119
+ if (attribute > 2) throw new RangeError("The max enum for CoreAttribute is 2");
120
+ if (attribute < 0) throw new RangeError("The minimum enum for CoreAttribute is 0");
121
+ return this.coreAttributes[attribute];
122
+ }
123
+ get(attribute) {
124
+ if (attribute > 22) throw new RangeError("The max enum for PedAttribute is 22");
125
+ if (attribute < 0) throw new RangeError("The minimum enum for PedAttribute is 0");
126
+ return this.pedAttributes[attribute];
127
+ }
128
+ set CoreIcon(status) {
129
+ if (status > 15) throw new RangeError("The max enum for StatusEffect is 15");
130
+ if (status < 0) throw new RangeError("The minimum enum for StatusEffect is 0");
131
+ _N("0xA4D3A1C008F250DF", status);
132
+ }
133
+ set PeriodicIcon(status) {
134
+ if (status > 15) throw new RangeError("The max enum for StatusEffect is 15!");
135
+ if (status < 0) throw new RangeError("The minimum enum for StatusEffect is 0");
136
+ _N("0xFB6E111908502871", status);
137
+ }
138
+ }
139
+ export {
140
+ Attributes,
141
+ CoreAttribute,
142
+ PedAttribute
143
+ };
package/Controls.js ADDED
@@ -0,0 +1,22 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ class Controls {
4
+ static {
5
+ __name(this, "Controls");
6
+ }
7
+ static IsInputJustPressed(hash) {
8
+ return IsControlJustPressed(0, hash);
9
+ }
10
+ static IsInputPressed(hash) {
11
+ return IsControlPressed(0, hash);
12
+ }
13
+ static IsDisabledInputPressed(hash) {
14
+ return IsDisabledControlPressed(0, hash);
15
+ }
16
+ static DisableControl(hash) {
17
+ DisableControlAction(0, hash, false);
18
+ }
19
+ }
20
+ export {
21
+ Controls
22
+ };
package/Game.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Ped, Player } from "./entities";
1
+ import { Ped } from "./entities/Ped";
2
2
  export declare class Game {
3
3
  static get PlayerPed(): Ped;
4
- static get Player(): Player;
4
+ static get Player(): import("./entities/Player").Player;
5
5
  }
package/Game.js ADDED
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Ped } from "./entities/Ped";
4
+ import { GameConstants } from "./GameConstants";
5
+ class Game {
6
+ static {
7
+ __name(this, "Game");
8
+ }
9
+ static get PlayerPed() {
10
+ return new Ped(PlayerPedId());
11
+ }
12
+ static get Player() {
13
+ return GameConstants.Player;
14
+ }
15
+ }
16
+ export {
17
+ Game
18
+ };
@@ -1,4 +1,4 @@
1
- import { Player } from "./entities";
1
+ import { Player } from "./entities/Player";
2
2
  export declare class GameConstants {
3
3
  private static player;
4
4
  static readonly PlayerId: number;
@@ -0,0 +1,24 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Player } from "./entities/Player";
4
+ class GameConstants {
5
+ static {
6
+ __name(this, "GameConstants");
7
+ }
8
+ // the actual player object that will get initialized on the first call to the `get Player()`
9
+ static player = null;
10
+ // The player id of the local client
11
+ static PlayerId = PlayerId();
12
+ // The server id of the local client.
13
+ static ServerId = GetPlayerServerId(GameConstants.PlayerId);
14
+ // The player class of the local object
15
+ static get Player() {
16
+ if (GameConstants.player === null) {
17
+ GameConstants.player = new Player(GameConstants.PlayerId);
18
+ }
19
+ return GameConstants.player;
20
+ }
21
+ }
22
+ export {
23
+ GameConstants
24
+ };
package/Model.js ADDED
@@ -0,0 +1,153 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Vector3 } from "./common/utils/Vector";
4
+ import { Delay } from "./common/utils/Delay";
5
+ class Model {
6
+ static {
7
+ __name(this, "Model");
8
+ }
9
+ /**
10
+ * Hash of this model.
11
+ */
12
+ hash;
13
+ requestedModel = false;
14
+ /**
15
+ * Creates a model object based on the hash key or model string.
16
+ *
17
+ * @param hash A number or string of the model's hash. Example: "mp_m_freemode_01"
18
+ */
19
+ constructor(hash) {
20
+ if (typeof hash === "string") {
21
+ this.hash = GetHashKey(hash);
22
+ } else {
23
+ this.hash = hash;
24
+ }
25
+ }
26
+ [Symbol.dispose]() {
27
+ if (this.requestedModel) {
28
+ this.markAsNoLongerNeeded();
29
+ }
30
+ }
31
+ /**
32
+ * Gets the hash of the model.
33
+ *
34
+ * @returns The hash key.
35
+ */
36
+ get Hash() {
37
+ return this.hash;
38
+ }
39
+ /**
40
+ * Gets if the model is valid or not.
41
+ *
42
+ * @returns Whether this model is valid.
43
+ */
44
+ get IsValid() {
45
+ return IsModelValid(this.hash);
46
+ }
47
+ /**
48
+ * Gets if the model is in cd image or not.
49
+ *
50
+ * @returns Whether this model is in cd image.
51
+ */
52
+ get IsInCdImage() {
53
+ return IsModelInCdimage(this.hash);
54
+ }
55
+ /**
56
+ * Gets if the model is loaded or not.
57
+ *
58
+ * @returns Whether this model is loaded.
59
+ */
60
+ get IsLoaded() {
61
+ return HasModelLoaded(this.hash);
62
+ }
63
+ /**
64
+ * Gets if the model collision is loaded or not.
65
+ *
66
+ * @returns Whether this model collision is loaded.
67
+ */
68
+ get IsCollisionLoaded() {
69
+ return HasCollisionForModelLoaded(this.hash);
70
+ }
71
+ /**
72
+ * Gets if the model is a boat or not.
73
+ *
74
+ * @returns Whether this model is a boat.
75
+ */
76
+ get IsBoat() {
77
+ return IsThisModelABoat(this.hash);
78
+ }
79
+ /**
80
+ * Gets if the model is a Ped or not.
81
+ *
82
+ * @returns Whether this model is a Ped.
83
+ */
84
+ get IsPed() {
85
+ return IsModelAPed(this.hash);
86
+ }
87
+ /**
88
+ * Gets if the model is a prop or not.
89
+ *
90
+ * @returns Whether this model is a prop.
91
+ */
92
+ get IsProp() {
93
+ return this.IsValid && !this.IsPed && !this.IsVehicle && !IsWeaponValid(this.hash);
94
+ }
95
+ /**
96
+ * Gets if the model is a train or not.
97
+ *
98
+ * @returns Whether this model is a train.
99
+ */
100
+ get IsTrain() {
101
+ return IsThisModelATrain(this.hash);
102
+ }
103
+ /**
104
+ * Gets if the model is a Vehicle or not.
105
+ *
106
+ * @returns Whether this model is a Vehicle.
107
+ */
108
+ get IsVehicle() {
109
+ return IsModelAVehicle(this.hash);
110
+ }
111
+ /**
112
+ * Gets the model dimensions.
113
+ *
114
+ * @returns This model min & max dimensions.
115
+ */
116
+ get Dimensions() {
117
+ const [minArray, maxArray] = GetModelDimensions(this.hash);
118
+ const min = Vector3.fromArray(minArray);
119
+ const max = Vector3.fromArray(maxArray);
120
+ return { min, max };
121
+ }
122
+ /**
123
+ * Request and load the model with a specified timeout. Default timeout is 1000 (recommended).
124
+ * This function will not automatically set the model as no longer needed when
125
+ * done.
126
+ *
127
+ * @param timeoutMs Maximum allowed time for model to load.
128
+ */
129
+ async request(timeoutMs = 1e3) {
130
+ if (!this.IsInCdImage && !this.IsValid && !IsWeaponValid(this.hash)) {
131
+ return false;
132
+ }
133
+ if (this.IsLoaded) {
134
+ return true;
135
+ }
136
+ RequestModel(this.hash, false);
137
+ const timeout = GetGameTimer() + timeoutMs;
138
+ while (!this.IsLoaded && GetGameTimer() < timeout) {
139
+ await Delay(0);
140
+ }
141
+ this.requestedModel = true;
142
+ return this.IsLoaded;
143
+ }
144
+ /**
145
+ * Sets the model as no longer needed allowing the game engine to free memory.
146
+ */
147
+ markAsNoLongerNeeded() {
148
+ SetModelAsNoLongerNeeded(this.hash);
149
+ }
150
+ }
151
+ export {
152
+ Model
153
+ };
package/RawControls.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { RawKeys } from "./enums";
1
+ import type { RawKeys } from "./enums/RawKeys";
2
2
  export declare class RawControls {
3
3
  static IsKeyDown(rawKey: RawKeys): boolean;
4
4
  static IsKeyPressed(rawKey: RawKeys): boolean;
package/RawControls.js ADDED
@@ -0,0 +1,22 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ class RawControls {
4
+ static {
5
+ __name(this, "RawControls");
6
+ }
7
+ static IsKeyDown(rawKey) {
8
+ return IsRawKeyDown(rawKey);
9
+ }
10
+ static IsKeyPressed(rawKey) {
11
+ return IsRawKeyPressed(rawKey);
12
+ }
13
+ static IsKeyReleased(rawKey) {
14
+ return IsRawKeyReleased(rawKey);
15
+ }
16
+ static IsKeyUp(rawKey) {
17
+ return IsRawKeyUp(rawKey);
18
+ }
19
+ }
20
+ export {
21
+ RawControls
22
+ };
@@ -0,0 +1,72 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ class RelationshipGroup {
4
+ static {
5
+ __name(this, "RelationshipGroup");
6
+ }
7
+ /**
8
+ * The hash of the relationship group
9
+ */
10
+ hash;
11
+ /**
12
+ * Create a relationship group. Optionally pass a group hash.
13
+ *
14
+ * @param name Name of the relationship group.
15
+ */
16
+ constructor(name) {
17
+ const [, groupHash] = AddRelationshipGroup(name);
18
+ this.hash = groupHash;
19
+ }
20
+ /**
21
+ * Gets the hash of the relationship group.
22
+ *
23
+ * @returns The hash of this object.
24
+ */
25
+ get Hash() {
26
+ return this.hash;
27
+ }
28
+ /**
29
+ * Get the relationship between two relationship groups.
30
+ *
31
+ * @param targetGroup The other relationship group.
32
+ * @returns The relationship
33
+ */
34
+ getRelationshipBetweenGroups(targetGroup) {
35
+ return GetRelationshipBetweenGroups(this.Hash, targetGroup.Hash);
36
+ }
37
+ /**
38
+ * Set the relationship group between this relationship group and another one.
39
+ *
40
+ * @param targetGroup The other relationship group.
41
+ * @param relationship The desired relationship.
42
+ * @param biDirectionally If target group should have same relationship towards this.
43
+ */
44
+ setRelationshipBetweenGroups(targetGroup, relationship, biDirectionally = false) {
45
+ SetRelationshipBetweenGroups(Number(relationship), this.Hash, targetGroup.Hash);
46
+ if (biDirectionally) {
47
+ SetRelationshipBetweenGroups(Number(relationship), targetGroup.Hash, this.Hash);
48
+ }
49
+ }
50
+ /**
51
+ * Clear the relationship between this relationship group and another.
52
+ *
53
+ * @param targetGroup The other relationship group.
54
+ * @param relationship The desired relationship to clear.
55
+ * @param biDirectionally Whether the target group should also clear the relationship.
56
+ */
57
+ clearRelationshipBetweenGroups(targetGroup, relationship, biDirectionally = false) {
58
+ ClearRelationshipBetweenGroups(Number(relationship), this.Hash, targetGroup.Hash);
59
+ if (biDirectionally) {
60
+ ClearRelationshipBetweenGroups(Number(relationship), targetGroup.Hash, this.Hash);
61
+ }
62
+ }
63
+ /**
64
+ * Remove this relationship group from the game. This will not delete this object.
65
+ */
66
+ remove() {
67
+ RemoveRelationshipGroup(this.Hash);
68
+ }
69
+ }
70
+ export {
71
+ RelationshipGroup
72
+ };
package/Volume.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Vector3 } from "./common/utils/Vector3";
1
+ import type { Vector3 } from "./common/utils/Vector";
2
2
  export declare class Volume {
3
3
  private handle;
4
4
  constructor(coord: Vector3, rot: Vector3, scale: Vector3, customName?: string);
package/Volume.js ADDED
@@ -0,0 +1,32 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ class Volume {
4
+ static {
5
+ __name(this, "Volume");
6
+ }
7
+ handle;
8
+ constructor(coord, rot, scale, customName) {
9
+ if (customName) {
10
+ this.handle = CreateVolumeCylinderWithCustomName(
11
+ coord.x,
12
+ coord.y,
13
+ coord.z,
14
+ rot.x,
15
+ rot.y,
16
+ rot.z,
17
+ scale.x,
18
+ scale.y,
19
+ scale.z,
20
+ customName
21
+ );
22
+ return;
23
+ }
24
+ this.handle = CreateVolumeCylinder(coord.x, coord.y, coord.z, rot.x, rot.y, rot.z, scale.x, scale.y, scale.z);
25
+ }
26
+ get Handle() {
27
+ return this.handle;
28
+ }
29
+ }
30
+ export {
31
+ Volume
32
+ };
@@ -0,0 +1,111 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ const commands = [];
4
+ $SERVER: {
5
+ on("playerJoining", () => emitNet("chat:addSuggestions", source, commands));
6
+ }
7
+ function registerCommand(name, commandHandler, restricted) {
8
+ if (Array.isArray(name)) {
9
+ for (const command of name) {
10
+ registerCommand(command, commandHandler, restricted);
11
+ }
12
+ return;
13
+ }
14
+ RegisterCommand(name, commandHandler, !!restricted);
15
+ $SERVER: {
16
+ const ace = `command.${name}`;
17
+ if (typeof restricted === "string") {
18
+ if (IsPrincipalAceAllowed(restricted, ace)) return;
19
+ return ExecuteCommand(`add_ace ${restricted} ${ace} allow`);
20
+ }
21
+ if (Array.isArray(restricted)) {
22
+ for (const principal of restricted) {
23
+ if (!IsPrincipalAceAllowed(principal, ace)) ExecuteCommand(`add_ace ${restricted} ${ace} allow`);
24
+ }
25
+ }
26
+ }
27
+ }
28
+ __name(registerCommand, "registerCommand");
29
+ class Command {
30
+ constructor(name, help, handler, params, restricted = true) {
31
+ this.name = name;
32
+ this.help = help;
33
+ this.params = params;
34
+ this.#handler = handler;
35
+ this.name = `/${name}`;
36
+ registerCommand(name, (source2, args, raw) => this.call(source2, args, raw), restricted);
37
+ if (params) {
38
+ for (const parameter of params) {
39
+ if (parameter.type) {
40
+ parameter.help = parameter.help ? `${parameter.help} (type: ${parameter.type})` : `(type: ${parameter.type})`;
41
+ }
42
+ }
43
+ setTimeout(() => {
44
+ $SERVER: {
45
+ commands.push(this);
46
+ emitNet("chat:addSuggestions", -1, this);
47
+ }
48
+ $CLIENT: {
49
+ emit("chat:addSuggestion", this);
50
+ }
51
+ }, 100);
52
+ }
53
+ }
54
+ static {
55
+ __name(this, "Command");
56
+ }
57
+ #handler;
58
+ mapArguments(source2, args, raw) {
59
+ const mapped = {
60
+ source: source2,
61
+ raw
62
+ };
63
+ if (!this.params) return mapped;
64
+ const result = this.params.every((param, index) => {
65
+ const arg = args[index];
66
+ let value = arg;
67
+ switch (param.type) {
68
+ case "number":
69
+ value = +arg;
70
+ break;
71
+ case "string":
72
+ value = !Number(arg) ? arg : false;
73
+ break;
74
+ case "playerId":
75
+ $SERVER: {
76
+ value = arg === "me" ? source2 : +arg;
77
+ if (!value || !DoesPlayerExist(value.toString())) value = void 0;
78
+ }
79
+ $CLIENT: {
80
+ value = arg === "me" ? GetPlayerServerId(PlayerId()) : +arg;
81
+ if (!value || GetPlayerFromServerId(value) === -1) value = void 0;
82
+ }
83
+ break;
84
+ case "longString":
85
+ value = raw.substring(raw.indexOf(arg));
86
+ break;
87
+ }
88
+ if (value === void 0 && (!param.optional || param.optional && arg)) {
89
+ return Citizen.trace(
90
+ `^1command '${raw.split(" ")[0] || raw}' received an invalid ${param.type} for argument ${index + 1} (${param.name}), received '${arg}'^0`
91
+ );
92
+ }
93
+ mapped[param.name] = value;
94
+ return true;
95
+ });
96
+ return result ? mapped : null;
97
+ }
98
+ async call(source2, args, raw = args.join(" ")) {
99
+ const parsed = this.mapArguments(source2, args, raw);
100
+ if (!parsed) return;
101
+ try {
102
+ await this.#handler(parsed);
103
+ } catch (err) {
104
+ Citizen.trace(`^1command '${raw.split(" ")[0] || raw}' failed to execute!^0
105
+ ${err.message}`);
106
+ }
107
+ }
108
+ }
109
+ export {
110
+ Command
111
+ };
@@ -0,0 +1,58 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { GlobalData } from "./GlobalData";
4
+ class Convar {
5
+ static {
6
+ __name(this, "Convar");
7
+ }
8
+ /**
9
+ * @returns the current console buffer
10
+ */
11
+ buffer() {
12
+ $CLIENT: {
13
+ if (GlobalData.IS_CLIENT) {
14
+ throw new Error("This function isn't available on the client");
15
+ }
16
+ }
17
+ return GetConsoleBuffer();
18
+ }
19
+ get(variable, defaultVar) {
20
+ return GetConvar(variable, defaultVar);
21
+ }
22
+ getInt(variable, defaultVar) {
23
+ return GetConvarInt(variable, defaultVar);
24
+ }
25
+ getFloat(varName, defaultVar) {
26
+ return GetConvarFloat(varName, defaultVar);
27
+ }
28
+ getBool(varName, defaultVar) {
29
+ return GetConvarBool(varName, defaultVar);
30
+ }
31
+ set(variable, value) {
32
+ $CLIENT: {
33
+ if (GlobalData.IS_CLIENT) {
34
+ throw new Error("This function isn't available on the client");
35
+ }
36
+ }
37
+ SetConvar(variable, value);
38
+ }
39
+ setReplicated(variable, value) {
40
+ $CLIENT: {
41
+ if (GlobalData.IS_CLIENT) {
42
+ throw new Error("This function isn't available on the client");
43
+ }
44
+ }
45
+ SetConvarReplicated(variable, value);
46
+ }
47
+ setServerInfo(variable, value) {
48
+ $CLIENT: {
49
+ if (GlobalData.IS_CLIENT) {
50
+ throw new Error("This function isn't available on the client");
51
+ }
52
+ }
53
+ SetConvarServerInfo(variable, value);
54
+ }
55
+ }
56
+ export {
57
+ Convar
58
+ };