@nativewrappers/redm 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/Attribute.d.ts +2 -2
- package/Controls.d.ts +1 -1
- package/Model.d.ts +1 -1
- package/README.md +45 -0
- package/RawControls.d.ts +1 -1
- package/RelationshipGroup.d.ts +1 -1
- package/Volume.d.ts +1 -1
- 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/common/utils/getStringFromUInt8Array.d.ts +8 -0
- package/common/utils/getUInt32FromUint8Array.d.ts +8 -0
- package/common/utils/index.d.ts +12 -0
- package/entities/BaseEntity.d.ts +1 -1
- package/entities/Entity.d.ts +3 -3
- package/entities/Ped.d.ts +4 -4
- package/entities/Vehicle.d.ts +1 -1
- package/index.d.ts +1 -1
- package/index.js +3348 -11
- package/interfaces/Dimensions.d.ts +1 -1
- package/package.json +6 -4
- package/utils/index.d.ts +1 -1
- package/world/createDraftVehicle.d.ts +3 -3
- package/world/createPed.d.ts +3 -3
- package/world/createProp.d.ts +3 -3
- package/world/createVehicle.d.ts +3 -3
- package/Attribute.js +0 -143
- package/Controls.js +0 -14
- package/Game.js +0 -10
- package/GameConstants.js +0 -20
- package/Model.js +0 -153
- package/RawControls.js +0 -14
- package/RelationshipGroup.js +0 -67
- package/Volume.js +0 -13
- package/entities/BaseEntity.js +0 -91
- package/entities/Entity.js +0 -59
- package/entities/Ped.js +0 -331
- package/entities/Player.js +0 -51
- package/entities/Prop.js +0 -3
- package/entities/Vehicle.js +0 -15
- package/entities/index.js +0 -4
- package/enums/Attributes.js +0 -51
- package/enums/Entity.js +0 -16
- package/enums/Keys.js +0 -806
- package/enums/Ped.js +0 -26
- package/enums/RawKeys.js +0 -246
- package/enums/Relationship.js +0 -10
- package/enums/VehicleSeat.js +0 -14
- package/enums/index.js +0 -6
- package/game/index.js +0 -1
- package/interfaces/Dimensions.js +0 -1
- package/types/Throwable.js +0 -4
- package/utils/Native.js +0 -9
- package/utils/index.js +0 -2
- package/world/createDraftVehicle.js +0 -17
- package/world/createPed.js +0 -16
- package/world/createProp.js +0 -16
- package/world/createVehicle.js +0 -16
- package/world/index.js +0 -4
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nativewrappers/redm",
|
|
3
3
|
"description": "Native wrappers and utilities for use with RedM.",
|
|
4
|
+
"contributors": [
|
|
5
|
+
"Remco Troost <d0p3t>",
|
|
6
|
+
"Dillon Skaggs <AvarianKnight>",
|
|
7
|
+
"Linden <thelindat>"
|
|
8
|
+
],
|
|
4
9
|
"license": "MIT",
|
|
5
10
|
"type": "module",
|
|
6
|
-
"version": "0.0.
|
|
11
|
+
"version": "0.0.72",
|
|
7
12
|
"repository": {
|
|
8
13
|
"type": "git",
|
|
9
14
|
"url": "https://github.com/nativewrappers/nativewrappers.git"
|
|
@@ -25,8 +30,5 @@
|
|
|
25
30
|
],
|
|
26
31
|
"exports": {
|
|
27
32
|
".": "./index.js"
|
|
28
|
-
},
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"@nativewrappers/common": "0.0.65"
|
|
31
33
|
}
|
|
32
34
|
}
|
package/utils/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./Native";
|
|
2
|
-
export { Vector2, Vector3, Vector4, Maths, Color, Quaternion, Delay, enumValues, getStringFromUInt8Array, getUInt32FromUint8Array, } from "
|
|
2
|
+
export { Vector2, Vector3, Vector4, Maths, Color, Quaternion, Delay, enumValues, getStringFromUInt8Array, getUInt32FromUint8Array, } from "../common/utils/index";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Vector3 } from "
|
|
2
|
-
import { Vehicle } from "
|
|
3
|
-
import { Model } from "
|
|
1
|
+
import type { Vector3 } from "../common/utils";
|
|
2
|
+
import { Vehicle } from "redm/entities";
|
|
3
|
+
import type { Model } from "redm/Model";
|
|
4
4
|
/**
|
|
5
5
|
* Creates a vehicle at the specified {@param spawnPos}, you don't need to request the model before this.
|
|
6
6
|
*/
|
package/world/createPed.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Vector3 } from "
|
|
2
|
-
import { Ped } from "
|
|
3
|
-
import { Model } from "
|
|
1
|
+
import type { Vector3 } from "../common/utils";
|
|
2
|
+
import { Ped } from "redm/entities";
|
|
3
|
+
import type { Model } from "redm/Model";
|
|
4
4
|
/**
|
|
5
5
|
* Creates a ped at the specified {@param spawnPos}, you don't need to request the model before this.
|
|
6
6
|
*/
|
package/world/createProp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Vector3 } from "
|
|
2
|
-
import { Prop } from "
|
|
3
|
-
import { Model } from "
|
|
1
|
+
import type { Vector3 } from "../common/utils";
|
|
2
|
+
import { Prop } from "redm/entities/Prop";
|
|
3
|
+
import type { Model } from "redm/Model";
|
|
4
4
|
/**
|
|
5
5
|
* Creates a ped at the specified {@param spawnPos}, you don't need to request the model before this.
|
|
6
6
|
*/
|
package/world/createVehicle.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Vector3 } from "
|
|
2
|
-
import { Vehicle } from "
|
|
3
|
-
import { Model } from "
|
|
1
|
+
import type { Vector3 } from "../common/utils";
|
|
2
|
+
import { Vehicle } from "redm/entities";
|
|
3
|
+
import type { Model } from "redm/Model";
|
|
4
4
|
/**
|
|
5
5
|
* Creates a vehicle at the specified {@param spawnPos}, you don't need to request the model before this.
|
|
6
6
|
*/
|
package/Attribute.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { _N } from "./utils/Native";
|
|
2
|
-
export class CoreAttribute {
|
|
3
|
-
handle;
|
|
4
|
-
attribute;
|
|
5
|
-
constructor(ped, attribute) {
|
|
6
|
-
this.handle = ped.Handle;
|
|
7
|
-
this.attribute = attribute;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* This doesn't seem to actually do anything
|
|
11
|
-
* @todo maybe remove unless theres a valid use case
|
|
12
|
-
* @param amount
|
|
13
|
-
* @param makeSound
|
|
14
|
-
*/
|
|
15
|
-
enableOverpower(amount, makeSound = false) {
|
|
16
|
-
// EnableAttributeCoreOverpower
|
|
17
|
-
_N("0x4AF5A4C7B9157D14", this.handle, this.attribute, amount, makeSound);
|
|
18
|
-
}
|
|
19
|
-
get Overpowered() {
|
|
20
|
-
return _N("0x200373A8DF081F22", this.attribute, Citizen.resultAsInteger());
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @returns the amount of overpower time left in seconds
|
|
24
|
-
*/
|
|
25
|
-
get OverpoweredTimeLeft() {
|
|
26
|
-
// GetAttributeCoreOverpowerSecondsLeft
|
|
27
|
-
return _N("0xB429F58803D285B1", this.handle, this.attribute, Citizen.resultAsInteger());
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Returns how full the core is
|
|
31
|
-
*/
|
|
32
|
-
get CoreValue() {
|
|
33
|
-
return GetAttributeCoreValue(this.handle, this.attribute);
|
|
34
|
-
}
|
|
35
|
-
set CoreValue(amount) {
|
|
36
|
-
// SetAttributeCoreValue
|
|
37
|
-
_N("0xC6258F41D86676E0", this.handle, this.attribute, amount);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export class PedAttribute {
|
|
41
|
-
handle;
|
|
42
|
-
attribute;
|
|
43
|
-
constructor(ped, attribute) {
|
|
44
|
-
this.handle = ped.Handle;
|
|
45
|
-
this.attribute = attribute;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
* @param amount the amount of points to add to the attribute
|
|
50
|
-
*/
|
|
51
|
-
addPoints(amount) {
|
|
52
|
-
AddAttributePoints(this.handle, this.attribute, amount);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Disables the overpower state on this attribute, see {@link enableOverpower} on how to enable
|
|
56
|
-
*/
|
|
57
|
-
disableOverpower() {
|
|
58
|
-
DisableAttributeOverpower(this.handle, this.attribute);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
* @param amount the amount to overpower this attribute by
|
|
63
|
-
* @param makeSound if activating the overpower should play sound
|
|
64
|
-
*/
|
|
65
|
-
enableOverpower(amount, makeSound = false) {
|
|
66
|
-
// EnableAttributeOverpower
|
|
67
|
-
_N("0xF6A7C08DF2E28B28", this.handle, this.attribute, amount, makeSound);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Gets the amount of attribute points the ped has
|
|
71
|
-
*/
|
|
72
|
-
get Points() {
|
|
73
|
-
return GetAttributePoints(this.handle, this.attribute);
|
|
74
|
-
}
|
|
75
|
-
set Points(amount) {
|
|
76
|
-
SetAttributePoints(this.handle, this.attribute, amount);
|
|
77
|
-
}
|
|
78
|
-
get Rank() {
|
|
79
|
-
return GetAttributeRank(this.handle, this.attribute);
|
|
80
|
-
}
|
|
81
|
-
set BaseRank(amount) {
|
|
82
|
-
SetAttributeBaseRank(this.handle, this.attribute, amount);
|
|
83
|
-
}
|
|
84
|
-
get BaseRank() {
|
|
85
|
-
return GetAttributeBaseRank(this.handle, this.attribute);
|
|
86
|
-
}
|
|
87
|
-
set BonusRank(amount) {
|
|
88
|
-
SetAttributeBonusRank(this.handle, this.attribute, amount);
|
|
89
|
-
}
|
|
90
|
-
get BonusRank() {
|
|
91
|
-
return GetAttributeBonusRank(this.handle, this.attribute);
|
|
92
|
-
}
|
|
93
|
-
get MaxRank() {
|
|
94
|
-
// GetMaxAttributeRank
|
|
95
|
-
return _N("0x704674A0535A471D", this.attribute, Citizen.resultAsInteger());
|
|
96
|
-
}
|
|
97
|
-
get Overpowered() {
|
|
98
|
-
// IsAttributeOverpowered
|
|
99
|
-
return _N("0x103C2F885ABEB00B", this.attribute, Citizen.resultAsInteger());
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
// There's probably a better way to do this but this will do for now as it reduces repetition
|
|
103
|
-
export class Attributes {
|
|
104
|
-
pedAttributes = [];
|
|
105
|
-
coreAttributes = [];
|
|
106
|
-
constructor(ped) {
|
|
107
|
-
for (let i = 0; i <= 21; i++) {
|
|
108
|
-
this.pedAttributes[i] = new PedAttribute(ped, i);
|
|
109
|
-
}
|
|
110
|
-
for (let i = 0; i <= 2; i++) {
|
|
111
|
-
this.coreAttributes[i] = new CoreAttribute(ped, i);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
getCore(attribute) {
|
|
115
|
-
if (attribute > 2)
|
|
116
|
-
throw new RangeError("The max enum for CoreAttribute is 2");
|
|
117
|
-
if (attribute < 0)
|
|
118
|
-
throw new RangeError("The minimum enum for CoreAttribute is 0");
|
|
119
|
-
// This should always be valid
|
|
120
|
-
return this.coreAttributes[attribute];
|
|
121
|
-
}
|
|
122
|
-
get(attribute) {
|
|
123
|
-
if (attribute > 22)
|
|
124
|
-
throw new RangeError("The max enum for PedAttribute is 22");
|
|
125
|
-
if (attribute < 0)
|
|
126
|
-
throw new RangeError("The minimum enum for PedAttribute is 0");
|
|
127
|
-
return this.pedAttributes[attribute];
|
|
128
|
-
}
|
|
129
|
-
set CoreIcon(status) {
|
|
130
|
-
if (status > 15)
|
|
131
|
-
throw new RangeError("The max enum for StatusEffect is 15");
|
|
132
|
-
if (status < 0)
|
|
133
|
-
throw new RangeError("The minimum enum for StatusEffect is 0");
|
|
134
|
-
_N("0xA4D3A1C008F250DF", status);
|
|
135
|
-
}
|
|
136
|
-
set PeriodicIcon(status) {
|
|
137
|
-
if (status > 15)
|
|
138
|
-
throw new RangeError("The max enum for StatusEffect is 15!");
|
|
139
|
-
if (status < 0)
|
|
140
|
-
throw new RangeError("The minimum enum for StatusEffect is 0");
|
|
141
|
-
_N("0xFB6E111908502871", status);
|
|
142
|
-
}
|
|
143
|
-
}
|
package/Controls.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export class Controls {
|
|
2
|
-
static IsInputJustPressed(hash) {
|
|
3
|
-
return IsControlJustPressed(0, hash);
|
|
4
|
-
}
|
|
5
|
-
static IsInputPressed(hash) {
|
|
6
|
-
return IsControlPressed(0, hash);
|
|
7
|
-
}
|
|
8
|
-
static IsDisabledInputPressed(hash) {
|
|
9
|
-
return IsDisabledControlPressed(0, hash);
|
|
10
|
-
}
|
|
11
|
-
static DisableControl(hash) {
|
|
12
|
-
DisableControlAction(0, hash, false);
|
|
13
|
-
}
|
|
14
|
-
}
|
package/Game.js
DELETED
package/GameConstants.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Player } from "./entities";
|
|
2
|
-
// Constants that will never change throughout the lifetime of the player
|
|
3
|
-
export class GameConstants {
|
|
4
|
-
// the actual player object that will get initialized on the first call to the `get Player()`
|
|
5
|
-
static player = null;
|
|
6
|
-
// The player id of the local client
|
|
7
|
-
static PlayerId = PlayerId();
|
|
8
|
-
// The server id of the local client.
|
|
9
|
-
static ServerId = GetPlayerServerId(GameConstants.PlayerId);
|
|
10
|
-
// The player class of the local object
|
|
11
|
-
static get Player() {
|
|
12
|
-
// Initialize the player on first access, this should prevent any issues where the `Player` class isn't
|
|
13
|
-
// defined yet since we call this from `Player` too.
|
|
14
|
-
// return GameConstants.player;
|
|
15
|
-
if (GameConstants.player === null) {
|
|
16
|
-
GameConstants.player = new Player(GameConstants.PlayerId);
|
|
17
|
-
}
|
|
18
|
-
return GameConstants.player;
|
|
19
|
-
}
|
|
20
|
-
}
|
package/Model.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { Vector3 } from "../common/utils/Vector3";
|
|
2
|
-
import { Delay } from "../common/utils";
|
|
3
|
-
/**
|
|
4
|
-
* Class to create and manage entity models.
|
|
5
|
-
*/
|
|
6
|
-
export class Model {
|
|
7
|
-
/**
|
|
8
|
-
* Hash of this model.
|
|
9
|
-
*/
|
|
10
|
-
hash;
|
|
11
|
-
requestedModel = false;
|
|
12
|
-
/**
|
|
13
|
-
* Creates a model object based on the hash key or model string.
|
|
14
|
-
*
|
|
15
|
-
* @param hash A number or string of the model's hash. Example: "mp_m_freemode_01"
|
|
16
|
-
*/
|
|
17
|
-
constructor(hash) {
|
|
18
|
-
if (typeof hash === "string") {
|
|
19
|
-
this.hash = GetHashKey(hash);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
this.hash = hash;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
[Symbol.dispose]() {
|
|
26
|
-
if (this.requestedModel) {
|
|
27
|
-
this.markAsNoLongerNeeded();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Gets the hash of the model.
|
|
32
|
-
*
|
|
33
|
-
* @returns The hash key.
|
|
34
|
-
*/
|
|
35
|
-
get Hash() {
|
|
36
|
-
return this.hash;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Gets if the model is valid or not.
|
|
40
|
-
*
|
|
41
|
-
* @returns Whether this model is valid.
|
|
42
|
-
*/
|
|
43
|
-
get IsValid() {
|
|
44
|
-
return IsModelValid(this.hash);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Gets if the model is in cd image or not.
|
|
48
|
-
*
|
|
49
|
-
* @returns Whether this model is in cd image.
|
|
50
|
-
*/
|
|
51
|
-
get IsInCdImage() {
|
|
52
|
-
return IsModelInCdimage(this.hash);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Gets if the model is loaded or not.
|
|
56
|
-
*
|
|
57
|
-
* @returns Whether this model is loaded.
|
|
58
|
-
*/
|
|
59
|
-
get IsLoaded() {
|
|
60
|
-
return HasModelLoaded(this.hash);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Gets if the model collision is loaded or not.
|
|
64
|
-
*
|
|
65
|
-
* @returns Whether this model collision is loaded.
|
|
66
|
-
*/
|
|
67
|
-
get IsCollisionLoaded() {
|
|
68
|
-
return HasCollisionForModelLoaded(this.hash);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Gets if the model is a boat or not.
|
|
72
|
-
*
|
|
73
|
-
* @returns Whether this model is a boat.
|
|
74
|
-
*/
|
|
75
|
-
get IsBoat() {
|
|
76
|
-
return IsThisModelABoat(this.hash);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Gets if the model is a Ped or not.
|
|
80
|
-
*
|
|
81
|
-
* @returns Whether this model is a Ped.
|
|
82
|
-
*/
|
|
83
|
-
get IsPed() {
|
|
84
|
-
return IsModelAPed(this.hash);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Gets if the model is a prop or not.
|
|
88
|
-
*
|
|
89
|
-
* @returns Whether this model is a prop.
|
|
90
|
-
*/
|
|
91
|
-
get IsProp() {
|
|
92
|
-
return (this.IsValid &&
|
|
93
|
-
!this.IsPed &&
|
|
94
|
-
!this.IsVehicle &&
|
|
95
|
-
!IsWeaponValid(this.hash));
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Gets if the model is a train or not.
|
|
99
|
-
*
|
|
100
|
-
* @returns Whether this model is a train.
|
|
101
|
-
*/
|
|
102
|
-
get IsTrain() {
|
|
103
|
-
return IsThisModelATrain(this.hash);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Gets if the model is a Vehicle or not.
|
|
107
|
-
*
|
|
108
|
-
* @returns Whether this model is a Vehicle.
|
|
109
|
-
*/
|
|
110
|
-
get IsVehicle() {
|
|
111
|
-
return IsModelAVehicle(this.hash);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Gets the model dimensions.
|
|
115
|
-
*
|
|
116
|
-
* @returns This model min & max dimensions.
|
|
117
|
-
*/
|
|
118
|
-
get Dimensions() {
|
|
119
|
-
const [minArray, maxArray] = GetModelDimensions(this.hash);
|
|
120
|
-
const min = Vector3.fromArray(minArray);
|
|
121
|
-
const max = Vector3.fromArray(maxArray);
|
|
122
|
-
return { min, max };
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Request and load the model with a specified timeout. Default timeout is 1000 (recommended).
|
|
126
|
-
* This function will not automatically set the model as no longer needed when
|
|
127
|
-
* done.
|
|
128
|
-
*
|
|
129
|
-
* @param timeoutMs Maximum allowed time for model to load.
|
|
130
|
-
*/
|
|
131
|
-
async request(timeoutMs = 1000) {
|
|
132
|
-
if (!this.IsInCdImage && !this.IsValid && !IsWeaponValid(this.hash)) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
// pre-check so if its already loaded we don't add another ref
|
|
136
|
-
if (this.IsLoaded) {
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
RequestModel(this.hash, false);
|
|
140
|
-
const timeout = GetGameTimer() + timeoutMs;
|
|
141
|
-
while (!this.IsLoaded && GetGameTimer() < timeout) {
|
|
142
|
-
await Delay(0);
|
|
143
|
-
}
|
|
144
|
-
this.requestedModel = true;
|
|
145
|
-
return this.IsLoaded;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Sets the model as no longer needed allowing the game engine to free memory.
|
|
149
|
-
*/
|
|
150
|
-
markAsNoLongerNeeded() {
|
|
151
|
-
SetModelAsNoLongerNeeded(this.hash);
|
|
152
|
-
}
|
|
153
|
-
}
|
package/RawControls.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export class RawControls {
|
|
2
|
-
static IsKeyDown(rawKey) {
|
|
3
|
-
return IsRawKeyDown(rawKey);
|
|
4
|
-
}
|
|
5
|
-
static IsKeyPressed(rawKey) {
|
|
6
|
-
return IsRawKeyPressed(rawKey);
|
|
7
|
-
}
|
|
8
|
-
static IsKeyReleased(rawKey) {
|
|
9
|
-
return IsRawKeyReleased(rawKey);
|
|
10
|
-
}
|
|
11
|
-
static IsKeyUp(rawKey) {
|
|
12
|
-
return IsRawKeyUp(rawKey);
|
|
13
|
-
}
|
|
14
|
-
}
|
package/RelationshipGroup.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Class to create and manage a relationship group. Useful to manage behavior between Peds.
|
|
3
|
-
*/
|
|
4
|
-
export class RelationshipGroup {
|
|
5
|
-
/**
|
|
6
|
-
* The hash of the relationship group
|
|
7
|
-
*/
|
|
8
|
-
hash;
|
|
9
|
-
/**
|
|
10
|
-
* Create a relationship group. Optionally pass a group hash.
|
|
11
|
-
*
|
|
12
|
-
* @param name Name of the relationship group.
|
|
13
|
-
*/
|
|
14
|
-
constructor(name) {
|
|
15
|
-
const [, groupHash] = AddRelationshipGroup(name);
|
|
16
|
-
this.hash = groupHash;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Gets the hash of the relationship group.
|
|
20
|
-
*
|
|
21
|
-
* @returns The hash of this object.
|
|
22
|
-
*/
|
|
23
|
-
get Hash() {
|
|
24
|
-
return this.hash;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Get the relationship between two relationship groups.
|
|
28
|
-
*
|
|
29
|
-
* @param targetGroup The other relationship group.
|
|
30
|
-
* @returns The relationship
|
|
31
|
-
*/
|
|
32
|
-
getRelationshipBetweenGroups(targetGroup) {
|
|
33
|
-
return GetRelationshipBetweenGroups(this.Hash, targetGroup.Hash);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Set the relationship group between this relationship group and another one.
|
|
37
|
-
*
|
|
38
|
-
* @param targetGroup The other relationship group.
|
|
39
|
-
* @param relationship The desired relationship.
|
|
40
|
-
* @param biDirectionally If target group should have same relationship towards this.
|
|
41
|
-
*/
|
|
42
|
-
setRelationshipBetweenGroups(targetGroup, relationship, biDirectionally = false) {
|
|
43
|
-
SetRelationshipBetweenGroups(Number(relationship), this.Hash, targetGroup.Hash);
|
|
44
|
-
if (biDirectionally) {
|
|
45
|
-
SetRelationshipBetweenGroups(Number(relationship), targetGroup.Hash, this.Hash);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Clear the relationship between this relationship group and another.
|
|
50
|
-
*
|
|
51
|
-
* @param targetGroup The other relationship group.
|
|
52
|
-
* @param relationship The desired relationship to clear.
|
|
53
|
-
* @param biDirectionally Whether the target group should also clear the relationship.
|
|
54
|
-
*/
|
|
55
|
-
clearRelationshipBetweenGroups(targetGroup, relationship, biDirectionally = false) {
|
|
56
|
-
ClearRelationshipBetweenGroups(Number(relationship), this.Hash, targetGroup.Hash);
|
|
57
|
-
if (biDirectionally) {
|
|
58
|
-
ClearRelationshipBetweenGroups(Number(relationship), targetGroup.Hash, this.Hash);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Remove this relationship group from the game. This will not delete this object.
|
|
63
|
-
*/
|
|
64
|
-
remove() {
|
|
65
|
-
RemoveRelationshipGroup(this.Hash);
|
|
66
|
-
}
|
|
67
|
-
}
|
package/Volume.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export class Volume {
|
|
2
|
-
handle;
|
|
3
|
-
constructor(coord, rot, scale, customName) {
|
|
4
|
-
if (customName) {
|
|
5
|
-
this.handle = CreateVolumeCylinderWithCustomName(coord.x, coord.y, coord.z, rot.x, rot.y, rot.z, scale.x, scale.y, scale.z, customName);
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
this.handle = CreateVolumeCylinder(coord.x, coord.y, coord.z, rot.x, rot.y, rot.z, scale.x, scale.y, scale.z);
|
|
9
|
-
}
|
|
10
|
-
get Handle() {
|
|
11
|
-
return this.handle;
|
|
12
|
-
}
|
|
13
|
-
}
|
package/entities/BaseEntity.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Vector3 } from "../../common/utils";
|
|
2
|
-
export class BaseEntity {
|
|
3
|
-
handle;
|
|
4
|
-
constructor(entHandle) {
|
|
5
|
-
this.handle = entHandle;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Replaces the current handle for the entity used on, this hsould be used sparringly, mainly
|
|
9
|
-
* in situations where you're going to reuse an entity over and over and don't want to make a
|
|
10
|
-
* new entity every time.
|
|
11
|
-
*
|
|
12
|
-
* **WARNING**: This does no checks, if you provide it an invalid entity it will use it
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* const REUSABLE_ENTITY = new Entity(entityHandle);
|
|
16
|
-
*
|
|
17
|
-
* onNet("entityHandler", (entNetId: number) => {
|
|
18
|
-
* // if no net entity we should ignore
|
|
19
|
-
* if (!NetworkDoesEntityExistWithNetworkId(entNetId)) return;
|
|
20
|
-
*
|
|
21
|
-
* // Reuse our entity so we don't have to initialize a new one
|
|
22
|
-
* REUSABLE_ENTITY.replaceHandle(NetworkGetEntityFromNetworkId(entNetId));
|
|
23
|
-
* // Do something with REUSABLE_ENTITY entity
|
|
24
|
-
* })
|
|
25
|
-
```
|
|
26
|
-
*/
|
|
27
|
-
replaceHandle(newHandle) {
|
|
28
|
-
this.handle = newHandle;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @returns the network for the specified entity, this doesn't check if the entity is networked, you should use {@link BaseEntity.IsNetworked}
|
|
32
|
-
*/
|
|
33
|
-
get NetworkId() {
|
|
34
|
-
return NetworkGetNetworkIdFromEntity(this.Handle);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @returns `true` if the current entity is networked, false otherwise
|
|
38
|
-
*/
|
|
39
|
-
get IsNetworked() {
|
|
40
|
-
return NetworkGetEntityIsNetworked(this.Handle);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* @returns Returns true if the entity handle is not 0 and exists in the game engine
|
|
44
|
-
*/
|
|
45
|
-
get Exists() {
|
|
46
|
-
return this.handle !== 0 && DoesEntityExist(this.Handle);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* @returns The entitys current handle.
|
|
50
|
-
*/
|
|
51
|
-
get Handle() {
|
|
52
|
-
return this.handle;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* @param amount the health to set the health to, setting to `0` will kill the entity, if using on a {@link Ped} you should check the MaxHealth before setting.
|
|
56
|
-
*/
|
|
57
|
-
set Health(amount) {
|
|
58
|
-
SetEntityHealth(this.Handle, amount, 0);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* @returns the amount of health the current {@link BaseEntity} has
|
|
62
|
-
*/
|
|
63
|
-
get Health() {
|
|
64
|
-
return GetEntityHealth(this.Handle);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* @returns the heading of the current {@link BaseEntity}
|
|
68
|
-
*/
|
|
69
|
-
get Heading() {
|
|
70
|
-
return GetEntityHeading(this.Handle);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* @param heading sets the entitys heading to the specified heading, this can be in the range of 0..360
|
|
74
|
-
*/
|
|
75
|
-
set Heading(heading) {
|
|
76
|
-
SetEntityHeading(this.Handle, heading);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* @returns the position of the current Entity
|
|
80
|
-
*/
|
|
81
|
-
get Position() {
|
|
82
|
-
return Vector3.fromArray(GetEntityCoords(this.handle, true, true));
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* You should (almost) always try to load the collisions before setting the entitys position if going a long distance.
|
|
86
|
-
* @param pos sets the position for the current ped
|
|
87
|
-
*/
|
|
88
|
-
set Position(pos) {
|
|
89
|
-
SetEntityCoords(this.handle, pos.x, pos.y, pos.z, false, false, false, false);
|
|
90
|
-
}
|
|
91
|
-
}
|
package/entities/Entity.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { EntityType, ForceType } from "../enums/Entity";
|
|
2
|
-
import { _N } from "../utils";
|
|
3
|
-
import { BaseEntity } from "./BaseEntity";
|
|
4
|
-
export class Entity extends BaseEntity {
|
|
5
|
-
// NOTE: There is nothing stopping you from using creating an invalid entity, you should do your own due-diligence
|
|
6
|
-
constructor(handle) {
|
|
7
|
-
super(handle);
|
|
8
|
-
}
|
|
9
|
-
addTrackingTrails() {
|
|
10
|
-
// _ADD_ENTITY_TRACKING_TRAILS
|
|
11
|
-
_N("0x1AD922AB5038DEF3", this.Handle);
|
|
12
|
-
}
|
|
13
|
-
get EntityType() {
|
|
14
|
-
return GetEntityType(this.Handle);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @param direction - the direction to apply the force towards
|
|
18
|
-
* @param offset - the offset to apply the force to
|
|
19
|
-
* @param forceType - the force type to apply
|
|
20
|
-
* @param boneIndex - the boneIndex to apply the force to, or 0
|
|
21
|
-
* @param isDirectional - whether the direction is relational?
|
|
22
|
-
* @param ignoreUpVec - ?
|
|
23
|
-
* @param isForceRel - whether to multiply the force by the object mass & acceleration
|
|
24
|
-
*/
|
|
25
|
-
applyForce(direction, offset, forceType = ForceType.MinForce, boneIndex = 0, isDirectional = false, ignoreUpVec = true, isForceRel = true) {
|
|
26
|
-
const d = direction;
|
|
27
|
-
const o = offset;
|
|
28
|
-
ApplyForceToEntity(this.Handle, forceType, d.x, d.y, d.z, o.x, o.y, o.z, boneIndex, isDirectional, ignoreUpVec, isForceRel, false, true);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @param direction - the direction to apply the force towards
|
|
32
|
-
* @param forceType - the force type to use
|
|
33
|
-
* @param isDirectional - whether the direction is local?
|
|
34
|
-
* @param isForceRel - whether to multiply the force by the object mass & acceleration
|
|
35
|
-
*/
|
|
36
|
-
applyForceToCenter(direction, forceType = ForceType.MinForce, isDirectional = false, isForceRel = true) {
|
|
37
|
-
const d = direction;
|
|
38
|
-
ApplyForceToEntityCenterOfMass(this.Handle, forceType, d.x, d.y, d.z, false, isDirectional, isForceRel, false);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* @param tgtEntity - the entity to attach to the {@Entity}
|
|
42
|
-
* @param pos - the position offset
|
|
43
|
-
* @param rot - the rotation to apply to the entity
|
|
44
|
-
* @param boneIndex - the bone to attach the entity to, or 0 for the center of the entity
|
|
45
|
-
* @param enableCollision - whether the entity should have collision enabled
|
|
46
|
-
* @param useSoftPinning - when false the entity will not detach from the {@Entity}
|
|
47
|
-
* @param vertexIndex - ?
|
|
48
|
-
* @param fixedRot - ?
|
|
49
|
-
* @throws Error if tgtEntity and {@Entity} are the same entity
|
|
50
|
-
*/
|
|
51
|
-
attachTo(tgtEntity, pos, rot, boneIndex = 0, enableCollision = true, useSoftPinning = false, vertexIndex = 0, fixedRot = true) {
|
|
52
|
-
if (tgtEntity.Handle === this.Handle) {
|
|
53
|
-
throw new Error("tgtEntity had the same handle as the current entity, attaching an entity to itself will crash");
|
|
54
|
-
}
|
|
55
|
-
const p = pos;
|
|
56
|
-
const r = rot;
|
|
57
|
-
AttachEntityToEntity(tgtEntity.Handle, this.Handle, boneIndex, p.x, p.y, p.z, r.x, r.y, r.z, false, useSoftPinning, enableCollision, (this.EntityType === EntityType.Ped), vertexIndex, fixedRot, false, false);
|
|
58
|
-
}
|
|
59
|
-
}
|