@nativewrappers/redm 0.0.78 → 0.0.80

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 (3) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +149 -0
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -8,4 +8,5 @@ export * from "./world";
8
8
  export * from "./GameConstants";
9
9
  export * from "./RelationshipGroup";
10
10
  export * from "./Attribute";
11
+ export * from "./Model";
11
12
  export * from "./common/index";
package/index.js CHANGED
@@ -2867,6 +2867,154 @@ var RelationshipGroup = class {
2867
2867
  }
2868
2868
  };
2869
2869
 
2870
+ // src/redm/Model.ts
2871
+ var Model = class {
2872
+ static {
2873
+ __name(this, "Model");
2874
+ }
2875
+ /**
2876
+ * Hash of this model.
2877
+ */
2878
+ hash;
2879
+ requestedModel = false;
2880
+ /**
2881
+ * Creates a model object based on the hash key or model string.
2882
+ *
2883
+ * @param hash A number or string of the model's hash. Example: "mp_m_freemode_01"
2884
+ */
2885
+ constructor(hash) {
2886
+ if (typeof hash === "string") {
2887
+ this.hash = GetHashKey(hash);
2888
+ } else {
2889
+ this.hash = hash;
2890
+ }
2891
+ }
2892
+ [Symbol.dispose]() {
2893
+ if (this.requestedModel) {
2894
+ this.markAsNoLongerNeeded();
2895
+ }
2896
+ }
2897
+ /**
2898
+ * Gets the hash of the model.
2899
+ *
2900
+ * @returns The hash key.
2901
+ */
2902
+ get Hash() {
2903
+ return this.hash;
2904
+ }
2905
+ /**
2906
+ * Gets if the model is valid or not.
2907
+ *
2908
+ * @returns Whether this model is valid.
2909
+ */
2910
+ get IsValid() {
2911
+ return IsModelValid(this.hash);
2912
+ }
2913
+ /**
2914
+ * Gets if the model is in cd image or not.
2915
+ *
2916
+ * @returns Whether this model is in cd image.
2917
+ */
2918
+ get IsInCdImage() {
2919
+ return IsModelInCdimage(this.hash);
2920
+ }
2921
+ /**
2922
+ * Gets if the model is loaded or not.
2923
+ *
2924
+ * @returns Whether this model is loaded.
2925
+ */
2926
+ get IsLoaded() {
2927
+ return HasModelLoaded(this.hash);
2928
+ }
2929
+ /**
2930
+ * Gets if the model collision is loaded or not.
2931
+ *
2932
+ * @returns Whether this model collision is loaded.
2933
+ */
2934
+ get IsCollisionLoaded() {
2935
+ return HasCollisionForModelLoaded(this.hash);
2936
+ }
2937
+ /**
2938
+ * Gets if the model is a boat or not.
2939
+ *
2940
+ * @returns Whether this model is a boat.
2941
+ */
2942
+ get IsBoat() {
2943
+ return IsThisModelABoat(this.hash);
2944
+ }
2945
+ /**
2946
+ * Gets if the model is a Ped or not.
2947
+ *
2948
+ * @returns Whether this model is a Ped.
2949
+ */
2950
+ get IsPed() {
2951
+ return IsModelAPed(this.hash);
2952
+ }
2953
+ /**
2954
+ * Gets if the model is a prop or not.
2955
+ *
2956
+ * @returns Whether this model is a prop.
2957
+ */
2958
+ get IsProp() {
2959
+ return this.IsValid && !this.IsPed && !this.IsVehicle && !IsWeaponValid(this.hash);
2960
+ }
2961
+ /**
2962
+ * Gets if the model is a train or not.
2963
+ *
2964
+ * @returns Whether this model is a train.
2965
+ */
2966
+ get IsTrain() {
2967
+ return IsThisModelATrain(this.hash);
2968
+ }
2969
+ /**
2970
+ * Gets if the model is a Vehicle or not.
2971
+ *
2972
+ * @returns Whether this model is a Vehicle.
2973
+ */
2974
+ get IsVehicle() {
2975
+ return IsModelAVehicle(this.hash);
2976
+ }
2977
+ /**
2978
+ * Gets the model dimensions.
2979
+ *
2980
+ * @returns This model min & max dimensions.
2981
+ */
2982
+ get Dimensions() {
2983
+ const [minArray, maxArray] = GetModelDimensions(this.hash);
2984
+ const min = Vector3.fromArray(minArray);
2985
+ const max = Vector3.fromArray(maxArray);
2986
+ return { min, max };
2987
+ }
2988
+ /**
2989
+ * Request and load the model with a specified timeout. Default timeout is 1000 (recommended).
2990
+ * This function will not automatically set the model as no longer needed when
2991
+ * done.
2992
+ *
2993
+ * @param timeoutMs Maximum allowed time for model to load.
2994
+ */
2995
+ async request(timeoutMs = 1e3) {
2996
+ if (!this.IsInCdImage && !this.IsValid && !IsWeaponValid(this.hash)) {
2997
+ return false;
2998
+ }
2999
+ if (this.IsLoaded) {
3000
+ return true;
3001
+ }
3002
+ RequestModel(this.hash, false);
3003
+ const timeout = GetGameTimer() + timeoutMs;
3004
+ while (!this.IsLoaded && GetGameTimer() < timeout) {
3005
+ await Delay(0);
3006
+ }
3007
+ this.requestedModel = true;
3008
+ return this.IsLoaded;
3009
+ }
3010
+ /**
3011
+ * Sets the model as no longer needed allowing the game engine to free memory.
3012
+ */
3013
+ markAsNoLongerNeeded() {
3014
+ SetModelAsNoLongerNeeded(this.hash);
3015
+ }
3016
+ };
3017
+
2870
3018
  // src/common/GlobalData.ts
2871
3019
  var GlobalData = class _GlobalData {
2872
3020
  static {
@@ -3577,6 +3725,7 @@ export {
3577
3725
  KnockOffVehicle,
3578
3726
  Kvp,
3579
3727
  Maths,
3728
+ Model,
3580
3729
  NetEvent,
3581
3730
  NetworkedMap,
3582
3731
  NuiEvent,
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "type": "module",
11
- "version": "0.0.78",
11
+ "version": "0.0.80",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"