@nativewrappers/fivem 0.0.65 → 0.0.72
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.
- package/Audio.d.ts +2 -2
- package/Blip.d.ts +2 -2
- package/Camera.d.ts +1 -1
- package/Game.d.ts +1 -1
- package/GameplayCamera.d.ts +1 -1
- package/Model.d.ts +1 -1
- package/ParticleEffect.d.ts +2 -2
- package/ParticleEffectAsset.d.ts +1 -1
- package/README.md +45 -0
- package/Raycast.d.ts +2 -2
- package/RelationshipGroup.d.ts +1 -1
- package/Tasks.d.ts +3 -3
- package/World.d.ts +2 -2
- package/cfx/StateBagChangeHandler.d.ts +1 -3
- package/common/Command.d.ts +30 -0
- package/common/Convar.d.ts +13 -0
- package/common/GlobalData.d.ts +8 -0
- package/common/Kvp.d.ts +69 -0
- package/common/Resource.d.ts +14 -0
- package/common/decors/Events.d.ts +54 -0
- package/common/index.d.ts +8 -0
- package/common/net/NetworkedMap.d.ts +28 -0
- package/common/types.d.ts +5 -0
- package/common/utils/ClassTypes.d.ts +11 -0
- package/common/utils/Color.d.ts +14 -0
- package/common/utils/Maths.d.ts +4 -0
- package/common/utils/PointF.d.ts +12 -0
- package/common/utils/Quaternion.d.ts +10 -0
- package/common/utils/Vector.d.ts +429 -0
- package/common/utils/Vector2.d.ts +1 -0
- package/common/utils/Vector3.d.ts +1 -0
- package/common/utils/Vector4.d.ts +1 -0
- package/common/utils/cleanPlayerName.d.ts +6 -0
- package/common/utils/enumValues.d.ts +12 -0
- package/{utils/getStringFromUInt8Array.js → common/utils/getStringFromUInt8Array.d.ts} +1 -3
- package/{utils/getUInt32FromUint8Array.js → common/utils/getUInt32FromUint8Array.d.ts} +1 -1
- package/common/utils/index.d.ts +12 -0
- package/index.d.ts +1 -1
- package/index.js +20136 -26
- package/interfaces/Dimensions.d.ts +1 -1
- package/models/BaseEntity.d.ts +3 -3
- package/models/Ped.d.ts +2 -2
- package/models/PedBone.d.ts +1 -1
- package/models/PedBoneCollection.d.ts +1 -1
- package/models/Player.d.ts +1 -1
- package/models/Vehicle.d.ts +2 -2
- package/models/VehicleDoor.d.ts +2 -2
- package/models/VehicleDoorCollection.d.ts +1 -1
- package/models/VehicleMod.d.ts +2 -2
- package/models/VehicleModCollection.d.ts +2 -2
- package/models/VehicleToggleMod.d.ts +2 -2
- package/models/VehicleWheel.d.ts +1 -1
- package/models/VehicleWheelCollection.d.ts +1 -1
- package/models/VehicleWindow.d.ts +2 -2
- package/models/VehicleWindowCollection.d.ts +1 -1
- package/package.json +6 -4
- package/ui/Container.d.ts +2 -2
- package/ui/Effects.d.ts +1 -1
- package/ui/Hud.d.ts +2 -2
- package/ui/InstructionalButtons.d.ts +1 -1
- package/ui/Rectangle.d.ts +2 -2
- package/ui/Scaleform.d.ts +1 -1
- package/ui/Screen.d.ts +1 -1
- package/ui/Text.d.ts +1 -1
- package/ui/interfaces/IButton.d.ts +1 -1
- package/ui/interfaces/IDrawable.d.ts +1 -1
- package/ui/menu/items/UIMenuItem.d.ts +1 -1
- package/ui/menu/items/UIMenuListItem.d.ts +1 -1
- package/ui/menu/items/panels/AbstractUIMenuPanel.d.ts +2 -2
- package/ui/menu/items/panels/UIMenuStatisticsPanel.d.ts +1 -1
- package/utils/LiteEvent.d.ts +2 -6
- package/utils/index.d.ts +1 -1
- package/weapon/DlcWeaponData.d.ts +1 -1
- package/weapon/Weapon.d.ts +7 -7
- package/weapon/WeaponAsset.d.ts +1 -1
- package/weapon/WeaponCollection.d.ts +2 -2
- package/weaponComponent/DlcWeaponComponentData.d.ts +1 -1
- package/weaponComponent/InvalidWeaponComponent.d.ts +1 -1
- package/weaponComponent/WeaponComponent.d.ts +3 -3
- package/weaponComponent/WeaponComponentCollection.d.ts +3 -3
- package/Audio.js +0 -93
- package/Blip.js +0 -105
- package/Camera.js +0 -162
- package/Checkpoint.js +0 -43
- package/Events.js +0 -74
- package/Game.js +0 -474
- package/GameplayCamera.js +0 -141
- package/Model.js +0 -213
- package/NetworkedScene.js +0 -18
- package/ParticleEffect.js +0 -123
- package/ParticleEffectAsset.js +0 -105
- package/Pickup.js +0 -19
- package/Raycast.js +0 -123
- package/RelationshipGroup.js +0 -67
- package/Rope.js +0 -129
- package/TaskSequence.js +0 -48
- package/Tasks.js +0 -241
- package/World.js +0 -765
- package/cfx/StateBagChangeHandler.js +0 -1
- package/cfx/index.js +0 -1
- package/enums/Alignment.js +0 -6
- package/enums/AnimationFlags.js +0 -35
- package/enums/AudioFlag.js +0 -38
- package/enums/BadgeStyle.js +0 -183
- package/enums/Blip.js +0 -225
- package/enums/Bone.js +0 -103
- package/enums/CameraShake.js +0 -14
- package/enums/CameraTypes.js +0 -8
- package/enums/CheckboxStyle.js +0 -5
- package/enums/Checkpoint.js +0 -67
- package/enums/CloudHat.js +0 -27
- package/enums/Control.js +0 -361
- package/enums/CursorSprite.js +0 -15
- package/enums/Driving.js +0 -34
- package/enums/ExplosionType.js +0 -45
- package/enums/FiringPattern.js +0 -20
- package/enums/Font.js +0 -8
- package/enums/ForceType.js +0 -9
- package/enums/Gender.js +0 -5
- package/enums/HelmetType.js +0 -6
- package/enums/HudColor.js +0 -184
- package/enums/HudComponent.js +0 -54
- package/enums/InputMode.js +0 -5
- package/enums/InvertAxis.js +0 -7
- package/enums/Language.js +0 -15
- package/enums/LeaveVehicleFlags.js +0 -11
- package/enums/LoadingSpinnerType.js +0 -8
- package/enums/MarkerType.js +0 -50
- package/enums/MenuAlignment.js +0 -5
- package/enums/NotificationType.js +0 -11
- package/enums/Parachute.js +0 -15
- package/enums/PickupType.js +0 -74
- package/enums/RadioStation.js +0 -25
- package/enums/RagdollType.js +0 -7
- package/enums/RaycastEnums.js +0 -32
- package/enums/Relationship.js +0 -10
- package/enums/RopeType.js +0 -6
- package/enums/ScreenEffect.js +0 -84
- package/enums/SpeechModifier.js +0 -40
- package/enums/Vehicle.js +0 -376
- package/enums/Weather.js +0 -22
- package/enums/ZoneID.js +0 -95
- package/enums/index.js +0 -42
- package/hashes/MaterialHash.js +0 -217
- package/hashes/PedHash.js +0 -725
- package/hashes/VehicleHash.js +0 -523
- package/hashes/WeaponHash.js +0 -161
- package/hashes/WeatherTypeHash.js +0 -22
- package/hashes/index.js +0 -5
- package/interfaces/Dimensions.js +0 -1
- package/models/BaseEntity.js +0 -477
- package/models/Entity.js +0 -25
- package/models/EntityBone.js +0 -26
- package/models/EntityBoneCollection.js +0 -18
- package/models/Ped.js +0 -692
- package/models/PedBone.js +0 -9
- package/models/PedBoneCollection.js +0 -21
- package/models/Player.js +0 -186
- package/models/Prop.js +0 -26
- package/models/Vehicle.js +0 -576
- package/models/VehicleDoor.js +0 -44
- package/models/VehicleDoorCollection.js +0 -62
- package/models/VehicleMod.js +0 -35
- package/models/VehicleModCollection.js +0 -227
- package/models/VehicleToggleMod.js +0 -29
- package/models/VehicleWheel.js +0 -23
- package/models/VehicleWheelCollection.js +0 -57
- package/models/VehicleWindow.js +0 -35
- package/models/VehicleWindowCollection.js +0 -57
- package/models/index.js +0 -19
- package/ui/Container.js +0 -31
- package/ui/Effects.js +0 -106
- package/ui/Fading.js +0 -69
- package/ui/Hud.js +0 -39
- package/ui/InstructionalButtons.js +0 -54
- package/ui/LoadingPrompt.js +0 -45
- package/ui/Notification.js +0 -9
- package/ui/Rectangle.js +0 -40
- package/ui/Scaleform.js +0 -236
- package/ui/Screen.js +0 -72
- package/ui/Sprite.js +0 -60
- package/ui/Text.js +0 -115
- package/ui/Timerbar.js +0 -248
- package/ui/index.js +0 -15
- package/ui/interfaces/IButton.js +0 -1
- package/ui/interfaces/IDrawable.js +0 -1
- package/ui/interfaces/index.js +0 -1
- package/ui/menu/Menu.js +0 -831
- package/ui/menu/MenuControl.js +0 -12
- package/ui/menu/MenuControls.js +0 -9
- package/ui/menu/MenuSettings.js +0 -54
- package/ui/menu/index.js +0 -6
- package/ui/menu/items/UIMenuCheckboxItem.js +0 -59
- package/ui/menu/items/UIMenuItem.js +0 -1111
- package/ui/menu/items/UIMenuListItem.js +0 -119
- package/ui/menu/items/UIMenuSeparatorItem.js +0 -29
- package/ui/menu/items/UIMenuSliderItem.js +0 -191
- package/ui/menu/items/index.js +0 -6
- package/ui/menu/items/panels/AbstractUIMenuPanel.js +0 -44
- package/ui/menu/items/panels/UIMenuColorPanel.js +0 -217
- package/ui/menu/items/panels/UIMenuGridPanel.js +0 -261
- package/ui/menu/items/panels/UIMenuPercentagePanel.js +0 -124
- package/ui/menu/items/panels/UIMenuStatisticsPanel.js +0 -79
- package/ui/menu/items/panels/UIMenuStatisticsPanelItem.js +0 -35
- package/ui/menu/items/panels/index.js +0 -6
- package/ui/menu/modules/ListItem.js +0 -10
- package/ui/menu/modules/index.js +0 -1
- package/utils/Animations.js +0 -55
- package/utils/Crypto.js +0 -25
- package/utils/LiteEvent.js +0 -19
- package/utils/Maths.js +0 -10
- package/utils/Point.js +0 -30
- package/utils/PointF.js +0 -14
- package/utils/Quaternion.js +0 -27
- package/utils/Size.js +0 -8
- package/utils/String.js +0 -25
- package/utils/enumValues.js +0 -14
- package/utils/index.js +0 -9
- package/weapon/DlcWeaponData.js +0 -44
- package/weapon/Mk2WeaponHash.js +0 -25
- package/weapon/Weapon.js +0 -270
- package/weapon/WeaponAsset.js +0 -84
- package/weapon/WeaponCollection.js +0 -187
- package/weapon/WeaponDisplayNameByHash.js +0 -75
- package/weapon/WeaponGroup.js +0 -19
- package/weapon/WeaponHudStats.js +0 -38
- package/weapon/WeaponLivery.js +0 -14
- package/weapon/WeaponLiveryColor.js +0 -35
- package/weapon/WeaponTint.js +0 -43
- package/weapon/index.js +0 -8
- package/weaponComponent/ComponentAttachmentPoint.js +0 -19
- package/weaponComponent/ComponentAttachmentPointByHash.js +0 -573
- package/weaponComponent/ComponentDisplayNameByHash.js +0 -280
- package/weaponComponent/DlcWeaponComponentData.js +0 -44
- package/weaponComponent/InvalidWeaponComponent.js +0 -28
- package/weaponComponent/WeaponComponent.js +0 -123
- package/weaponComponent/WeaponComponentCollection.js +0 -174
- package/weaponComponent/WeaponComponentHash.js +0 -887
- package/weaponComponent/WeaponComponentHashesByWeaponHash.js +0 -829
- package/weaponComponent/WeaponComponentHudStats.js +0 -34
- package/weaponComponent/index.js +0 -5
package/Camera.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { PedBone } from "./models";
|
|
2
|
-
import { BaseEntity } from "./models/BaseEntity";
|
|
3
|
-
import { Vector3 } from "./utils";
|
|
4
|
-
import { LoadAnimDict } from "./utils/Animations";
|
|
5
|
-
export class Camera {
|
|
6
|
-
static shakeNames = [
|
|
7
|
-
"HAND_SHAKE",
|
|
8
|
-
"SMALL_EXPLOSION_SHAKE",
|
|
9
|
-
"MEDIUM_EXPLOSION_SHAKE",
|
|
10
|
-
"LARGE_EXPLOSION_SHAKE",
|
|
11
|
-
"JOLT_SHAKE",
|
|
12
|
-
"VIBRATE_SHAKE",
|
|
13
|
-
"ROAD_VIBRATION_SHAKE",
|
|
14
|
-
"DRUNK_SHAKE",
|
|
15
|
-
"SKY_DIVING_SHAKE",
|
|
16
|
-
"FAMILY5_DRUG_TRIP_SHAKE",
|
|
17
|
-
"DEATH_FAIL_IN_EFFECT_SHAKE",
|
|
18
|
-
];
|
|
19
|
-
handle;
|
|
20
|
-
constructor(handle) {
|
|
21
|
-
this.handle = handle;
|
|
22
|
-
}
|
|
23
|
-
get Handle() {
|
|
24
|
-
return this.handle;
|
|
25
|
-
}
|
|
26
|
-
get IsActive() {
|
|
27
|
-
return IsCamActive(this.handle);
|
|
28
|
-
}
|
|
29
|
-
set IsActive(active) {
|
|
30
|
-
SetCamActive(this.handle, active);
|
|
31
|
-
}
|
|
32
|
-
get Position() {
|
|
33
|
-
return Vector3.fromArray(GetCamCoord(this.handle));
|
|
34
|
-
}
|
|
35
|
-
set Position(position) {
|
|
36
|
-
SetCamCoord(this.handle, position.x, position.y, position.z);
|
|
37
|
-
}
|
|
38
|
-
get Rotation() {
|
|
39
|
-
return Vector3.fromArray(GetCamRot(this.handle, 2));
|
|
40
|
-
}
|
|
41
|
-
set Rotation(rotation) {
|
|
42
|
-
SetCamRot(this.handle, rotation.x, rotation.y, rotation.z, 2);
|
|
43
|
-
}
|
|
44
|
-
// public get Matrix() : Matrix {}
|
|
45
|
-
/**
|
|
46
|
-
* Gets the direction the camera is facing. Same as ForwardVector
|
|
47
|
-
*/
|
|
48
|
-
get Direction() {
|
|
49
|
-
return this.ForwardVector;
|
|
50
|
-
}
|
|
51
|
-
set Direction(direction) {
|
|
52
|
-
const dir = direction.normalize();
|
|
53
|
-
const vec1 = new Vector3(dir.x, dir.y, 0);
|
|
54
|
-
const vec2 = new Vector3(dir.z, vec1.distanceSquared(vec1), 0);
|
|
55
|
-
const vec3 = vec2.normalize();
|
|
56
|
-
this.Rotation = new Vector3(Math.atan2(vec3.x, vec3.y) * 57.295779513082323, this.Rotation.y, Math.atan2(dir.x, dir.y) * -57.295779513082323);
|
|
57
|
-
}
|
|
58
|
-
// public get UpVector() : Vector3 {
|
|
59
|
-
// return Matrix.Up;
|
|
60
|
-
// }
|
|
61
|
-
get ForwardVector() {
|
|
62
|
-
const rotation = Vector3.multiply(this.Rotation, Math.PI / 180);
|
|
63
|
-
const normalized = Vector3.normalize(new Vector3(-Math.sin(rotation.z) * Math.abs(Math.cos(rotation.x)), Math.cos(rotation.z) * Math.abs(Math.cos(rotation.x)), Math.sin(rotation.x)));
|
|
64
|
-
return new Vector3(normalized.x, normalized.y, normalized.z);
|
|
65
|
-
}
|
|
66
|
-
// public get RightVector() : Vector3 {
|
|
67
|
-
// return Matrix.Right;
|
|
68
|
-
// }
|
|
69
|
-
// public Vector3 GetOffsetPosition(Vector3 offset) {
|
|
70
|
-
// return Vector3.TransformCoordinate(offset, Matrix);
|
|
71
|
-
// }
|
|
72
|
-
// public Vector3 GetPositionOffset(Vector3 worldCoords) {
|
|
73
|
-
// return Vector3.TransformCoordinate(worldCoords, Matrix.Invert(Matrix));
|
|
74
|
-
// }
|
|
75
|
-
get FieldOfView() {
|
|
76
|
-
return GetCamFov(this.handle);
|
|
77
|
-
}
|
|
78
|
-
set FieldOfView(fieldOfView) {
|
|
79
|
-
SetCamFov(this.handle, fieldOfView);
|
|
80
|
-
}
|
|
81
|
-
get NearClip() {
|
|
82
|
-
return GetCamNearClip(this.handle);
|
|
83
|
-
}
|
|
84
|
-
set NearClip(nearClip) {
|
|
85
|
-
SetCamNearClip(this.handle, nearClip);
|
|
86
|
-
}
|
|
87
|
-
get FarClip() {
|
|
88
|
-
return GetCamFarClip(this.handle);
|
|
89
|
-
}
|
|
90
|
-
set FarClip(farClip) {
|
|
91
|
-
SetCamFarClip(this.handle, farClip);
|
|
92
|
-
}
|
|
93
|
-
set NearDepthOfField(nearDepthOfField) {
|
|
94
|
-
SetCamNearDof(this.handle, nearDepthOfField);
|
|
95
|
-
}
|
|
96
|
-
get FarDepthOfField() {
|
|
97
|
-
return GetCamFarDof(this.handle);
|
|
98
|
-
}
|
|
99
|
-
set FarDepthOfField(farDepthOfField) {
|
|
100
|
-
SetCamFarDof(this.handle, farDepthOfField);
|
|
101
|
-
}
|
|
102
|
-
set DepthOfFieldStrength(strength) {
|
|
103
|
-
SetCamDofStrength(this.handle, strength);
|
|
104
|
-
}
|
|
105
|
-
set MotionBlurStrength(strength) {
|
|
106
|
-
SetCamMotionBlurStrength(this.handle, strength);
|
|
107
|
-
}
|
|
108
|
-
shake(shakeType, amplitude) {
|
|
109
|
-
ShakeCam(this.handle, Camera.shakeNames[Number(shakeType)], amplitude);
|
|
110
|
-
}
|
|
111
|
-
stopShaking() {
|
|
112
|
-
StopCamShaking(this.handle, true);
|
|
113
|
-
}
|
|
114
|
-
get IsShaking() {
|
|
115
|
-
return IsCamShaking(this.handle);
|
|
116
|
-
}
|
|
117
|
-
set ShakeAmplitude(amplitude) {
|
|
118
|
-
SetCamShakeAmplitude(this.handle, amplitude);
|
|
119
|
-
}
|
|
120
|
-
async playAnim(animName, animDict, position, rotation) {
|
|
121
|
-
await LoadAnimDict(animDict);
|
|
122
|
-
PlayCamAnim(this.handle, animName, animDict, position.x, position.y, position.z, rotation.x, rotation.y, rotation.z, false, 2);
|
|
123
|
-
RemoveAnimDict(animDict);
|
|
124
|
-
}
|
|
125
|
-
pointAt(target, offset = new Vector3(0, 0, 0)) {
|
|
126
|
-
if (target instanceof BaseEntity) {
|
|
127
|
-
PointCamAtEntity(this.handle, target.Handle, offset.x, offset.y, offset.z, true);
|
|
128
|
-
}
|
|
129
|
-
else if (target instanceof PedBone) {
|
|
130
|
-
PointCamAtPedBone(this.handle, target.Owner.Handle, target.Index, offset.x, offset.y, offset.z, true);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
PointCamAtCoord(this.handle, target.x, target.y, target.z);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
stopPointing() {
|
|
137
|
-
StopCamPointing(this.handle);
|
|
138
|
-
}
|
|
139
|
-
interpTo(to, duration, easePosition, easeRotation) {
|
|
140
|
-
SetCamActiveWithInterp(to.handle, this.handle, duration, Number(easePosition), Number(easeRotation));
|
|
141
|
-
}
|
|
142
|
-
get IsInterpolating() {
|
|
143
|
-
return IsCamInterpolating(this.handle);
|
|
144
|
-
}
|
|
145
|
-
attachTo(object, offset) {
|
|
146
|
-
if (object instanceof BaseEntity) {
|
|
147
|
-
AttachCamToEntity(this.handle, object.Handle, offset.x, offset.y, offset.z, true);
|
|
148
|
-
}
|
|
149
|
-
else if (object instanceof PedBone) {
|
|
150
|
-
AttachCamToPedBone(this.handle, object.Owner.Handle, object.Index, offset.x, offset.y, offset.z, true);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
detach() {
|
|
154
|
-
DetachCam(this.handle);
|
|
155
|
-
}
|
|
156
|
-
delete() {
|
|
157
|
-
DestroyCam(this.handle, false);
|
|
158
|
-
}
|
|
159
|
-
exists() {
|
|
160
|
-
return DoesCamExist(this.handle);
|
|
161
|
-
}
|
|
162
|
-
}
|
package/Checkpoint.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { CheckpointIcon } from "./enums";
|
|
2
|
-
import { Vector3 } from "./utils";
|
|
3
|
-
export class Checkpoint {
|
|
4
|
-
handle;
|
|
5
|
-
position = new Vector3(0, 0, 0);
|
|
6
|
-
targetPosition = new Vector3(0, 0, 0);
|
|
7
|
-
icon = CheckpointIcon.Empty;
|
|
8
|
-
radius = 0;
|
|
9
|
-
constructor(handle) {
|
|
10
|
-
this.handle = handle;
|
|
11
|
-
}
|
|
12
|
-
get Position() {
|
|
13
|
-
return this.position;
|
|
14
|
-
}
|
|
15
|
-
set Position(position) {
|
|
16
|
-
this.position = position;
|
|
17
|
-
}
|
|
18
|
-
get TargetPosition() {
|
|
19
|
-
return this.targetPosition;
|
|
20
|
-
}
|
|
21
|
-
set TargetPosition(targetPosition) {
|
|
22
|
-
this.targetPosition = targetPosition;
|
|
23
|
-
}
|
|
24
|
-
get Icon() {
|
|
25
|
-
return this.icon;
|
|
26
|
-
}
|
|
27
|
-
set Icon(icon) {
|
|
28
|
-
this.icon = icon;
|
|
29
|
-
}
|
|
30
|
-
// TODO
|
|
31
|
-
// public get CustomIcon(): CheckpointIcon {
|
|
32
|
-
// return this.icon;
|
|
33
|
-
// }
|
|
34
|
-
// public set CustomIcon(icon: CheckpointIcon) {
|
|
35
|
-
// this.icon = icon;
|
|
36
|
-
// }
|
|
37
|
-
get Radius() {
|
|
38
|
-
return this.radius;
|
|
39
|
-
}
|
|
40
|
-
set Radius(radius) {
|
|
41
|
-
this.radius = radius;
|
|
42
|
-
}
|
|
43
|
-
}
|
package/Events.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { ClassTypes } from "../common/utils/ClassTypes";
|
|
2
|
-
import { Ped } from "./models/Ped";
|
|
3
|
-
import { Vector2, Vector3, Vector4 } from "./utils";
|
|
4
|
-
import { Player } from "./models/Player";
|
|
5
|
-
import { Prop } from "./models/Prop";
|
|
6
|
-
import { Vehicle } from "./models/Vehicle";
|
|
7
|
-
import { BaseEntity } from "./models";
|
|
8
|
-
const getClassFromArguments = (...args) => {
|
|
9
|
-
const newArgs = [];
|
|
10
|
-
for (const arg of args) {
|
|
11
|
-
if (!arg.type) {
|
|
12
|
-
newArgs.push(arg);
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
switch (arg.type) {
|
|
16
|
-
case ClassTypes.Vector2: {
|
|
17
|
-
newArgs.push(Vector2.fromObject(arg));
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
case ClassTypes.Vector3: {
|
|
21
|
-
newArgs.push(Vector3.fromObject(arg));
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
case ClassTypes.Vector4: {
|
|
25
|
-
newArgs.push(Vector4.fromObject(arg));
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
case ClassTypes.Ped: {
|
|
29
|
-
newArgs.push(Ped.fromNetworkId(arg.handle));
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
case ClassTypes.Player: {
|
|
33
|
-
newArgs.push(Player.fromServerId(arg.source));
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
case ClassTypes.Prop: {
|
|
37
|
-
newArgs.push(Prop.fromNetworkId(arg.handle));
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
case ClassTypes.Vehicle: {
|
|
41
|
-
newArgs.push(Vehicle.fromNetworkId(arg.netId));
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
case ClassTypes.Entity: {
|
|
45
|
-
newArgs.push(BaseEntity.fromNetworkId(arg.netId));
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
default: {
|
|
49
|
-
newArgs.push(arg);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return newArgs;
|
|
54
|
-
};
|
|
55
|
-
// TODO: Add a third argument to enable recursive decent and change any
|
|
56
|
-
// object/array to its proper type
|
|
57
|
-
export class Events {
|
|
58
|
-
/**
|
|
59
|
-
* An onNet wrapper that properly converts the type into the correct type
|
|
60
|
-
*/
|
|
61
|
-
static onNet = (eventName, event) => {
|
|
62
|
-
onNet(eventName, (...args) => {
|
|
63
|
-
event(...getClassFromArguments(...args));
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* An on wrapper that properly converts the classes
|
|
68
|
-
*/
|
|
69
|
-
static on = (eventName, event) => {
|
|
70
|
-
on(eventName, (...args) => {
|
|
71
|
-
event(...getClassFromArguments(...args));
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
}
|