@armoury/fivem-roleplay-gamemode-common 1.0.72 → 1.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.
|
@@ -5,15 +5,56 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.Vehicles = void 0;
|
|
10
13
|
const injection_js_1 = require("injection-js");
|
|
11
14
|
// TODO: "Attached stashes" functionality should be available for any type of entity, not only vehicles
|
|
12
15
|
let Vehicles = class Vehicles {
|
|
16
|
+
constructor() {
|
|
17
|
+
// TODO: Move this to armoury framework
|
|
18
|
+
if (!IsDuplicityVersion()) {
|
|
19
|
+
AddStateBagChangeHandler(IDENTIFIER_VEHICLE_TRUNK_OPEN, null, (bagName, key, value, reserved, replicated) => {
|
|
20
|
+
const vehicle = GetEntityFromStateBagName(bagName);
|
|
21
|
+
if (!vehicle || !DoesEntityExist(vehicle)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (GetEntityType(vehicle) !== 2) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (value === 1) {
|
|
28
|
+
console.log('REMOVEME! Trunk is now open.');
|
|
29
|
+
SetVehicleDoorOpen(vehicle, 5, false, false);
|
|
30
|
+
}
|
|
31
|
+
else if (value === 0) {
|
|
32
|
+
console.log('REMOVEME! Trunk is now shut.');
|
|
33
|
+
SetVehicleDoorShut(vehicle, 5, false);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
static setTrunkOpen(entityId, open) {
|
|
39
|
+
if (!IsDuplicityVersion()) {
|
|
40
|
+
throw new Error('Can\'t do this inside a client script.');
|
|
41
|
+
}
|
|
42
|
+
if (!Number.isSafeInteger(entityId)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const state = Entity(entityId).state;
|
|
46
|
+
if (!state) {
|
|
47
|
+
throw new Error('Invalid entity.');
|
|
48
|
+
}
|
|
49
|
+
state.set(IDENTIFIER_VEHICLE_TRUNK_OPEN, +open, true);
|
|
50
|
+
}
|
|
13
51
|
static getOwningPersistableId(entityId) {
|
|
14
52
|
if (!Number.isSafeInteger(entityId)) {
|
|
15
53
|
return null;
|
|
16
54
|
}
|
|
55
|
+
if (!Entity(entityId).state) {
|
|
56
|
+
throw new Error('Invalid entity.');
|
|
57
|
+
}
|
|
17
58
|
const owningPersistableId = Entity(entityId).state[IDENTIFIER_PERSISTABLE_OWNINGID];
|
|
18
59
|
if (owningPersistableId == null || !Number.isSafeInteger(owningPersistableId)) {
|
|
19
60
|
return null;
|
|
@@ -24,12 +65,18 @@ let Vehicles = class Vehicles {
|
|
|
24
65
|
if (!IsDuplicityVersion()) {
|
|
25
66
|
throw new Error('Can\'t do this inside a client script.');
|
|
26
67
|
}
|
|
68
|
+
if (!Entity(entityId).state) {
|
|
69
|
+
throw new Error('Invalid entity.');
|
|
70
|
+
}
|
|
27
71
|
Entity(entityId).state.set(IDENTIFIER_PERSISTABLE_OWNINGID, owningPersistableId, true);
|
|
28
72
|
}
|
|
29
73
|
static attachStash(entityId, stashId, type) {
|
|
30
74
|
if (!IsDuplicityVersion()) {
|
|
31
75
|
throw new Error('Can\'t do this inside a client script.');
|
|
32
76
|
}
|
|
77
|
+
if (!Entity(entityId).state) {
|
|
78
|
+
throw new Error('Invalid entity.');
|
|
79
|
+
}
|
|
33
80
|
let count = Entity(entityId).state[IDENTIFIER_ATTACHED_STASHES_COUNT];
|
|
34
81
|
if (count != null && !Number.isSafeInteger(count)) {
|
|
35
82
|
throw new Error('Corrupted attached stash count data.');
|
|
@@ -45,6 +92,9 @@ let Vehicles = class Vehicles {
|
|
|
45
92
|
return true;
|
|
46
93
|
}
|
|
47
94
|
static getAttachedStashIdsByType(entityId, type) {
|
|
95
|
+
if (!Entity(entityId).state) {
|
|
96
|
+
throw new Error('Invalid entity.');
|
|
97
|
+
}
|
|
48
98
|
const count = Entity(entityId).state[IDENTIFIER_ATTACHED_STASHES_COUNT] ?? 0;
|
|
49
99
|
if (!count) {
|
|
50
100
|
return null;
|
|
@@ -62,6 +112,9 @@ let Vehicles = class Vehicles {
|
|
|
62
112
|
return stashIds;
|
|
63
113
|
}
|
|
64
114
|
static getStashData(entityId, index) {
|
|
115
|
+
if (!Entity(entityId).state) {
|
|
116
|
+
throw new Error('Invalid entity.');
|
|
117
|
+
}
|
|
65
118
|
const stashId = Entity(entityId).state[IDENTIFIER_ATTACHED_STASH_BYINDEX(index)];
|
|
66
119
|
if (stashId == null || !Number.isSafeInteger(stashId)) {
|
|
67
120
|
return null;
|
|
@@ -75,11 +128,15 @@ let Vehicles = class Vehicles {
|
|
|
75
128
|
};
|
|
76
129
|
exports.Vehicles = Vehicles;
|
|
77
130
|
exports.Vehicles = Vehicles = __decorate([
|
|
78
|
-
(0, injection_js_1.Injectable)()
|
|
131
|
+
(0, injection_js_1.Injectable)(),
|
|
132
|
+
__metadata("design:paramtypes", [])
|
|
79
133
|
], Vehicles);
|
|
80
134
|
/** Entities */
|
|
81
135
|
const PERSISTABLE_PREFIX = 'armoury:entity:owning-persistable';
|
|
82
136
|
const IDENTIFIER_PERSISTABLE_OWNINGID = PERSISTABLE_PREFIX + ':owningId';
|
|
137
|
+
/** Trunk (TODO: Move applicable to main framework)*/
|
|
138
|
+
const VEHICLE_TRUNK_PREFIX = 'armoury:vehicle:trunk';
|
|
139
|
+
const IDENTIFIER_VEHICLE_TRUNK_OPEN = VEHICLE_TRUNK_PREFIX + ':open';
|
|
83
140
|
/** Attached Stashes */
|
|
84
141
|
const ATTACHED_STASHES_PREFIX = 'armoury:entity:attached-stashes';
|
|
85
142
|
const IDENTIFIER_ATTACHED_STASHES_COUNT = ATTACHED_STASHES_PREFIX + ':count';
|
|
@@ -4,13 +4,54 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
7
10
|
import { Injectable } from 'injection-js';
|
|
8
11
|
// TODO: "Attached stashes" functionality should be available for any type of entity, not only vehicles
|
|
9
12
|
let Vehicles = class Vehicles {
|
|
13
|
+
constructor() {
|
|
14
|
+
// TODO: Move this to armoury framework
|
|
15
|
+
if (!IsDuplicityVersion()) {
|
|
16
|
+
AddStateBagChangeHandler(IDENTIFIER_VEHICLE_TRUNK_OPEN, null, (bagName, key, value, reserved, replicated) => {
|
|
17
|
+
const vehicle = GetEntityFromStateBagName(bagName);
|
|
18
|
+
if (!vehicle || !DoesEntityExist(vehicle)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (GetEntityType(vehicle) !== 2) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (value === 1) {
|
|
25
|
+
console.log('REMOVEME! Trunk is now open.');
|
|
26
|
+
SetVehicleDoorOpen(vehicle, 5, false, false);
|
|
27
|
+
}
|
|
28
|
+
else if (value === 0) {
|
|
29
|
+
console.log('REMOVEME! Trunk is now shut.');
|
|
30
|
+
SetVehicleDoorShut(vehicle, 5, false);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
static setTrunkOpen(entityId, open) {
|
|
36
|
+
if (!IsDuplicityVersion()) {
|
|
37
|
+
throw new Error('Can\'t do this inside a client script.');
|
|
38
|
+
}
|
|
39
|
+
if (!Number.isSafeInteger(entityId)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const state = Entity(entityId).state;
|
|
43
|
+
if (!state) {
|
|
44
|
+
throw new Error('Invalid entity.');
|
|
45
|
+
}
|
|
46
|
+
state.set(IDENTIFIER_VEHICLE_TRUNK_OPEN, +open, true);
|
|
47
|
+
}
|
|
10
48
|
static getOwningPersistableId(entityId) {
|
|
11
49
|
if (!Number.isSafeInteger(entityId)) {
|
|
12
50
|
return null;
|
|
13
51
|
}
|
|
52
|
+
if (!Entity(entityId).state) {
|
|
53
|
+
throw new Error('Invalid entity.');
|
|
54
|
+
}
|
|
14
55
|
const owningPersistableId = Entity(entityId).state[IDENTIFIER_PERSISTABLE_OWNINGID];
|
|
15
56
|
if (owningPersistableId == null || !Number.isSafeInteger(owningPersistableId)) {
|
|
16
57
|
return null;
|
|
@@ -21,12 +62,18 @@ let Vehicles = class Vehicles {
|
|
|
21
62
|
if (!IsDuplicityVersion()) {
|
|
22
63
|
throw new Error('Can\'t do this inside a client script.');
|
|
23
64
|
}
|
|
65
|
+
if (!Entity(entityId).state) {
|
|
66
|
+
throw new Error('Invalid entity.');
|
|
67
|
+
}
|
|
24
68
|
Entity(entityId).state.set(IDENTIFIER_PERSISTABLE_OWNINGID, owningPersistableId, true);
|
|
25
69
|
}
|
|
26
70
|
static attachStash(entityId, stashId, type) {
|
|
27
71
|
if (!IsDuplicityVersion()) {
|
|
28
72
|
throw new Error('Can\'t do this inside a client script.');
|
|
29
73
|
}
|
|
74
|
+
if (!Entity(entityId).state) {
|
|
75
|
+
throw new Error('Invalid entity.');
|
|
76
|
+
}
|
|
30
77
|
let count = Entity(entityId).state[IDENTIFIER_ATTACHED_STASHES_COUNT];
|
|
31
78
|
if (count != null && !Number.isSafeInteger(count)) {
|
|
32
79
|
throw new Error('Corrupted attached stash count data.');
|
|
@@ -42,6 +89,9 @@ let Vehicles = class Vehicles {
|
|
|
42
89
|
return true;
|
|
43
90
|
}
|
|
44
91
|
static getAttachedStashIdsByType(entityId, type) {
|
|
92
|
+
if (!Entity(entityId).state) {
|
|
93
|
+
throw new Error('Invalid entity.');
|
|
94
|
+
}
|
|
45
95
|
const count = Entity(entityId).state[IDENTIFIER_ATTACHED_STASHES_COUNT] ?? 0;
|
|
46
96
|
if (!count) {
|
|
47
97
|
return null;
|
|
@@ -59,6 +109,9 @@ let Vehicles = class Vehicles {
|
|
|
59
109
|
return stashIds;
|
|
60
110
|
}
|
|
61
111
|
static getStashData(entityId, index) {
|
|
112
|
+
if (!Entity(entityId).state) {
|
|
113
|
+
throw new Error('Invalid entity.');
|
|
114
|
+
}
|
|
62
115
|
const stashId = Entity(entityId).state[IDENTIFIER_ATTACHED_STASH_BYINDEX(index)];
|
|
63
116
|
if (stashId == null || !Number.isSafeInteger(stashId)) {
|
|
64
117
|
return null;
|
|
@@ -71,12 +124,16 @@ let Vehicles = class Vehicles {
|
|
|
71
124
|
}
|
|
72
125
|
};
|
|
73
126
|
Vehicles = __decorate([
|
|
74
|
-
Injectable()
|
|
127
|
+
Injectable(),
|
|
128
|
+
__metadata("design:paramtypes", [])
|
|
75
129
|
], Vehicles);
|
|
76
130
|
export { Vehicles };
|
|
77
131
|
/** Entities */
|
|
78
132
|
const PERSISTABLE_PREFIX = 'armoury:entity:owning-persistable';
|
|
79
133
|
const IDENTIFIER_PERSISTABLE_OWNINGID = PERSISTABLE_PREFIX + ':owningId';
|
|
134
|
+
/** Trunk (TODO: Move applicable to main framework)*/
|
|
135
|
+
const VEHICLE_TRUNK_PREFIX = 'armoury:vehicle:trunk';
|
|
136
|
+
const IDENTIFIER_VEHICLE_TRUNK_OPEN = VEHICLE_TRUNK_PREFIX + ':open';
|
|
80
137
|
/** Attached Stashes */
|
|
81
138
|
const ATTACHED_STASHES_PREFIX = 'armoury:entity:attached-stashes';
|
|
82
139
|
const IDENTIFIER_ATTACHED_STASHES_COUNT = ATTACHED_STASHES_PREFIX + ':count';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare class Vehicles {
|
|
2
|
+
constructor();
|
|
3
|
+
static setTrunkOpen(entityId: number, open: boolean): void;
|
|
2
4
|
static getOwningPersistableId(entityId: number): number | null;
|
|
3
5
|
static setOwningPersistableId(entityId: number, owningPersistableId: number): void;
|
|
4
6
|
static attachStash(entityId: number, stashId: number, type: string): boolean;
|
package/package.json
CHANGED