@nativewrappers/fivem 0.0.65 → 0.0.73

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