@nativewrappers/fivem 0.0.80 → 0.0.81
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/Audio.js +99 -0
- package/Blip.d.ts +4 -3
- package/Blip.js +113 -0
- package/Camera.d.ts +3 -3
- package/Camera.js +190 -0
- package/Checkpoint.d.ts +2 -2
- package/Checkpoint.js +51 -0
- package/Events.js +80 -0
- package/Game.d.ts +10 -3
- package/Game.js +478 -0
- package/GameplayCamera.d.ts +2 -2
- package/GameplayCamera.js +152 -0
- package/Model.js +210 -0
- package/NetworkedScene.d.ts +2 -1
- package/NetworkedScene.js +50 -0
- package/ParticleEffect.d.ts +4 -3
- package/ParticleEffect.js +128 -0
- package/ParticleEffectAsset.d.ts +2 -2
- package/ParticleEffectAsset.js +133 -0
- package/Pickup.d.ts +1 -1
- package/Pickup.js +27 -0
- package/Raycast.d.ts +5 -3
- package/Raycast.js +132 -0
- package/RelationshipGroup.d.ts +1 -1
- package/RelationshipGroup.js +72 -0
- package/Rope.d.ts +1 -1
- package/Rope.js +149 -0
- package/TaskSequence.js +52 -0
- package/Tasks.d.ts +8 -3
- package/Tasks.js +334 -0
- package/World.d.ts +13 -4
- package/World.js +945 -0
- package/cfx/StateBagChangeHandler.js +0 -0
- package/cfx/index.d.ts +1 -1
- package/cfx/index.js +4 -0
- package/common/Command.js +111 -0
- package/common/Convar.js +58 -0
- package/common/GlobalData.js +16 -0
- package/common/Kvp.js +137 -0
- package/common/Resource.js +54 -0
- package/common/decors/Events.js +170 -0
- package/common/net/NetworkedMap.js +225 -0
- package/common/types.js +0 -0
- package/common/utils/ClassTypes.js +15 -0
- package/common/utils/Color.js +33 -0
- package/common/utils/Delay.d.ts +1 -0
- package/common/utils/Delay.js +6 -0
- package/common/utils/Maths.js +18 -0
- package/common/utils/Point.d.ts +9 -0
- package/common/utils/Point.js +36 -0
- package/common/utils/PointF.d.ts +1 -1
- package/common/utils/PointF.js +18 -0
- package/common/utils/Quaternion.d.ts +1 -1
- package/common/utils/Quaternion.js +33 -0
- package/common/utils/Vector.js +589 -0
- package/common/utils/cleanPlayerName.js +17 -0
- package/common/utils/enumValues.js +20 -0
- package/common/utils/getStringFromUInt8Array.js +6 -0
- package/common/utils/getUInt32FromUint8Array.js +6 -0
- package/enums/Alignment.js +9 -0
- package/enums/AnimationFlags.js +38 -0
- package/enums/AudioFlag.js +41 -0
- package/enums/BadgeStyle.js +186 -0
- package/enums/Blip.js +229 -0
- package/enums/Bone.js +105 -0
- package/enums/CameraShake.js +17 -0
- package/enums/CameraTypes.js +11 -0
- package/enums/CheckboxStyle.js +8 -0
- package/enums/Checkpoint.js +68 -0
- package/enums/CloudHat.js +27 -0
- package/enums/Control.js +364 -0
- package/enums/CursorSprite.js +18 -0
- package/enums/Driving.js +38 -0
- package/enums/ExplosionType.js +45 -0
- package/enums/FiringPattern.js +23 -0
- package/enums/Font.js +11 -0
- package/enums/ForceType.js +12 -0
- package/enums/Gender.js +8 -0
- package/enums/HelmetType.js +9 -0
- package/enums/HudColor.js +187 -0
- package/enums/HudComponent.js +57 -0
- package/enums/InputMode.js +8 -0
- package/enums/InvertAxis.js +10 -0
- package/enums/Language.js +18 -0
- package/enums/LeaveVehicleFlags.js +14 -0
- package/enums/LoadingSpinnerType.js +11 -0
- package/enums/MarkerType.js +48 -0
- package/enums/MenuAlignment.js +8 -0
- package/enums/NotificationType.js +14 -0
- package/enums/Parachute.js +19 -0
- package/enums/PickupType.js +77 -0
- package/enums/RadioStation.js +28 -0
- package/enums/RagdollType.js +10 -0
- package/enums/RaycastEnums.js +33 -0
- package/enums/Relationship.js +13 -0
- package/enums/RopeType.js +9 -0
- package/enums/ScreenEffect.js +87 -0
- package/enums/SpeechModifier.js +43 -0
- package/enums/Vehicle.js +396 -0
- package/enums/Weather.js +22 -0
- package/enums/ZoneID.js +95 -0
- package/hashes/MaterialHash.js +220 -0
- package/hashes/PedHash.js +728 -0
- package/hashes/VehicleHash.js +526 -0
- package/hashes/WeaponHash.js +155 -0
- package/hashes/WeatherTypeHash.js +22 -0
- package/interfaces/Dimensions.d.ts +1 -1
- package/interfaces/Dimensions.js +0 -0
- package/models/BaseEntity.d.ts +10 -8
- package/models/BaseEntity.js +576 -0
- package/models/Entity.d.ts +0 -1
- package/models/Entity.js +0 -0
- package/models/EntityBone.d.ts +1 -1
- package/models/EntityBone.js +32 -0
- package/models/EntityBoneCollection.d.ts +1 -1
- package/models/EntityBoneCollection.js +27 -0
- package/models/Ped.d.ts +13 -5
- package/models/Ped.js +711 -0
- package/models/PedBone.d.ts +3 -2
- package/models/PedBone.js +18 -0
- package/models/PedBoneCollection.d.ts +3 -1
- package/models/PedBoneCollection.js +31 -0
- package/models/Player.d.ts +4 -2
- package/models/Player.js +188 -0
- package/models/Prop.d.ts +1 -1
- package/models/Prop.js +34 -0
- package/models/Vehicle.d.ts +9 -4
- package/models/Vehicle.js +582 -0
- package/models/VehicleDoor.d.ts +1 -1
- package/models/VehicleDoor.js +52 -0
- package/models/VehicleDoorCollection.d.ts +1 -1
- package/models/VehicleDoorCollection.js +66 -0
- package/models/VehicleMod.d.ts +1 -1
- package/models/VehicleMod.js +43 -0
- package/models/VehicleModCollection.d.ts +2 -2
- package/models/VehicleModCollection.js +227 -0
- package/models/VehicleToggleMod.d.ts +1 -1
- package/models/VehicleToggleMod.js +37 -0
- package/models/VehicleWheel.js +31 -0
- package/models/VehicleWheelCollection.d.ts +1 -1
- package/models/VehicleWheelCollection.js +61 -0
- package/models/VehicleWindow.d.ts +1 -1
- package/models/VehicleWindow.js +43 -0
- package/models/VehicleWindowCollection.d.ts +1 -1
- package/models/VehicleWindowCollection.js +62 -0
- package/package.json +2 -2
- package/ui/Container.d.ts +4 -2
- package/ui/Container.js +39 -0
- package/ui/Effects.d.ts +1 -1
- package/ui/Effects.js +112 -0
- package/ui/Fading.js +74 -0
- package/ui/Hud.d.ts +3 -2
- package/ui/Hud.js +47 -0
- package/ui/InstructionalButtons.js +42 -0
- package/ui/LoadingPrompt.d.ts +1 -1
- package/ui/LoadingPrompt.js +37 -0
- package/ui/Notification.js +17 -0
- package/ui/Rectangle.d.ts +4 -2
- package/ui/Rectangle.js +46 -0
- package/ui/Scaleform.d.ts +2 -1
- package/ui/Scaleform.js +240 -0
- package/ui/Screen.d.ts +6 -3
- package/ui/Screen.js +83 -0
- package/ui/Sprite.d.ts +3 -1
- package/ui/Sprite.js +70 -0
- package/ui/Text.d.ts +6 -3
- package/ui/Text.js +119 -0
- package/ui/Timerbar.js +241 -0
- package/ui/interfaces/IButton.d.ts +1 -1
- package/ui/interfaces/IButton.js +0 -0
- package/ui/interfaces/IDrawable.d.ts +3 -1
- package/ui/interfaces/IDrawable.js +0 -0
- package/ui/menu/Menu.d.ts +9 -4
- package/ui/menu/Menu.js +830 -0
- package/ui/menu/MenuControl.js +20 -0
- package/ui/menu/MenuControls.js +17 -0
- package/ui/menu/MenuSettings.d.ts +1 -1
- package/ui/menu/MenuSettings.js +57 -0
- package/ui/menu/items/UIMenuCheckboxItem.d.ts +3 -3
- package/ui/menu/items/UIMenuCheckboxItem.js +70 -0
- package/ui/menu/items/UIMenuItem.d.ts +10 -4
- package/ui/menu/items/UIMenuItem.js +1103 -0
- package/ui/menu/items/UIMenuListItem.d.ts +3 -3
- package/ui/menu/items/UIMenuListItem.js +118 -0
- package/ui/menu/items/UIMenuSeparatorItem.d.ts +1 -1
- package/ui/menu/items/UIMenuSeparatorItem.js +37 -0
- package/ui/menu/items/UIMenuSliderItem.d.ts +4 -3
- package/ui/menu/items/UIMenuSliderItem.js +180 -0
- package/ui/menu/items/panels/AbstractUIMenuPanel.d.ts +4 -3
- package/ui/menu/items/panels/AbstractUIMenuPanel.js +49 -0
- package/ui/menu/items/panels/UIMenuColorPanel.d.ts +3 -3
- package/ui/menu/items/panels/UIMenuColorPanel.js +215 -0
- package/ui/menu/items/panels/UIMenuGridPanel.d.ts +3 -3
- package/ui/menu/items/panels/UIMenuGridPanel.js +216 -0
- package/ui/menu/items/panels/UIMenuPercentagePanel.d.ts +2 -2
- package/ui/menu/items/panels/UIMenuPercentagePanel.js +138 -0
- package/ui/menu/items/panels/UIMenuStatisticsPanel.d.ts +3 -2
- package/ui/menu/items/panels/UIMenuStatisticsPanel.js +88 -0
- package/ui/menu/items/panels/UIMenuStatisticsPanelItem.d.ts +2 -1
- package/ui/menu/items/panels/UIMenuStatisticsPanelItem.js +48 -0
- package/ui/menu/modules/ListItem.js +18 -0
- package/utils/Animations.js +43 -0
- package/utils/Crypto.js +33 -0
- package/utils/LiteEvent.js +25 -0
- package/utils/Maths.js +18 -0
- package/utils/Point.js +36 -0
- package/utils/Size.js +16 -0
- package/utils/String.d.ts +1 -1
- package/utils/String.js +35 -0
- package/weapon/DlcWeaponData.d.ts +1 -1
- package/weapon/DlcWeaponData.js +40 -0
- package/weapon/Mk2WeaponHash.js +18 -0
- package/weapon/Weapon.d.ts +7 -7
- package/weapon/Weapon.js +276 -0
- package/weapon/WeaponAsset.d.ts +1 -1
- package/weapon/WeaponAsset.js +87 -0
- package/weapon/WeaponCollection.d.ts +3 -2
- package/weapon/WeaponCollection.js +179 -0
- package/weapon/WeaponDisplayNameByHash.d.ts +1 -1
- package/weapon/WeaponDisplayNameByHash.js +73 -0
- package/weapon/WeaponGroup.js +22 -0
- package/weapon/WeaponHudStats.d.ts +1 -1
- package/weapon/WeaponHudStats.js +33 -0
- package/weapon/WeaponLivery.js +17 -0
- package/weapon/WeaponLiveryColor.js +38 -0
- package/weapon/WeaponTint.js +46 -0
- package/weaponComponent/ComponentAttachmentPoint.js +22 -0
- package/weaponComponent/ComponentAttachmentPointByHash.js +307 -0
- package/weaponComponent/ComponentDisplayNameByHash.js +278 -0
- package/weaponComponent/DlcWeaponComponentData.js +40 -0
- package/weaponComponent/InvalidWeaponComponent.d.ts +1 -1
- package/weaponComponent/InvalidWeaponComponent.js +31 -0
- package/weaponComponent/WeaponComponent.d.ts +4 -4
- package/weaponComponent/WeaponComponent.js +124 -0
- package/weaponComponent/WeaponComponentCollection.d.ts +2 -2
- package/weaponComponent/WeaponComponentCollection.js +187 -0
- package/weaponComponent/WeaponComponentHash.js +670 -0
- package/weaponComponent/WeaponComponentHashesByWeaponHash.d.ts +1 -1
- package/weaponComponent/WeaponComponentHashesByWeaponHash.js +864 -0
- package/weaponComponent/WeaponComponentHudStats.js +33 -0
- package/common/index.d.ts +0 -8
- package/common/utils/Vector2.d.ts +0 -1
- package/common/utils/Vector3.d.ts +0 -1
- package/common/utils/Vector4.d.ts +0 -1
- package/common/utils/index.d.ts +0 -12
- package/enums/index.d.ts +0 -42
- package/hashes/index.d.ts +0 -5
- package/index.d.ts +0 -25
- package/index.js +0 -18794
- package/models/index.d.ts +0 -18
- package/ui/index.d.ts +0 -15
- package/ui/interfaces/index.d.ts +0 -2
- package/ui/menu/index.d.ts +0 -6
- package/ui/menu/items/index.d.ts +0 -6
- package/ui/menu/items/panels/index.d.ts +0 -6
- package/ui/menu/modules/index.d.ts +0 -1
- package/utils/PointF.d.ts +0 -7
- package/utils/Quaternion.d.ts +0 -10
- package/utils/enumValues.d.ts +0 -12
- package/utils/getStringFromUInt8Array.d.ts +0 -8
- package/utils/getUInt32FromUint8Array.d.ts +0 -8
- package/utils/index.d.ts +0 -9
- package/weapon/index.d.ts +0 -8
- package/weaponComponent/index.d.ts +0 -5
package/World.js
ADDED
|
@@ -0,0 +1,945 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { Blip } from "./Blip";
|
|
4
|
+
import { Camera } from "./Camera";
|
|
5
|
+
import { CameraTypes } from "./enums/CameraTypes";
|
|
6
|
+
import { CloudHat } from "./enums/CloudHat";
|
|
7
|
+
import { IntersectFlags, SHAPE_TEST_DEFAULT } from "./enums/RaycastEnums";
|
|
8
|
+
import { Weather } from "./enums/Weather";
|
|
9
|
+
import { GameplayCamera } from "./GameplayCamera";
|
|
10
|
+
import { VehicleHash } from "./hashes/VehicleHash";
|
|
11
|
+
import { Model } from "./Model";
|
|
12
|
+
import { Ped } from "./models/Ped";
|
|
13
|
+
import { Prop } from "./models/Prop";
|
|
14
|
+
import { Vehicle } from "./models/Vehicle";
|
|
15
|
+
import { Pickup } from "./Pickup";
|
|
16
|
+
import { AsynchronousRaycastResult, SynchronousRaycastResult } from "./Raycast";
|
|
17
|
+
import { Rope } from "./Rope";
|
|
18
|
+
import { Maths } from "./utils/Maths";
|
|
19
|
+
import { Vector3 } from "./common/utils/Vector";
|
|
20
|
+
class World {
|
|
21
|
+
static {
|
|
22
|
+
__name(this, "World");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get the current camera that's rendering.
|
|
26
|
+
*
|
|
27
|
+
* @returns The camera that's currently used.
|
|
28
|
+
*/
|
|
29
|
+
static get RenderingCamera() {
|
|
30
|
+
return new Camera(GetRenderingCam());
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Set the rendering camera. World.RenderingCamera = null to reset.
|
|
34
|
+
*
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const position = new Vector3(-802.311, 175.056, 72.8446);
|
|
37
|
+
* const myCamera = World.createCamera(position, new Vector3(0,0,0), 180);
|
|
38
|
+
* World.RenderingCamera = myCamera;
|
|
39
|
+
*
|
|
40
|
+
* // Reset to default cam
|
|
41
|
+
* World.RenderingCamera = null;
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param value The camera to render.
|
|
45
|
+
*/
|
|
46
|
+
static set RenderingCamera(value) {
|
|
47
|
+
if (value === null) {
|
|
48
|
+
RenderScriptCams(false, false, 3e3, true, false);
|
|
49
|
+
} else {
|
|
50
|
+
value.IsActive = true;
|
|
51
|
+
RenderScriptCams(true, false, 3e3, true, false);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Whether to create a network world state for Ropes
|
|
56
|
+
* This currently does nothing
|
|
57
|
+
*/
|
|
58
|
+
static set RopesCreateNetworkWorldState(value) {
|
|
59
|
+
SetRopesCreateNetworkWorldState(value);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the current date in the world.
|
|
63
|
+
*
|
|
64
|
+
* @returns The current date.
|
|
65
|
+
*/
|
|
66
|
+
static get CurrentDate() {
|
|
67
|
+
const year = GetClockYear();
|
|
68
|
+
const month = GetClockMonth();
|
|
69
|
+
const day = GetClockDayOfMonth();
|
|
70
|
+
const hour = GetClockHours();
|
|
71
|
+
const minutes = GetClockMinutes();
|
|
72
|
+
const seconds = GetClockSeconds();
|
|
73
|
+
return new Date(year, month, day, hour, minutes, seconds);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Set the current date of the world.
|
|
77
|
+
*/
|
|
78
|
+
static set CurrentDate(date) {
|
|
79
|
+
SetClockDate(date.getDate(), date.getMonth(), date.getFullYear());
|
|
80
|
+
NetworkOverrideClockTime(date.getHours(), date.getMinutes(), date.getSeconds());
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Disables all emissive textures, street/building/vehicle lights. "EMP" effect.
|
|
84
|
+
*
|
|
85
|
+
* @param value On or off.
|
|
86
|
+
*/
|
|
87
|
+
static set Blackout(value) {
|
|
88
|
+
SetBlackout(value);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get the current cloud hat.
|
|
92
|
+
*
|
|
93
|
+
* @returns The current cloud hat type.
|
|
94
|
+
*/
|
|
95
|
+
static get CloudHat() {
|
|
96
|
+
return this.currentCloudHat;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Set the current cloud hat.
|
|
100
|
+
*
|
|
101
|
+
* @param value The type of cloud hat.
|
|
102
|
+
*/
|
|
103
|
+
static set CloudHat(value) {
|
|
104
|
+
this.currentCloudHat = value;
|
|
105
|
+
if (this.currentCloudHat === CloudHat.Unknown) {
|
|
106
|
+
this.currentCloudHat = CloudHat.Clear;
|
|
107
|
+
ClearCloudHat();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
SetCloudHatTransition(this.cloudHatDict.get(this.currentCloudHat) ?? "", 3);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get the opacity of current cloud hat. Value is between 0-1.
|
|
114
|
+
*
|
|
115
|
+
* @returns The current cloud opacity between 0.0 and 1.0
|
|
116
|
+
*/
|
|
117
|
+
static get CloudHatOpacity() {
|
|
118
|
+
return GetCloudHatOpacity();
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Set opacity of current cloud hat between 0-1.
|
|
122
|
+
*
|
|
123
|
+
* @param value Opacity between 0.0 and 1.0
|
|
124
|
+
*/
|
|
125
|
+
static set CloudHatOpacity(value) {
|
|
126
|
+
SetCloudHatOpacity(Maths.clamp(value, 0, 1));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get the current weather type.
|
|
130
|
+
*
|
|
131
|
+
* @returns The current type of weather.
|
|
132
|
+
*/
|
|
133
|
+
static get Weather() {
|
|
134
|
+
switch (GetPrevWeatherTypeHashName()) {
|
|
135
|
+
case -1750463879:
|
|
136
|
+
return Weather.ExtraSunny;
|
|
137
|
+
case 916995460:
|
|
138
|
+
return Weather.Clear;
|
|
139
|
+
case -1530260698:
|
|
140
|
+
return Weather.Neutral;
|
|
141
|
+
case 282916021:
|
|
142
|
+
return Weather.Smog;
|
|
143
|
+
case -1368164796:
|
|
144
|
+
return Weather.Foggy;
|
|
145
|
+
case 821931868:
|
|
146
|
+
return Weather.Clouds;
|
|
147
|
+
case -1148613331:
|
|
148
|
+
return Weather.Overcast;
|
|
149
|
+
case 1840358669:
|
|
150
|
+
return Weather.Clearing;
|
|
151
|
+
case 1420204096:
|
|
152
|
+
return Weather.Raining;
|
|
153
|
+
case -1233681761:
|
|
154
|
+
return Weather.ThunderStorm;
|
|
155
|
+
case 669657108:
|
|
156
|
+
return Weather.Blizzard;
|
|
157
|
+
case -273223690:
|
|
158
|
+
return Weather.Snowing;
|
|
159
|
+
case 603685163:
|
|
160
|
+
return Weather.Snowlight;
|
|
161
|
+
case -1429616491:
|
|
162
|
+
return Weather.Christmas;
|
|
163
|
+
case -921030142:
|
|
164
|
+
return Weather.Halloween;
|
|
165
|
+
default:
|
|
166
|
+
return Weather.Unknown;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Set the current weather.
|
|
171
|
+
*
|
|
172
|
+
* @param value Type of weather to set.
|
|
173
|
+
*/
|
|
174
|
+
static set Weather(value) {
|
|
175
|
+
if (value !== Weather.Unknown) {
|
|
176
|
+
const weather = this.weatherDict[value];
|
|
177
|
+
SetWeatherTypeOverTime(weather, 1);
|
|
178
|
+
setTimeout(() => {
|
|
179
|
+
SetWeatherTypeNow(weather);
|
|
180
|
+
}, 100);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get the next weather type.
|
|
185
|
+
*
|
|
186
|
+
* @returns The Weather type
|
|
187
|
+
*/
|
|
188
|
+
static get NextWeather() {
|
|
189
|
+
switch (GetNextWeatherTypeHashName()) {
|
|
190
|
+
case -1750463879:
|
|
191
|
+
return Weather.ExtraSunny;
|
|
192
|
+
case 916995460:
|
|
193
|
+
return Weather.Clear;
|
|
194
|
+
case -1530260698:
|
|
195
|
+
return Weather.Neutral;
|
|
196
|
+
case 282916021:
|
|
197
|
+
return Weather.Smog;
|
|
198
|
+
case -1368164796:
|
|
199
|
+
return Weather.Foggy;
|
|
200
|
+
case 821931868:
|
|
201
|
+
return Weather.Clouds;
|
|
202
|
+
case -1148613331:
|
|
203
|
+
return Weather.Overcast;
|
|
204
|
+
case 1840358669:
|
|
205
|
+
return Weather.Clearing;
|
|
206
|
+
case 1420204096:
|
|
207
|
+
return Weather.Raining;
|
|
208
|
+
case -1233681761:
|
|
209
|
+
return Weather.ThunderStorm;
|
|
210
|
+
case 669657108:
|
|
211
|
+
return Weather.Blizzard;
|
|
212
|
+
case -273223690:
|
|
213
|
+
return Weather.Snowing;
|
|
214
|
+
case 603685163:
|
|
215
|
+
return Weather.Snowlight;
|
|
216
|
+
case -1429616491:
|
|
217
|
+
return Weather.Christmas;
|
|
218
|
+
case -921030142:
|
|
219
|
+
return Weather.Halloween;
|
|
220
|
+
default:
|
|
221
|
+
return Weather.Unknown;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Set weather type instantly. Similar to World.transitionToWeather with duration 0.
|
|
226
|
+
*/
|
|
227
|
+
static set NextWeather(value) {
|
|
228
|
+
if (value !== Weather.Unknown) {
|
|
229
|
+
const weather = this.weatherDict[value];
|
|
230
|
+
SetWeatherTypeOverTime(weather, 0);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Doesn't work
|
|
235
|
+
*/
|
|
236
|
+
static get WeatherTransition() {
|
|
237
|
+
const transition = GetWeatherTypeTransition();
|
|
238
|
+
return [this.weatherDict[transition[0]], this.weatherDict[transition[1]], transition[2]];
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Doesn't work
|
|
242
|
+
*/
|
|
243
|
+
static set WeatherTransition(transition) {
|
|
244
|
+
SetWeatherTypeTransition(transition[0], transition[1], transition[2]);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Transition to different weather type within a certain time.
|
|
248
|
+
*
|
|
249
|
+
* @param weather Weather type to change to.
|
|
250
|
+
* @param duration Time for full weather change (in milliseconds);
|
|
251
|
+
*/
|
|
252
|
+
static transitionToWeather(weather, duration) {
|
|
253
|
+
if (weather !== Weather.Unknown) {
|
|
254
|
+
SetWeatherTypeOverTime(this.weatherDict[weather], duration);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Destroys all existing cameras and sets your rendering camera back to GameplayCam.
|
|
259
|
+
*/
|
|
260
|
+
static destroyAllCameras() {
|
|
261
|
+
DestroyAllCams(false);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Creates a blip at a given position and optionally radius.
|
|
265
|
+
*
|
|
266
|
+
* ```typescript
|
|
267
|
+
* const position = new Vector3(-802.311, 175.056, 72.8446);
|
|
268
|
+
* const myStoreBlip = World.createBlip(position, 5.0);
|
|
269
|
+
* myStoreBlip.Sprite = BlipSprite.Store;
|
|
270
|
+
* ```
|
|
271
|
+
*
|
|
272
|
+
* @param position World coordinate of blip.
|
|
273
|
+
* @param radius (Optional) Radius of where blip should be shown.
|
|
274
|
+
* @returns Blip object.
|
|
275
|
+
*/
|
|
276
|
+
static createBlip(position, radius) {
|
|
277
|
+
if (radius !== null && radius !== void 0) {
|
|
278
|
+
return new Blip(AddBlipForRadius(position.x, position.y, position.z, radius));
|
|
279
|
+
}
|
|
280
|
+
return new Blip(AddBlipForCoord(position.x, position.y, position.z));
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Creates a cam that defaults to {@link CameraTypes.Scripted}
|
|
284
|
+
*
|
|
285
|
+
* ```ts
|
|
286
|
+
* const cam = World.createCamera(CameraTypes.Spline, true);
|
|
287
|
+
* ```
|
|
288
|
+
* @param cameraType the camera type to create
|
|
289
|
+
* @param active unknown
|
|
290
|
+
* @returns
|
|
291
|
+
*/
|
|
292
|
+
static createCamera(cameraType = CameraTypes.Scripted, active = true) {
|
|
293
|
+
return new Camera(CreateCam(cameraType, active));
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Creates a camera using 'DEFAULT_SCRIPTED_CAMERA'.
|
|
297
|
+
*
|
|
298
|
+
* ```typescript
|
|
299
|
+
* const position = new Vector3(-802.311, 175.056, 72.8446);
|
|
300
|
+
* const myCamera = World.createCameraWithParams(position, new Vector3(0,0,0), 180);
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* @param position World coordinate where the camera should render.
|
|
304
|
+
* @param rotation Rotation of camera relative to world.
|
|
305
|
+
* @param fieldOfView Field of view angle of camera.
|
|
306
|
+
* @returns Camera object.
|
|
307
|
+
*/
|
|
308
|
+
static createCameraWithParams(cameraType = CameraTypes.Scripted, position = Vector3.Zero, rotation = Vector3.Zero, fieldOfView = 90) {
|
|
309
|
+
return new Camera(
|
|
310
|
+
CreateCamWithParams(
|
|
311
|
+
cameraType,
|
|
312
|
+
position.x,
|
|
313
|
+
position.y,
|
|
314
|
+
position.z,
|
|
315
|
+
rotation.x,
|
|
316
|
+
rotation.y,
|
|
317
|
+
rotation.z,
|
|
318
|
+
fieldOfView,
|
|
319
|
+
true,
|
|
320
|
+
2
|
|
321
|
+
)
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Create a ped at a desired location.
|
|
326
|
+
*
|
|
327
|
+
* ```typescript
|
|
328
|
+
* const position = new Vector3(-802.311, 175.056, 72.8446);
|
|
329
|
+
* const model = new Model("a_f_m_beach_01");
|
|
330
|
+
* const myPed = await World.createPed(model, position);
|
|
331
|
+
* ```
|
|
332
|
+
*
|
|
333
|
+
* @param model Ped model to be spawned.
|
|
334
|
+
* @param position World position (coordinates) of Ped spawn.
|
|
335
|
+
* @param heading Heading of Ped when spawning.
|
|
336
|
+
* @param isNetwork
|
|
337
|
+
* @returns Ped object.
|
|
338
|
+
*/
|
|
339
|
+
static async createPed(model, position, heading = 0, isNetwork = true, pinToScript = true) {
|
|
340
|
+
if (!model.IsPed || !await model.request(1e3)) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
const ped = CreatePed(-1, model.Hash, position.x, position.y, position.z, heading, isNetwork, pinToScript);
|
|
344
|
+
model.markAsNoLongerNeeded();
|
|
345
|
+
if (ped === 0) {
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
return new Ped(ped);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Creates a [[`Ped`]] with a random model.
|
|
352
|
+
*
|
|
353
|
+
* ```typescript
|
|
354
|
+
* const position = new Vector3(-802.311, 175.056, 72.8446);
|
|
355
|
+
* const randomPed = World.createRandomPed(position);
|
|
356
|
+
* ```
|
|
357
|
+
*
|
|
358
|
+
* @param position World coordinate of Ped spawn.
|
|
359
|
+
* @returns Ped object.
|
|
360
|
+
*/
|
|
361
|
+
static createRandomPed(position) {
|
|
362
|
+
return new Ped(CreateRandomPed(position.x, position.y, position.z));
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Create a vehicle at a desired location.
|
|
366
|
+
*
|
|
367
|
+
* ```typescript
|
|
368
|
+
* const position = new Vector3(-802.311, 175.056, 72.8446);
|
|
369
|
+
* const model = new Model("adder");
|
|
370
|
+
* const myVehicle = await World.createVehicle(model, position);
|
|
371
|
+
* ```
|
|
372
|
+
*
|
|
373
|
+
* @param model Vehicle model to be spawned.
|
|
374
|
+
* @param position World position (coordinates) of Vehicle spawn.
|
|
375
|
+
* @param heading Heading of Vehicle when spawning.
|
|
376
|
+
* @param isNetwork
|
|
377
|
+
* @returns Vehicle object.
|
|
378
|
+
*/
|
|
379
|
+
static async createVehicle(model, position, heading = 0, isNetwork = true, pinToScript = true) {
|
|
380
|
+
if (!model.IsVehicle || !await model.request(1e3)) {
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
const vehicle = CreateVehicle(model.Hash, position.x, position.y, position.z, heading, isNetwork, pinToScript);
|
|
384
|
+
if (vehicle === 0) {
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
return new Vehicle(vehicle);
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Create a random vehicle at a desired location.
|
|
391
|
+
*
|
|
392
|
+
* ```typescript
|
|
393
|
+
* const position = new Vector3(-802.311, 175.056, 72.8446);
|
|
394
|
+
* const randomVehicle = await World.createRandomVehicle(position);
|
|
395
|
+
* ```
|
|
396
|
+
*
|
|
397
|
+
* @param position World position (coordinates) of Vehicle spawn.
|
|
398
|
+
* @param heading Heading of Vehicle when spawning.
|
|
399
|
+
* @param isNetwork
|
|
400
|
+
* @returns Vehicle object.
|
|
401
|
+
*/
|
|
402
|
+
static async createRandomVehicle(position, heading = 0, isNetwork = true) {
|
|
403
|
+
const vehicleCount = Object.keys(VehicleHash).length / 2;
|
|
404
|
+
const randomIndex = Maths.getRandomInt(0, vehicleCount);
|
|
405
|
+
const randomVehicleName = VehicleHash[randomIndex];
|
|
406
|
+
const modelHash = GetHashKey(randomVehicleName);
|
|
407
|
+
const model = new Model(modelHash);
|
|
408
|
+
return this.createVehicle(model, position, heading, isNetwork, false);
|
|
409
|
+
}
|
|
410
|
+
/*
|
|
411
|
+
* Creates a rope at the specified location.
|
|
412
|
+
*
|
|
413
|
+
* ```typescript
|
|
414
|
+
* const position = new Vector3(-802.311, 175.056, 72.8446)
|
|
415
|
+
* const rotation = new Vector3(0,0,0)
|
|
416
|
+
* const rope = await World.createRope(position, rotation, 15.0, RopeType.ThickRope, 3.0, 0.5);
|
|
417
|
+
* ```
|
|
418
|
+
*
|
|
419
|
+
* You should manually call `RopeUnloadTextures()` after you finish using **all** ropes, unlike models requesting rope models is instantaneous
|
|
420
|
+
* If called with collisionOn you will have to LoadRopeData after
|
|
421
|
+
*/
|
|
422
|
+
static async createRope(position, rotation, maxLength, ropeType, initLength, minLength, lengthChangeRate = 1, onlyPPU = false, collisionOn = false, lockFromFront = false, timeMultiplier = 1, breakable = false, shouldLoadTextures = true) {
|
|
423
|
+
if (shouldLoadTextures) {
|
|
424
|
+
if (!RopeAreTexturesLoaded()) {
|
|
425
|
+
RopeLoadTextures();
|
|
426
|
+
}
|
|
427
|
+
while (!RopeAreTexturesLoaded()) {
|
|
428
|
+
await Wait(0);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
const [ropeHandle] = AddRope(
|
|
432
|
+
position.x,
|
|
433
|
+
position.y,
|
|
434
|
+
position.z,
|
|
435
|
+
rotation.x,
|
|
436
|
+
rotation.y,
|
|
437
|
+
rotation.z,
|
|
438
|
+
maxLength,
|
|
439
|
+
ropeType,
|
|
440
|
+
initLength,
|
|
441
|
+
minLength,
|
|
442
|
+
lengthChangeRate,
|
|
443
|
+
onlyPPU,
|
|
444
|
+
collisionOn,
|
|
445
|
+
lockFromFront,
|
|
446
|
+
timeMultiplier,
|
|
447
|
+
breakable
|
|
448
|
+
);
|
|
449
|
+
return new Rope(ropeHandle);
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Spawns a [[`Prop`]] at the given position.
|
|
453
|
+
*
|
|
454
|
+
* ```typescript
|
|
455
|
+
* const position = new Vector3(-802.311, 175.056, 72.8446);
|
|
456
|
+
* const model = new Model("prop_barrel_02a");
|
|
457
|
+
* const myBarrelProp = await World.createProp(model, position, false, true);
|
|
458
|
+
* ```
|
|
459
|
+
*
|
|
460
|
+
* @param model The [[`Model`]] to spawn (must be a Prop)
|
|
461
|
+
* @param position Location of Prop
|
|
462
|
+
* @param doorFlag If set to true, the Prop will have physics otherwise it's static.
|
|
463
|
+
* @param placeOnGround If set to true, sets the Prop on the ground nearest to position.
|
|
464
|
+
* @param isNetwork
|
|
465
|
+
* @returns Prop object.
|
|
466
|
+
*/
|
|
467
|
+
static async createProp(model, position, placeOnGround, isNetwork = true, pinToScript = true, forceToBeObject = false) {
|
|
468
|
+
if (!model.IsProp || !await model.request(1e3)) {
|
|
469
|
+
return null;
|
|
470
|
+
}
|
|
471
|
+
const object = CreateObject(
|
|
472
|
+
model.Hash,
|
|
473
|
+
position.x,
|
|
474
|
+
position.y,
|
|
475
|
+
position.z,
|
|
476
|
+
isNetwork,
|
|
477
|
+
pinToScript,
|
|
478
|
+
forceToBeObject
|
|
479
|
+
);
|
|
480
|
+
model.markAsNoLongerNeeded();
|
|
481
|
+
if (object === 0) {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
const prop = new Prop(object);
|
|
485
|
+
if (placeOnGround) {
|
|
486
|
+
prop.placeOnGround();
|
|
487
|
+
}
|
|
488
|
+
return prop;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Create a pickup in a specific position in the world with a specified type and value.
|
|
492
|
+
*
|
|
493
|
+
* @param type The [[`PickupType`]] of pickup.
|
|
494
|
+
* @param position The position in the world it should be spawned.
|
|
495
|
+
* @param model The model of the spawned pickup.
|
|
496
|
+
* @param value Give a value for the pickup when picked up.
|
|
497
|
+
* @param rotation If set, create a rotating pickup with this rotation.
|
|
498
|
+
* @returns Pickup object.
|
|
499
|
+
*/
|
|
500
|
+
static async createPickup(type, position, model, value, rotation) {
|
|
501
|
+
if (!await model.request(1e3)) {
|
|
502
|
+
return null;
|
|
503
|
+
}
|
|
504
|
+
let handle = 0;
|
|
505
|
+
if (rotation !== void 0)
|
|
506
|
+
handle = CreatePickupRotate(
|
|
507
|
+
type,
|
|
508
|
+
position.x,
|
|
509
|
+
position.y,
|
|
510
|
+
position.z,
|
|
511
|
+
rotation.x,
|
|
512
|
+
rotation.y,
|
|
513
|
+
rotation.z,
|
|
514
|
+
0,
|
|
515
|
+
value,
|
|
516
|
+
2,
|
|
517
|
+
true,
|
|
518
|
+
model.Hash
|
|
519
|
+
);
|
|
520
|
+
else handle = CreatePickup(type, position.x, position.y, position.z, 0, value, true, model.Hash);
|
|
521
|
+
model.markAsNoLongerNeeded();
|
|
522
|
+
if (handle === 0) {
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
return new Pickup(handle);
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Creates an ambient pickup.
|
|
529
|
+
*
|
|
530
|
+
* @param type The [[`PickupType`]] of the pickup.
|
|
531
|
+
* @param position The position where it should be spawned.
|
|
532
|
+
* @param model The model.
|
|
533
|
+
* @param value The value tied to the pickup.
|
|
534
|
+
* @returns The pickup in form of a Prop.
|
|
535
|
+
*/
|
|
536
|
+
static async createAmbientPickup(type, position, model, value) {
|
|
537
|
+
if (!await model.request(1e3)) {
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
const handle = CreateAmbientPickup(type, position.x, position.y, position.z, 0, value, model.Hash, false, true);
|
|
541
|
+
model.markAsNoLongerNeeded();
|
|
542
|
+
if (handle === 0) {
|
|
543
|
+
return null;
|
|
544
|
+
}
|
|
545
|
+
return new Prop(handle);
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Draw a marker at a desired location. Careful! Must be drawn every tick.
|
|
549
|
+
*
|
|
550
|
+
* ```typescript
|
|
551
|
+
* const position = new Vector3(-802.311, 175.056, 72.8446);
|
|
552
|
+
* const zeroVector = new Vector3(0,0,0);
|
|
553
|
+
*
|
|
554
|
+
* setTick(() => {
|
|
555
|
+
* World.drawMarker(MarkerType.ThickChevronUp, position, zeroVector, zeroVector, 1.0, new Color(255,0,0));
|
|
556
|
+
* })
|
|
557
|
+
* ```
|
|
558
|
+
*
|
|
559
|
+
* @param type Type of marker.
|
|
560
|
+
* @param position Location of marker.
|
|
561
|
+
* @param direction Direction facing.
|
|
562
|
+
* @param rotation World rotation.
|
|
563
|
+
* @param scale Size of marker.
|
|
564
|
+
* @param color Color of marker.
|
|
565
|
+
* @param bobUpAndDown Animated movement along marker's own X axis.
|
|
566
|
+
* @param faceCamera Rendering marker facing rendering camera.
|
|
567
|
+
* @param rotateY Rotate along Y axis.
|
|
568
|
+
* @param textureDict Custom texture dictionary for custom marker.
|
|
569
|
+
* @param textureName Custom texture name for custom marker.
|
|
570
|
+
* @param drawOnEntity Render the marker on an entity.
|
|
571
|
+
*/
|
|
572
|
+
static drawMarker(type, position, direction, rotation, scale, color, bobUpAndDown = false, faceCamera = false, rotateY = false, textureDict = null, textureName = null, drawOnEntity = false) {
|
|
573
|
+
DrawMarker(
|
|
574
|
+
Number(type),
|
|
575
|
+
position.x,
|
|
576
|
+
position.y,
|
|
577
|
+
position.z,
|
|
578
|
+
direction.x,
|
|
579
|
+
direction.y,
|
|
580
|
+
direction.z,
|
|
581
|
+
rotation.x,
|
|
582
|
+
rotation.y,
|
|
583
|
+
rotation.z,
|
|
584
|
+
scale.x,
|
|
585
|
+
scale.y,
|
|
586
|
+
scale.z,
|
|
587
|
+
color.r,
|
|
588
|
+
color.g,
|
|
589
|
+
color.b,
|
|
590
|
+
color.a,
|
|
591
|
+
bobUpAndDown,
|
|
592
|
+
faceCamera,
|
|
593
|
+
2,
|
|
594
|
+
rotateY,
|
|
595
|
+
textureDict,
|
|
596
|
+
textureName,
|
|
597
|
+
drawOnEntity
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Creates a light in the world with a certain length (range).
|
|
602
|
+
*
|
|
603
|
+
* @param pos World coordinate where to draw the light.
|
|
604
|
+
* @param color RGB colors of the light.
|
|
605
|
+
* @param range How far to draw the light.
|
|
606
|
+
* @param intensity Intensity of the light ("alpha").
|
|
607
|
+
*/
|
|
608
|
+
static drawLightWithRange(pos, color, range, intensity) {
|
|
609
|
+
DrawLightWithRange(pos.x, pos.y, pos.z, color.r, color.g, color.b, range, intensity);
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Creates a light in the world. More configurable than World.drawLightWithRange.
|
|
613
|
+
*
|
|
614
|
+
* @param pos World coordinate of spotlight.
|
|
615
|
+
* @param dir Direction to face spotlight.
|
|
616
|
+
* @param color RGB colors of spotlight.
|
|
617
|
+
* @param distance The maximum distance the spotlight can reach.
|
|
618
|
+
* @param brightness Brightness of the spotlight.
|
|
619
|
+
* @param roundness "Smoothness" of the edge of the spotlight.
|
|
620
|
+
* @param radius Radius size of spotlight.
|
|
621
|
+
* @param fadeOut Falloff size of the spotlight's edge.
|
|
622
|
+
*/
|
|
623
|
+
static drawSpotLight(pos, dir, color, distance, brightness, roundness, radius, fadeOut) {
|
|
624
|
+
DrawSpotLight(
|
|
625
|
+
pos.x,
|
|
626
|
+
pos.y,
|
|
627
|
+
pos.z,
|
|
628
|
+
dir.x,
|
|
629
|
+
dir.y,
|
|
630
|
+
dir.z,
|
|
631
|
+
color.r,
|
|
632
|
+
color.g,
|
|
633
|
+
color.b,
|
|
634
|
+
distance,
|
|
635
|
+
brightness,
|
|
636
|
+
roundness,
|
|
637
|
+
radius,
|
|
638
|
+
fadeOut
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Creates a light in the world. Same as World.drawSpotlight, but also draws shadows.
|
|
643
|
+
*
|
|
644
|
+
* @param pos World coordinate of spotlight.
|
|
645
|
+
* @param dir Direction to face spotlight.
|
|
646
|
+
* @param color RGB colors of spotlight.
|
|
647
|
+
* @param distance The maximum distance the spotlight can reach.
|
|
648
|
+
* @param brightness Brightness of the spotlight.
|
|
649
|
+
* @param roundness "Smoothness" of the edge of the spotlight.
|
|
650
|
+
* @param radius Radius size of spotlight.
|
|
651
|
+
* @param fadeOut Falloff size of the spotlight's edge.
|
|
652
|
+
*/
|
|
653
|
+
static drawSpotLightWithShadow(pos, dir, color, distance, brightness, roundness, radius, fadeOut) {
|
|
654
|
+
DrawSpotLightWithShadow(
|
|
655
|
+
pos.x,
|
|
656
|
+
pos.y,
|
|
657
|
+
pos.z,
|
|
658
|
+
dir.x,
|
|
659
|
+
dir.y,
|
|
660
|
+
dir.z,
|
|
661
|
+
color.r,
|
|
662
|
+
color.g,
|
|
663
|
+
color.b,
|
|
664
|
+
distance,
|
|
665
|
+
brightness,
|
|
666
|
+
roundness,
|
|
667
|
+
radius,
|
|
668
|
+
fadeOut,
|
|
669
|
+
0
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Draws a line in the world. It's not possible to change thickness.
|
|
674
|
+
*
|
|
675
|
+
* @param start World coordinate of start position of line.
|
|
676
|
+
* @param end World coordinate of end position of line.
|
|
677
|
+
* @param color RGB color of line.
|
|
678
|
+
*/
|
|
679
|
+
static drawLine(start, end, color) {
|
|
680
|
+
DrawLine(start.x, start.y, start.z, end.x, end.y, end.z, color.r, color.g, color.b, color.a);
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Draw polygon in the world.
|
|
684
|
+
*
|
|
685
|
+
* @param vertexA World coordinate of first point.
|
|
686
|
+
* @param vertexB World coordinate of second point.
|
|
687
|
+
* @param vertexC World coordinate of third point.
|
|
688
|
+
* @param color RGB color of polygon.
|
|
689
|
+
*/
|
|
690
|
+
static drawPoly(vertexA, vertexB, vertexC, color) {
|
|
691
|
+
DrawPoly(
|
|
692
|
+
vertexA.x,
|
|
693
|
+
vertexA.y,
|
|
694
|
+
vertexA.z,
|
|
695
|
+
vertexB.x,
|
|
696
|
+
vertexB.y,
|
|
697
|
+
vertexB.z,
|
|
698
|
+
vertexC.x,
|
|
699
|
+
vertexC.y,
|
|
700
|
+
vertexC.z,
|
|
701
|
+
color.r,
|
|
702
|
+
color.g,
|
|
703
|
+
color.b,
|
|
704
|
+
color.a
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
// TODO: Add a raycast option for every type.
|
|
708
|
+
/**
|
|
709
|
+
* Cast a ray from {@param start} to {@param end}.
|
|
710
|
+
*
|
|
711
|
+
* @param start Starting position of raycast.
|
|
712
|
+
* @param end Direction to cast a ray to.
|
|
713
|
+
* @param losFlags The entity type(s) that the raycast should intersect with
|
|
714
|
+
* defaults to {@enum IntersectFlags.All}
|
|
715
|
+
* @param options Possible entity types to detect.
|
|
716
|
+
* @param ignoreEntity An entity to ignore (usually player's Ped).
|
|
717
|
+
* @returns {@see SynchronousRaycastResult} object.
|
|
718
|
+
*/
|
|
719
|
+
static expensiveRaycast(start, end, losFlags = IntersectFlags.All, shapeTestOptions = SHAPE_TEST_DEFAULT, ignoreEntity) {
|
|
720
|
+
return new SynchronousRaycastResult(
|
|
721
|
+
StartExpensiveSynchronousShapeTestLosProbe(
|
|
722
|
+
start.x,
|
|
723
|
+
start.y,
|
|
724
|
+
start.z,
|
|
725
|
+
end.x,
|
|
726
|
+
end.y,
|
|
727
|
+
end.z,
|
|
728
|
+
losFlags,
|
|
729
|
+
ignoreEntity?.Handle ?? 0,
|
|
730
|
+
shapeTestOptions
|
|
731
|
+
)
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Cast a ray from {@param start} to {@param end} and returns the first hit
|
|
736
|
+
* entity or coordinate .
|
|
737
|
+
*
|
|
738
|
+
* @param start starting position of raycast.
|
|
739
|
+
* @param end the ending position to raycast to.
|
|
740
|
+
* @param losFlags The entity type(s) that the raycast should intersect with defaults to {@enum IntersectFlags.All}
|
|
741
|
+
* @param shapeTestOptions shape test collision modifiers defaults to ignoring glass, see through, and no collided entities
|
|
742
|
+
* @param ignoreEntity An entity to ignore (usually player's Ped).
|
|
743
|
+
* @returns {@see AsynchronousRaycastResult} object that must be awaited to get its results.
|
|
744
|
+
*/
|
|
745
|
+
static raycast(start, end, losFlags = IntersectFlags.All, shapeTestOptions = SHAPE_TEST_DEFAULT, ignoreEntity) {
|
|
746
|
+
return new AsynchronousRaycastResult(
|
|
747
|
+
StartShapeTestLosProbe(
|
|
748
|
+
start.x,
|
|
749
|
+
start.y,
|
|
750
|
+
start.z,
|
|
751
|
+
end.x,
|
|
752
|
+
end.y,
|
|
753
|
+
end.z,
|
|
754
|
+
losFlags,
|
|
755
|
+
ignoreEntity?.Handle ?? 0,
|
|
756
|
+
shapeTestOptions
|
|
757
|
+
)
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
static raycastDirection(useExpensiveRaycast, source, direction, maxDistance, losFlags = IntersectFlags.All, shapeTestOptions = SHAPE_TEST_DEFAULT, ignoreEntity) {
|
|
761
|
+
const target = Vector3.add(source, Vector3.multiply(direction, maxDistance));
|
|
762
|
+
if (useExpensiveRaycast) {
|
|
763
|
+
return new SynchronousRaycastResult(
|
|
764
|
+
StartExpensiveSynchronousShapeTestLosProbe(
|
|
765
|
+
source.x,
|
|
766
|
+
source.y,
|
|
767
|
+
source.z,
|
|
768
|
+
target.x,
|
|
769
|
+
target.y,
|
|
770
|
+
target.z,
|
|
771
|
+
losFlags,
|
|
772
|
+
ignoreEntity?.Handle ?? 0,
|
|
773
|
+
shapeTestOptions
|
|
774
|
+
)
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
return new AsynchronousRaycastResult(
|
|
778
|
+
StartShapeTestLosProbe(
|
|
779
|
+
source.x,
|
|
780
|
+
source.y,
|
|
781
|
+
source.z,
|
|
782
|
+
target.x,
|
|
783
|
+
target.y,
|
|
784
|
+
target.z,
|
|
785
|
+
losFlags,
|
|
786
|
+
ignoreEntity?.Handle ?? 0,
|
|
787
|
+
shapeTestOptions
|
|
788
|
+
)
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Cast a ray from the local players camera until it hits an entity
|
|
793
|
+
*
|
|
794
|
+
* @param maxDistance Max distance to cast the ray.
|
|
795
|
+
* @param flags Possible entity types to detect.
|
|
796
|
+
* @returns SynchronousRaycast object.
|
|
797
|
+
*/
|
|
798
|
+
static raycastPlayerCamera(maxDistance, flags) {
|
|
799
|
+
const camera = GameplayCamera.Position;
|
|
800
|
+
const direction = GameplayCamera.ForwardVector;
|
|
801
|
+
const destination = direction.multiply(maxDistance).add(camera);
|
|
802
|
+
return new SynchronousRaycastResult(
|
|
803
|
+
StartExpensiveSynchronousShapeTestLosProbe(
|
|
804
|
+
camera.x,
|
|
805
|
+
camera.y,
|
|
806
|
+
camera.z,
|
|
807
|
+
destination.x,
|
|
808
|
+
destination.y,
|
|
809
|
+
destination.z,
|
|
810
|
+
flags,
|
|
811
|
+
PlayerPedId(),
|
|
812
|
+
7
|
|
813
|
+
)
|
|
814
|
+
);
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Gets the closest object of this model
|
|
818
|
+
*/
|
|
819
|
+
static getClosestObject(model, coords, radius = 25, isMission = false) {
|
|
820
|
+
const prop = GetClosestObjectOfType(coords.x, coords.y, coords.z, radius, model.Hash, isMission, false, false);
|
|
821
|
+
if (prop !== 0) {
|
|
822
|
+
return new Prop(prop);
|
|
823
|
+
}
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Get all [[`Prop`]] entities in your own scope.
|
|
828
|
+
*
|
|
829
|
+
* @returns Array of Props.
|
|
830
|
+
*/
|
|
831
|
+
static getAllProps() {
|
|
832
|
+
const handles = GetGamePool("CObject");
|
|
833
|
+
const props = [];
|
|
834
|
+
handles.forEach((handle) => props.push(new Prop(handle)));
|
|
835
|
+
return props;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Get all [[`Rope`]] entities in your own scope.
|
|
839
|
+
*
|
|
840
|
+
* @returns Array of Ropes.
|
|
841
|
+
*/
|
|
842
|
+
static getAllRopes() {
|
|
843
|
+
const handles = GetAllRopes();
|
|
844
|
+
const props = [];
|
|
845
|
+
handles.forEach((handle) => props.push(new Rope(handle)));
|
|
846
|
+
return props;
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Get all [[`Ped`]] entities in your own scope.
|
|
850
|
+
*
|
|
851
|
+
* @returns Array of Peds.
|
|
852
|
+
*/
|
|
853
|
+
static getAllPeds() {
|
|
854
|
+
const handles = GetGamePool("CPed");
|
|
855
|
+
const peds = [];
|
|
856
|
+
handles.forEach((handle) => peds.push(new Ped(handle)));
|
|
857
|
+
return peds;
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Get all [[`Vehicle`]] entities in your own scope.
|
|
861
|
+
*
|
|
862
|
+
* @returns Array of Vehicles.
|
|
863
|
+
*/
|
|
864
|
+
static getAllVehicles() {
|
|
865
|
+
const handles = GetGamePool("CVehicle");
|
|
866
|
+
const vehicles = [];
|
|
867
|
+
handles.forEach((handle) => vehicles.push(new Vehicle(handle)));
|
|
868
|
+
return vehicles;
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Gets the cloest [[`Vehicle`]] to the current coords, or null if none are found
|
|
872
|
+
* @returns the closest vehicle or null
|
|
873
|
+
*/
|
|
874
|
+
static getClosestVehicle(coords) {
|
|
875
|
+
const vehicles = this.getAllVehicles();
|
|
876
|
+
let currentVeh = null;
|
|
877
|
+
let lastDistance = 9999;
|
|
878
|
+
for (const vehicle of vehicles) {
|
|
879
|
+
if (!currentVeh) {
|
|
880
|
+
currentVeh = vehicle;
|
|
881
|
+
lastDistance = coords.distance(vehicle.Position);
|
|
882
|
+
continue;
|
|
883
|
+
}
|
|
884
|
+
const distance = coords.distance(vehicle.Position);
|
|
885
|
+
if (distance < lastDistance) {
|
|
886
|
+
currentVeh = vehicle;
|
|
887
|
+
lastDistance = distance;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
return currentVeh;
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Get all [[`Pickup`]] entities using the GetGamePool.
|
|
894
|
+
* @returns Array of Pickups.
|
|
895
|
+
*/
|
|
896
|
+
static getAllPickups() {
|
|
897
|
+
const handles = GetGamePool("CPickup");
|
|
898
|
+
const pickups = [];
|
|
899
|
+
handles.forEach((handle) => pickups.push(new Pickup(handle)));
|
|
900
|
+
return pickups;
|
|
901
|
+
}
|
|
902
|
+
static currentCloudHat = CloudHat.Clear;
|
|
903
|
+
static cloudHatDict = /* @__PURE__ */ new Map([
|
|
904
|
+
[CloudHat.Unknown, "Unknown"],
|
|
905
|
+
[CloudHat.Altostratus, "altostratus"],
|
|
906
|
+
[CloudHat.Cirrus, "Cirrus"],
|
|
907
|
+
[CloudHat.Cirrocumulus, "cirrocumulus"],
|
|
908
|
+
[CloudHat.Clear, "Clear 01"],
|
|
909
|
+
[CloudHat.Cloudy, "Cloudy 01"],
|
|
910
|
+
[CloudHat.Contrails, "Contrails"],
|
|
911
|
+
[CloudHat.Horizon, "Horizon"],
|
|
912
|
+
[CloudHat.HorizonBand1, "horizonband1"],
|
|
913
|
+
[CloudHat.HorizonBand2, "horizonband2"],
|
|
914
|
+
[CloudHat.HorizonBand3, "horizonband3"],
|
|
915
|
+
[CloudHat.Horsey, "horsey"],
|
|
916
|
+
[CloudHat.Nimbus, "Nimbus"],
|
|
917
|
+
[CloudHat.Puffs, "Puffs"],
|
|
918
|
+
[CloudHat.Rain, "RAIN"],
|
|
919
|
+
[CloudHat.Snowy, "Snowy 01"],
|
|
920
|
+
[CloudHat.Stormy, "Stormy 01"],
|
|
921
|
+
[CloudHat.Stratoscumulus, "stratoscumulus"],
|
|
922
|
+
[CloudHat.Stripey, "Stripey"],
|
|
923
|
+
[CloudHat.Shower, "shower"],
|
|
924
|
+
[CloudHat.Wispy, "Wispy"]
|
|
925
|
+
]);
|
|
926
|
+
static weatherDict = [
|
|
927
|
+
"EXTRASUNNY",
|
|
928
|
+
"CLEAR",
|
|
929
|
+
"CLOUDS",
|
|
930
|
+
"SMOG",
|
|
931
|
+
"FOGGY",
|
|
932
|
+
"OVERCAST",
|
|
933
|
+
"RAIN",
|
|
934
|
+
"THUNDER",
|
|
935
|
+
"CLEARING",
|
|
936
|
+
"NEUTRAL",
|
|
937
|
+
"SNOW",
|
|
938
|
+
"BLIZZARD",
|
|
939
|
+
"SNOWLIGHT",
|
|
940
|
+
"XMAS"
|
|
941
|
+
];
|
|
942
|
+
}
|
|
943
|
+
export {
|
|
944
|
+
World
|
|
945
|
+
};
|