diff --git a/client/js/compatibility/classes/areaBlip.js b/client/js/compatibility/classes/areaBlip.js
index 12783f260..0f3f82462 100644
--- a/client/js/compatibility/classes/areaBlip.js
+++ b/client/js/compatibility/classes/areaBlip.js
@@ -2,14 +2,19 @@
///
// import * as alt from "@altv/client";
-requireBinding("client/entity.js");
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
const { SharedBlip } = requireBinding("shared/compatibility/classes/sharedBlip.js");
const { BaseObject } = requireBinding("client/compatibility/classes/baseObject.js");
const { WorldObject } = requireBinding("client/compatibility/classes/worldObject.js");
+requireBinding("client/entity.js");
+
class AreaBlip {
constructor(x, y, z, width, height) {
+ assert(arguments.length === 5, "5 arguments expected");
+
return alt.AreaBlip.create({
pos: { x, y, z },
scale: { x: width, y: height }
diff --git a/client/js/compatibility/classes/audio.js b/client/js/compatibility/classes/audio.js
index 75a03c0e1..18aa8d13c 100644
--- a/client/js/compatibility/classes/audio.js
+++ b/client/js/compatibility/classes/audio.js
@@ -5,13 +5,15 @@
requireBinding("client/factory.js");
/** @type {typeof import("../../../../shared/js/utils.js")} */
-const { assertIsType } = requireBinding("shared/utils.js");
+const { assertIsType, assert } = requireBinding("shared/utils.js");
class Audio extends alt.Audio {
constructor(...args) {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length >= 1 && args.length <= 4, "Minimum 1, maximum 4 arguments expected");
+
const [source, volume, radio, clearCache] = args;
return alt.Audio.create({ source, volume, radio, clearCache });
diff --git a/client/js/compatibility/classes/audioCategory.js b/client/js/compatibility/classes/audioCategory.js
index bce2bdc39..bd524ffab 100644
--- a/client/js/compatibility/classes/audioCategory.js
+++ b/client/js/compatibility/classes/audioCategory.js
@@ -2,11 +2,16 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class AudioCategory extends alt.AudioCategory {
constructor(...args) {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length === 1, "1 arguments expected");
+
return alt.AudioCategory.get(args[0]);
}
diff --git a/client/js/compatibility/classes/audioFilter.js b/client/js/compatibility/classes/audioFilter.js
index 3598ae6f8..6409c62d8 100644
--- a/client/js/compatibility/classes/audioFilter.js
+++ b/client/js/compatibility/classes/audioFilter.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("client/factory.js");
class AudioFilter extends alt.AudioFilter {
@@ -9,6 +12,8 @@ class AudioFilter extends alt.AudioFilter {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length === 1, "1 arguments expected");
+
return alt.AudioFilter.create({ hash: args[0] });
}
diff --git a/client/js/compatibility/classes/audioOutputAttached.js b/client/js/compatibility/classes/audioOutputAttached.js
index dfd5daba6..96b19d4ea 100644
--- a/client/js/compatibility/classes/audioOutputAttached.js
+++ b/client/js/compatibility/classes/audioOutputAttached.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("client/factory.js");
class AudioOutputAttached extends alt.AudioOutputAttached {
@@ -9,6 +12,8 @@ class AudioOutputAttached extends alt.AudioOutputAttached {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length >= 1 && args.length <= 2, "Minimum 1, maximum 2 arguments expected");
+
const [entity, categoryHash] = args;
return alt.AudioOutputAttached.create({ entity, categoryHash });
diff --git a/client/js/compatibility/classes/audioOutputFrontend.js b/client/js/compatibility/classes/audioOutputFrontend.js
index 1185a4ecc..fe4dbe38b 100644
--- a/client/js/compatibility/classes/audioOutputFrontend.js
+++ b/client/js/compatibility/classes/audioOutputFrontend.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("client/factory.js");
class AudioOutputFrontend extends alt.AudioOutputFrontend {
@@ -9,6 +12,8 @@ class AudioOutputFrontend extends alt.AudioOutputFrontend {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length >= 0 && args.length <= 1, "Minimum 0, maximum 1 arguments expected");
+
const [categoryHash] = args;
return alt.AudioOutputFrontend.create({ categoryHash });
diff --git a/client/js/compatibility/classes/audioOutputWorld.js b/client/js/compatibility/classes/audioOutputWorld.js
index 96245c5fe..2e9392cf7 100644
--- a/client/js/compatibility/classes/audioOutputWorld.js
+++ b/client/js/compatibility/classes/audioOutputWorld.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("client/factory.js");
class AudioOutputWorld extends alt.AudioOutputWorld {
@@ -9,6 +12,8 @@ class AudioOutputWorld extends alt.AudioOutputWorld {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length >= 1 && args.length <= 2, "Minimum 1, maximum 2 arguments expected");
+
const [pos, categoryHash] = args;
return alt.AudioOutputWorld.create({ pos, categoryHash });
diff --git a/client/js/compatibility/classes/checkpoint.js b/client/js/compatibility/classes/checkpoint.js
index 159d37f24..10daf96de 100644
--- a/client/js/compatibility/classes/checkpoint.js
+++ b/client/js/compatibility/classes/checkpoint.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("shared/factory.js");
class Checkpoint extends alt.Checkpoint {
@@ -9,6 +12,8 @@ class Checkpoint extends alt.Checkpoint {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length == 8 || args.length == 12, "8 or 12 arguments expected");
+
const type = args[0];
const pos = args.length == 8 ? args[1] : { x: args[1], y: args[2], z: args[3] };
const nextPos = args.length == 8 ? args[2] : { x: args[4], y: args[5], z: args[6] };
diff --git a/client/js/compatibility/classes/colshapeCircle.js b/client/js/compatibility/classes/colshapeCircle.js
index 4c9c9023b..fa380005a 100644
--- a/client/js/compatibility/classes/colshapeCircle.js
+++ b/client/js/compatibility/classes/colshapeCircle.js
@@ -2,10 +2,15 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class ColshapeCircle extends alt.ColShape {
constructor(...args) {
if (!args.length) return super();
+ assert(args.length === 3, "3 arguments expected");
+
const [x, y, radius] = args;
return alt.ColShapeCircle.create({
diff --git a/client/js/compatibility/classes/colshapeCuboid.js b/client/js/compatibility/classes/colshapeCuboid.js
index 79bcba601..7d0068ff5 100644
--- a/client/js/compatibility/classes/colshapeCuboid.js
+++ b/client/js/compatibility/classes/colshapeCuboid.js
@@ -2,10 +2,15 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class ColshapeCuboid extends alt.ColShape {
constructor(...args) {
if (!args.length) return super();
+ assert(args.length === 6, "6 arguments expected");
+
const [x, y, z, x2, y2, z2] = args;
return alt.ColShapeCuboid.create({
diff --git a/client/js/compatibility/classes/colshapeCylinder.js b/client/js/compatibility/classes/colshapeCylinder.js
index 63dcb1f93..d1b5141f2 100644
--- a/client/js/compatibility/classes/colshapeCylinder.js
+++ b/client/js/compatibility/classes/colshapeCylinder.js
@@ -2,10 +2,15 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class ColshapeCylinder extends alt.ColShape {
constructor(...args) {
const [x, y, z, radius, height] = args;
+ assert(args.length === 5, "5 arguments expected");
+
return alt.ColShapeCylinder.create({
pos: { x, y, z },
radius,
diff --git a/client/js/compatibility/classes/colshapePolygon.js b/client/js/compatibility/classes/colshapePolygon.js
index 598b39fbe..d038aac27 100644
--- a/client/js/compatibility/classes/colshapePolygon.js
+++ b/client/js/compatibility/classes/colshapePolygon.js
@@ -2,10 +2,15 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class ColshapePolygon extends alt.ColShape {
constructor(...args) {
if (!args.length) return super();
+ assert(args.length === 3, "3 arguments expected");
+
const [minZ, maxZ, points] = args;
return alt.ColShapePolygon.create({
diff --git a/client/js/compatibility/classes/colshapeRectangle.js b/client/js/compatibility/classes/colshapeRectangle.js
index 2d94c7eb9..f14eedf89 100644
--- a/client/js/compatibility/classes/colshapeRectangle.js
+++ b/client/js/compatibility/classes/colshapeRectangle.js
@@ -2,10 +2,15 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class ColshapeRectangle extends alt.ColShape {
constructor(...args) {
if (!args.length) return super();
+ assert(args.length === 4, "4 arguments expected");
+
const [x, y, x2, y2] = args;
return alt.ColShapeRectangle.create({
diff --git a/client/js/compatibility/classes/colshapeSphere.js b/client/js/compatibility/classes/colshapeSphere.js
index c8047430e..85142918a 100644
--- a/client/js/compatibility/classes/colshapeSphere.js
+++ b/client/js/compatibility/classes/colshapeSphere.js
@@ -2,10 +2,15 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class ColshapeSphere extends alt.ColShape {
constructor(...args) {
if (!args.length) return super();
+ assert(args.length === 4, "4 arguments expected");
+
const [x, y, z, radius] = args;
return alt.ColShapeSphere.create({
diff --git a/client/js/compatibility/classes/localObject.js b/client/js/compatibility/classes/localObject.js
index e69adf4e3..7baea1406 100644
--- a/client/js/compatibility/classes/localObject.js
+++ b/client/js/compatibility/classes/localObject.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("client/factory.js");
class LocalObject extends alt.LocalObject {
@@ -9,6 +12,8 @@ class LocalObject extends alt.LocalObject {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length >= 3 && args.length <= 7, "Minimum 3, maximum 7 arguments expected");
+
const [model, pos, rot, noOffset, dynamic, useStreaming, streamingDistance] = args;
return alt.LocalObject.create({ model, pos, rot, noOffset, dynamic, useStreaming, streamingDistance });
diff --git a/client/js/compatibility/classes/localPed.js b/client/js/compatibility/classes/localPed.js
index 06999c5cf..6888d3c88 100644
--- a/client/js/compatibility/classes/localPed.js
+++ b/client/js/compatibility/classes/localPed.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("client/factory.js");
class LocalPed extends alt.LocalPed {
@@ -9,6 +12,8 @@ class LocalPed extends alt.LocalPed {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length >= 4 && args.length <= 6, "Minimum 4, maximum 6 arguments expected");
+
const [model, dimension, pos, heading, useStreaming, streamingDistance] = args;
return alt.LocalPed.create({ model, dimension, pos, heading, useStreaming, streamingDistance });
diff --git a/client/js/compatibility/classes/localVehicle.js b/client/js/compatibility/classes/localVehicle.js
index 0983739b8..712dd60db 100644
--- a/client/js/compatibility/classes/localVehicle.js
+++ b/client/js/compatibility/classes/localVehicle.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("client/factory.js");
class LocalVehicle extends alt.LocalVehicle {
@@ -9,6 +12,8 @@ class LocalVehicle extends alt.LocalVehicle {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length >= 4 && args.length <= 6, "Minimum 4, maximum 6 arguments expected");
+
const [model, dimension, pos, rot, useStreaming, streamingDistance] = args;
return alt.LocalVehicle.create({ model, dimension, pos, rot, useStreaming, streamingDistance });
diff --git a/client/js/compatibility/classes/mapZoomData.js b/client/js/compatibility/classes/mapZoomData.js
index edd1a4886..8722728a2 100644
--- a/client/js/compatibility/classes/mapZoomData.js
+++ b/client/js/compatibility/classes/mapZoomData.js
@@ -2,11 +2,16 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class MapZoomData extends alt.MapZoomData {
constructor(...args) {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length === 1, "1 arguments expected");
+
return alt.MapZoomData.get(zoomDataId[0]);
}
}
diff --git a/client/js/compatibility/classes/marker.js b/client/js/compatibility/classes/marker.js
index 886dc2773..b9deb1125 100644
--- a/client/js/compatibility/classes/marker.js
+++ b/client/js/compatibility/classes/marker.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("shared/factory.js");
class Marker extends alt.Marker {
@@ -9,6 +12,8 @@ class Marker extends alt.Marker {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length >= 3 && args.length <= 5, "Minimum 3, maximum 5 arguments expected");
+
const [type, pos, color, useStreaming, streamingDistance] = args;
return alt.Marker.create({ type, pos, color, useStreaming, streamingDistance });
diff --git a/client/js/compatibility/classes/memoryBuffer.js b/client/js/compatibility/classes/memoryBuffer.js
index 555979d5e..aa917842e 100644
--- a/client/js/compatibility/classes/memoryBuffer.js
+++ b/client/js/compatibility/classes/memoryBuffer.js
@@ -5,10 +5,16 @@
/** @type {typeof import("../../../../shared/js/compatibility/utils/classes.js")} */
const { extendClassWithProperties } = requireBinding("shared/compatibility/utils/classes.js");
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert, assertIsType } = requireBinding("shared/utils.js");
+
requireBinding("shared/logging.js");
class MemoryBuffer extends alt.Buffer {
constructor(size) {
+ assertIsType(size, "number", "1 arguments expected");
+ assert(size <= 1024, "You can't allocate > 1KB");
+
return new alt.Buffer(size);
}
diff --git a/client/js/compatibility/classes/pointRadius.js b/client/js/compatibility/classes/pointRadius.js
index dd3647e36..a707b3952 100644
--- a/client/js/compatibility/classes/pointRadius.js
+++ b/client/js/compatibility/classes/pointRadius.js
@@ -2,16 +2,20 @@
///
// import * as alt from "@altv/client";
-requireBinding("client/entity.js");
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
const { SharedBlip } = requireBinding("shared/compatibility/classes/sharedBlip.js");
const { BaseObject } = requireBinding("client/compatibility/classes/baseObject.js");
const { WorldObject } = requireBinding("client/compatibility/classes/worldObject.js");
+requireBinding("client/entity.js");
+
class PointBlip {
constructor(...args) {
- if (args.length == 3) return alt.PointBlip.create({ pos: { x: args[0], y: args[1], z: args[2] } });
- else return alt.PointBlip.create({ entity: args[0] });
+ assert(args.length == 3, "3 arguments expected");
+
+ return alt.PointBlip.create({ pos: { x: args[0], y: args[1], z: args[2] } });
}
}
diff --git a/client/js/compatibility/classes/radiusBlip.js b/client/js/compatibility/classes/radiusBlip.js
index 3db1be83b..e0494fd23 100644
--- a/client/js/compatibility/classes/radiusBlip.js
+++ b/client/js/compatibility/classes/radiusBlip.js
@@ -2,14 +2,20 @@
///
// import * as alt from "@altv/client";
-requireBinding("client/entity.js");
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
const { SharedBlip } = requireBinding("shared/compatibility/classes/sharedBlip.js");
const { BaseObject } = requireBinding("client/compatibility/classes/baseObject.js");
const { WorldObject } = requireBinding("client/compatibility/classes/worldObject.js");
+requireBinding("client/entity.js");
+
class RadiusBlip {
- constructor(x, y, z, radius) {
+ constructor(...args) {
+ assert(args.length === 4, "4 arguments expected");
+
+ const [x, y, z, radius] = args;
return alt.RadiusBlip.create({
pos: { x, y, z },
radius
diff --git a/client/js/compatibility/classes/rmlDocument.js b/client/js/compatibility/classes/rmlDocument.js
index d23aa3e50..7a46f5afa 100644
--- a/client/js/compatibility/classes/rmlDocument.js
+++ b/client/js/compatibility/classes/rmlDocument.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("client/factory.js");
class RmlDocument extends alt.RmlDocument {
@@ -9,6 +12,8 @@ class RmlDocument extends alt.RmlDocument {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length === 1, "1 arguments expected");
+
const [url] = args;
return alt.RmlDocument.create({ url });
diff --git a/client/js/compatibility/classes/textLabel.js b/client/js/compatibility/classes/textLabel.js
index f9b24ffdc..b3eba0fcc 100644
--- a/client/js/compatibility/classes/textLabel.js
+++ b/client/js/compatibility/classes/textLabel.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("client/factory.js");
class TextLabel extends alt.TextLabel {
@@ -9,6 +12,8 @@ class TextLabel extends alt.TextLabel {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length >= 9 && args.length <= 11, "Minimum 9, maximum 11 arguments expected");
+
const [text, fontName, fontSize, fontScale, pos, rot, color, outlineWidth, outlineColor, useStreaming, streamingDistance] = args;
return alt.TextLabel.create({ text, fontName, fontSize, fontScale, pos, rot, color, outlineWidth, outlineColor, useStreaming, streamingDistance });
diff --git a/client/js/compatibility/classes/virtualEntity.js b/client/js/compatibility/classes/virtualEntity.js
index 79e2fcdcf..47cfd689b 100644
--- a/client/js/compatibility/classes/virtualEntity.js
+++ b/client/js/compatibility/classes/virtualEntity.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("shared/factory.js");
class VirtualEntity extends alt.VirtualEntity {
@@ -9,6 +12,8 @@ class VirtualEntity extends alt.VirtualEntity {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length == 3 || args.length == 4, "3 or 4 arguments expected");
+
const [group, pos, streamingDistance, data] = args;
return alt.VirtualEntity.create({
diff --git a/client/js/compatibility/classes/virtualEntityGroup.js b/client/js/compatibility/classes/virtualEntityGroup.js
index 68ae1af36..e47eaca1d 100644
--- a/client/js/compatibility/classes/virtualEntityGroup.js
+++ b/client/js/compatibility/classes/virtualEntityGroup.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("shared/factory.js");
class VirtualEntityGroup extends alt.VirtualEntityGroup {
@@ -9,6 +12,8 @@ class VirtualEntityGroup extends alt.VirtualEntityGroup {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length === 1, "1 arguments expected");
+
return alt.VirtualEntityGroup.create({
maxEntitiesInStream: args[0]
});
diff --git a/client/js/compatibility/classes/weaponData.js b/client/js/compatibility/classes/weaponData.js
index d5b326d44..d5c5dfd58 100644
--- a/client/js/compatibility/classes/weaponData.js
+++ b/client/js/compatibility/classes/weaponData.js
@@ -2,9 +2,12 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assertIsOneOfType } = requireBinding("shared/utils.js");
+
class WeaponData {
constructor(weaponHash) {
- if (!weaponHash) return;
+ assertIsOneOfType(weaponHash, ["string", "number"], "1 arguments expected");
return alt.WeaponData.get(weaponHash);
}
diff --git a/client/js/compatibility/classes/weaponObject.js b/client/js/compatibility/classes/weaponObject.js
index 09d78d814..b196511bf 100644
--- a/client/js/compatibility/classes/weaponObject.js
+++ b/client/js/compatibility/classes/weaponObject.js
@@ -2,11 +2,16 @@
///
// import * as alt from "@altv/client";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class WeaponObject extends alt.LocalObject {
constructor(...args) {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length >= 3 && args.length <= 9, "Minimum 3, maximum 9 arguments expected");
+
const [weapon, pos, rot, model, ammoCount, createDefaultComponents, scale, useStreaming, streamingDistance] = args;
return alt.WeaponObject.create({ weapon, pos, rot, model, ammoCount, createDefaultComponents, scale, useStreaming, streamingDistance });
diff --git a/client/js/compatibility/classes/webSocketClient.js b/client/js/compatibility/classes/webSocketClient.js
index f52e710ff..57381dff7 100644
--- a/client/js/compatibility/classes/webSocketClient.js
+++ b/client/js/compatibility/classes/webSocketClient.js
@@ -12,6 +12,8 @@ class WebSocketClient extends alt.WebSocketClient {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length == 1, "1 arguments expected");
+
return alt.WebSocketClient.create({ url: args[0] });
}
diff --git a/client/js/compatibility/classes/webview.js b/client/js/compatibility/classes/webview.js
index 0d13338ce..3ace69c7a 100644
--- a/client/js/compatibility/classes/webview.js
+++ b/client/js/compatibility/classes/webview.js
@@ -5,7 +5,7 @@
requireBinding("client/factory.js");
/** @type {typeof import("../../../../shared/js/utils.js")} */
-const { assertIsType, isObject } = requireBinding("shared/utils.js");
+const { assert, assertIsType, isObject } = requireBinding("shared/utils.js");
class WebView extends alt.WebView {
constructor(...args) {
@@ -14,6 +14,8 @@ class WebView extends alt.WebView {
const url = args[0];
+ assert(args.length >= 1 && args.length <= 4, "Minimum 1, maximum 4 arguments expected");
+
let instance = null;
if (args.length == 4) {
const [_, isOverlay, pos, size] = args;
@@ -70,6 +72,10 @@ class WebView extends alt.WebView {
return alt.WebView.listeners[eventName] ?? [];
}
+
+ toString() {
+ return `WebView{ url: "${this.url}" }`;
+ }
}
alt.WebView.setFactory(WebView);
diff --git a/server/js/compatibility/classes/areaBlip.js b/server/js/compatibility/classes/areaBlip.js
index 52591a3c1..9757c369d 100644
--- a/server/js/compatibility/classes/areaBlip.js
+++ b/server/js/compatibility/classes/areaBlip.js
@@ -2,12 +2,17 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("shared/entity.js");
class AreaBlip {
constructor(...args) {
if (!args.length) return this;
+ assert(args.length == 6, "6 arguments expected");
+
const [x, y, z, width, height, global] = args;
return alt.AreaBlip.create({
diff --git a/server/js/compatibility/classes/checkpoint.js b/server/js/compatibility/classes/checkpoint.js
index 3499e651f..037c1d2aa 100644
--- a/server/js/compatibility/classes/checkpoint.js
+++ b/server/js/compatibility/classes/checkpoint.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("shared/factory.js");
class Checkpoint extends alt.Checkpoint {
@@ -9,6 +12,8 @@ class Checkpoint extends alt.Checkpoint {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length == 6 || args.length == 11, "6 or 11 arguments expected");
+
const type = args[0];
const pos = args.length == 6 ? args[1] : { x: args[1], y: args[2], z: args[3] };
const radius = args.length == 6 ? args[2] : args[4];
diff --git a/server/js/compatibility/classes/colshapeCircle.js b/server/js/compatibility/classes/colshapeCircle.js
index cd9b17c16..23d1469c8 100644
--- a/server/js/compatibility/classes/colshapeCircle.js
+++ b/server/js/compatibility/classes/colshapeCircle.js
@@ -2,10 +2,15 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class ColshapeCircle extends alt.ColShape {
constructor(...args) {
if (!args.length) return super();
+ assert(args.length === 3, "3 arguments expected");
+
const [x, y, radius] = args;
return alt.ColShapeCircle.create({
diff --git a/server/js/compatibility/classes/colshapeCuboid.js b/server/js/compatibility/classes/colshapeCuboid.js
index 6dc9dfdf0..9ace90e87 100644
--- a/server/js/compatibility/classes/colshapeCuboid.js
+++ b/server/js/compatibility/classes/colshapeCuboid.js
@@ -2,10 +2,15 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class ColshapeCuboid extends alt.ColShape {
constructor(...args) {
if (!args.length) return super();
+ assert(args.length === 6, "6 arguments expected");
+
const [x, y, z, x2, y2, z2] = args;
return alt.ColShapeCuboid.create({
diff --git a/server/js/compatibility/classes/colshapeCylinder.js b/server/js/compatibility/classes/colshapeCylinder.js
index 53374ec8b..bd5b30527 100644
--- a/server/js/compatibility/classes/colshapeCylinder.js
+++ b/server/js/compatibility/classes/colshapeCylinder.js
@@ -2,10 +2,15 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class ColshapeCylinder extends alt.ColShape {
constructor(...args) {
if (!args.length) return super();
+ assert(args.length === 5, "5 arguments expected");
+
const [x, y, z, radius, height] = args;
return alt.ColShapeCylinder.create({
diff --git a/server/js/compatibility/classes/colshapePolygon.js b/server/js/compatibility/classes/colshapePolygon.js
index c991e6564..24f29ff3a 100644
--- a/server/js/compatibility/classes/colshapePolygon.js
+++ b/server/js/compatibility/classes/colshapePolygon.js
@@ -2,10 +2,15 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class ColshapePolygon extends alt.ColShape {
constructor(...args) {
if (!args.length) return super();
+ assert(args.length === 3, "3 arguments expected");
+
const [minZ, maxZ, points] = args;
return alt.ColShapePolygon.create({
diff --git a/server/js/compatibility/classes/colshapeRectangle.js b/server/js/compatibility/classes/colshapeRectangle.js
index 919999bab..b1d5d00a2 100644
--- a/server/js/compatibility/classes/colshapeRectangle.js
+++ b/server/js/compatibility/classes/colshapeRectangle.js
@@ -2,10 +2,15 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class ColshapeRectangle extends alt.ColShape {
constructor(...args) {
if (!args.length) return super();
+ assert(args.length === 4, "4 arguments expected");
+
const [x, y, x2, y2] = args;
return alt.ColShapeRectangle.create({
diff --git a/server/js/compatibility/classes/colshapeSphere.js b/server/js/compatibility/classes/colshapeSphere.js
index e0b5f0d53..af39fae4f 100644
--- a/server/js/compatibility/classes/colshapeSphere.js
+++ b/server/js/compatibility/classes/colshapeSphere.js
@@ -2,10 +2,15 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
class ColshapeSphere extends alt.ColShape {
constructor(...args) {
if (!args.length) return super();
+ assert(args.length === 4, "4 arguments expected");
+
const [x, y, z, radius] = args;
return alt.ColShapeSphere.create({
diff --git a/server/js/compatibility/classes/marker.js b/server/js/compatibility/classes/marker.js
index 43f0c7444..694491579 100644
--- a/server/js/compatibility/classes/marker.js
+++ b/server/js/compatibility/classes/marker.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("shared/factory.js");
class Marker extends alt.Marker {
@@ -9,6 +12,8 @@ class Marker extends alt.Marker {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length === 3, "3 arguments expected");
+
const [type, pos, color] = args;
return alt.Marker.create({ type, pos, color });
diff --git a/server/js/compatibility/classes/object.js b/server/js/compatibility/classes/object.js
index 78349f66b..ffbe5dabc 100644
--- a/server/js/compatibility/classes/object.js
+++ b/server/js/compatibility/classes/object.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("server/factory.js");
class _Object extends alt.Object {
@@ -9,6 +12,8 @@ class _Object extends alt.Object {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length >= 3 && args.length <= 7, "Minimum 3, maximum 7 arguments expected");
+
const [model, pos, rot, alpha, textureVariation, lodDistance, streamingDistance] = args;
return alt.Object.create({
diff --git a/server/js/compatibility/classes/ped.js b/server/js/compatibility/classes/ped.js
index ef84daebd..5669a5571 100644
--- a/server/js/compatibility/classes/ped.js
+++ b/server/js/compatibility/classes/ped.js
@@ -7,6 +7,9 @@ const { extendClassWithProperties } = requireBinding("shared/compatibility/utils
const { SharedPed } = requireBinding("shared/compatibility/classes/sharedPed.js");
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("server/factory.js");
class Ped extends alt.Ped {
@@ -14,6 +17,8 @@ class Ped extends alt.Ped {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length >= 3, "Minimum 3 arguments expected");
+
const [model, position, rotation, streamingDistance] = args;
return alt.Ped.create({
diff --git a/server/js/compatibility/classes/pointBlip.js b/server/js/compatibility/classes/pointBlip.js
index 2a5774afc..e34784750 100644
--- a/server/js/compatibility/classes/pointBlip.js
+++ b/server/js/compatibility/classes/pointBlip.js
@@ -2,12 +2,17 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("shared/entity.js");
class PointBlip {
constructor(...args) {
if (!args.length) return this;
+ assert(args.length == 2 || args.length == 4, "2 or 4 arguments expected");
+
let instance;
if (args.length === 4) {
const [x, y, z, global] = args;
diff --git a/server/js/compatibility/classes/radiusBlip.js b/server/js/compatibility/classes/radiusBlip.js
index 376ed0bdf..0cccc0efb 100644
--- a/server/js/compatibility/classes/radiusBlip.js
+++ b/server/js/compatibility/classes/radiusBlip.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("shared/entity.js");
const { SharedBlip } = requireBinding("shared/compatibility/classes/sharedBlip.js");
@@ -10,6 +13,8 @@ class RadiusBlip {
constructor(...args) {
if (!args.length) return this;
+ assert(args.length === 5, "5 arguments expected");
+
const [x, y, z, radius, global] = args;
return alt.RadiusBlip.create({
diff --git a/server/js/compatibility/classes/vehicle.js b/server/js/compatibility/classes/vehicle.js
index 3dfbf3afc..58a4f6721 100644
--- a/server/js/compatibility/classes/vehicle.js
+++ b/server/js/compatibility/classes/vehicle.js
@@ -5,6 +5,9 @@
/** @type {typeof import("../../../../shared/js/compatibility/utils/classes.js")} */
const { extendClassWithProperties } = requireBinding("shared/compatibility/utils/classes.js");
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert, assertIsOneOfType } = requireBinding("shared/utils.js");
+
const { SharedVehicle } = requireBinding("shared/compatibility/classes/sharedVehicle.js");
requireBinding("server/factory.js");
@@ -14,6 +17,9 @@ class Vehicle extends alt.Vehicle {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length >= 3 && args.length <= 8, "Minimum 3, maximum 8 arguments expected");
+ assertIsOneOfType(args[0], ["string", "number"], "string or number expected");
+
const [model, ...rest] = args;
const pos = rest.length <= 3 ? rest[0] : { x: rest[0], y: rest[1], z: rest[2] };
const rot = rest.length <= 3 ? rest[1] : { x: rest[3], y: rest[4], z: rest[5] };
diff --git a/server/js/compatibility/classes/virtualEntity.js b/server/js/compatibility/classes/virtualEntity.js
index 476e4d46d..ce6645ef3 100644
--- a/server/js/compatibility/classes/virtualEntity.js
+++ b/server/js/compatibility/classes/virtualEntity.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("shared/factory.js");
class VirtualEntity extends alt.VirtualEntity {
@@ -9,6 +12,8 @@ class VirtualEntity extends alt.VirtualEntity {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length == 3 || args.length == 4, "3 or 4 arguments expected");
+
const [group, pos, streamingDistance, data] = args;
return alt.VirtualEntity.create({
diff --git a/server/js/compatibility/classes/virtualEntityGroup.js b/server/js/compatibility/classes/virtualEntityGroup.js
index 943eda7aa..4ea875946 100644
--- a/server/js/compatibility/classes/virtualEntityGroup.js
+++ b/server/js/compatibility/classes/virtualEntityGroup.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("shared/factory.js");
class VirtualEntityGroup extends alt.VirtualEntityGroup {
@@ -9,6 +12,8 @@ class VirtualEntityGroup extends alt.VirtualEntityGroup {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length === 1, "1 arguments expected");
+
return alt.VirtualEntityGroup.create({
maxEntitiesInStream: args[0]
});
diff --git a/server/js/compatibility/classes/voiceChannel.js b/server/js/compatibility/classes/voiceChannel.js
index 0e8f28f9b..6b73024d7 100644
--- a/server/js/compatibility/classes/voiceChannel.js
+++ b/server/js/compatibility/classes/voiceChannel.js
@@ -2,6 +2,9 @@
///
// import * as alt from "@altv/server";
+/** @type {typeof import("../../../../shared/js/utils.js")} */
+const { assert } = requireBinding("shared/utils.js");
+
requireBinding("server/factory.js");
class VoiceChannel extends alt.VoiceChannel {
@@ -9,6 +12,8 @@ class VoiceChannel extends alt.VoiceChannel {
// NOTE (xLuxy): This prevents the infinite loop caused by alt.*.create
if (!args.length) return super();
+ assert(args.length === 2, "2 arguments expected");
+
const [spatial, maxDistance] = args;
return alt.VoiceChannel.create({ spatial, maxDistance });
}
diff --git a/shared/js/utils.js b/shared/js/utils.js
index e4b994984..056de5be5 100644
--- a/shared/js/utils.js
+++ b/shared/js/utils.js
@@ -50,6 +50,13 @@ export function assertIsType(value, type, message) {
assert(typeof value === type, message);
}
+export function assertIsOneOfType(value, types, message) {
+ assert(
+ types.some((type) => typeof value === type),
+ message
+ );
+}
+
export function assertNotNaN(val, message = "Expected number") {
assert(!isNaN(val), message);
}