@armoury/fivem-framework-client 0.0.0-stage → 1.0.8
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/dist/cjs/client/client-action-points.js +179 -0
- package/dist/cjs/client/client-entities.js +287 -0
- package/dist/cjs/client/client-hud.controller.js +17 -0
- package/dist/cjs/client/client-ui.controller.js +91 -0
- package/dist/cjs/client/client.base.js +72 -0
- package/dist/cjs/client/client.controller.js +28 -0
- package/dist/cjs/client/constants/color.mappings.js +91 -0
- package/dist/cjs/client/index.js +45 -0
- package/dist/cjs/client/interfaces/client-ui.interface.js +2 -0
- package/dist/cjs/client/models/action-point.model.js +2 -0
- package/dist/cjs/client/models/blip.model.js +2 -0
- package/dist/cjs/client/models/index.js +21 -0
- package/dist/cjs/client/models/marker.model.js +2 -0
- package/dist/cjs/client/models/ui-button.model.js +2 -0
- package/dist/cjs/client/models/ui-dialog.model.js +2 -0
- package/dist/cjs/client/services/client-action-points.service.js +158 -0
- package/dist/cjs/client/services/client-blips.service.js +80 -0
- package/dist/cjs/client/services/client-checkpoints.service.js +41 -0
- package/dist/cjs/client/services/client-hud.service.js +25 -0
- package/dist/cjs/client/services/client-markers.service.js +62 -0
- package/dist/cjs/client/services/client-peds.service.js +104 -0
- package/dist/cjs/client/services/client-session.service.js +24 -0
- package/dist/cjs/client/services/client-ticks.service.js +77 -0
- package/dist/cjs/client/services/client-translate.service.js +41 -0
- package/dist/cjs/client/services/client-ui.service.js +112 -0
- package/dist/cjs/client/services/client-vehicles.service.js +66 -0
- package/dist/cjs/client/services/client-waypoints.service.js +72 -0
- package/dist/cjs/client/services/index.js +28 -0
- package/dist/esm/client/client-action-points.js +176 -0
- package/dist/esm/client/client-entities.js +284 -0
- package/dist/esm/client/client-hud.controller.js +13 -0
- package/dist/esm/client/client-ui.controller.js +84 -0
- package/dist/esm/client/client.base.js +68 -0
- package/dist/esm/client/client.controller.js +24 -0
- package/dist/esm/client/constants/color.mappings.js +88 -0
- package/dist/esm/client/index.js +27 -0
- package/dist/esm/client/interfaces/client-ui.interface.js +1 -0
- package/dist/esm/client/models/action-point.model.js +1 -0
- package/dist/esm/client/models/blip.model.js +1 -0
- package/dist/esm/client/models/index.js +5 -0
- package/dist/esm/client/models/marker.model.js +1 -0
- package/dist/esm/client/models/ui-button.model.js +1 -0
- package/dist/esm/client/models/ui-dialog.model.js +1 -0
- package/dist/esm/client/services/client-action-points.service.js +155 -0
- package/dist/esm/client/services/client-blips.service.js +77 -0
- package/dist/esm/client/services/client-checkpoints.service.js +38 -0
- package/dist/esm/client/services/client-hud.service.js +22 -0
- package/dist/esm/client/services/client-markers.service.js +59 -0
- package/dist/esm/client/services/client-peds.service.js +101 -0
- package/dist/esm/client/services/client-session.service.js +21 -0
- package/dist/esm/client/services/client-ticks.service.js +74 -0
- package/dist/esm/client/services/client-translate.service.js +38 -0
- package/dist/esm/client/services/client-ui.service.js +109 -0
- package/dist/esm/client/services/client-vehicles.service.js +63 -0
- package/dist/esm/client/services/client-waypoints.service.js +69 -0
- package/dist/esm/client/services/index.js +12 -0
- package/dist/types/ambient.declarations.d.ts +62840 -0
- package/dist/types/client/client-action-points.d.ts +30 -0
- package/dist/types/client/client-entities.d.ts +43 -0
- package/dist/types/client/client-hud.controller.d.ts +4 -0
- package/dist/types/client/client-ui.controller.d.ts +19 -0
- package/dist/types/client/client.base.d.ts +22 -0
- package/dist/types/client/client.controller.d.ts +12 -0
- package/dist/types/client/constants/color.mappings.d.ts +3 -0
- package/dist/types/client/index.d.ts +10 -0
- package/dist/types/client/interfaces/client-ui.interface.d.ts +4 -0
- package/dist/types/client/models/action-point.model.d.ts +10 -0
- package/dist/types/client/models/blip.model.d.ts +14 -0
- package/dist/types/client/models/index.d.ts +5 -0
- package/dist/types/client/models/marker.model.d.ts +22 -0
- package/dist/types/client/models/ui-button.model.d.ts +8 -0
- package/dist/types/client/models/ui-dialog.model.d.ts +9 -0
- package/dist/types/client/services/client-action-points.service.d.ts +29 -0
- package/dist/types/client/services/client-blips.service.d.ts +10 -0
- package/dist/types/client/services/client-checkpoints.service.d.ts +7 -0
- package/dist/types/client/services/client-hud.service.d.ts +3 -0
- package/dist/types/client/services/client-markers.service.d.ts +11 -0
- package/dist/types/client/services/client-peds.service.d.ts +10 -0
- package/dist/types/client/services/client-session.service.d.ts +3 -0
- package/dist/types/client/services/client-ticks.service.d.ts +21 -0
- package/dist/types/client/services/client-translate.service.d.ts +13 -0
- package/dist/types/client/services/client-ui.service.d.ts +19 -0
- package/dist/types/client/services/client-vehicles.service.d.ts +8 -0
- package/dist/types/client/services/client-waypoints.service.d.ts +13 -0
- package/dist/types/client/services/index.d.ts +12 -0
- package/package.json +32 -5
- package/README.md +0 -3
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
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
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ClientActionPoints = void 0;
|
|
13
|
+
// TODO: Remove
|
|
14
|
+
const client_entities_1 = require("./client-entities");
|
|
15
|
+
const fivem_framework_common_1 = require("@armoury/fivem-framework-common");
|
|
16
|
+
let ClientActionPoints = class ClientActionPoints extends client_entities_1.ClientEntities {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.chunkRadius = 75;
|
|
20
|
+
this._actionPoints = {};
|
|
21
|
+
this._cachedPlayerPosition = [NaN, NaN];
|
|
22
|
+
this._cachedPlayerRoundedPosition = [NaN, NaN];
|
|
23
|
+
this._cachedIsPlayerInAnyVehicle = false;
|
|
24
|
+
}
|
|
25
|
+
get actionPoints() {
|
|
26
|
+
return this._actionPoints;
|
|
27
|
+
}
|
|
28
|
+
get cachedPlayerPosition() {
|
|
29
|
+
return this._cachedPlayerPosition;
|
|
30
|
+
}
|
|
31
|
+
createMarkers(markers) {
|
|
32
|
+
super.createMarkers(markers);
|
|
33
|
+
this.createActionPoints(...markers.map((marker) => ({
|
|
34
|
+
id: `${Cfx.Client.GetCurrentResourceName()}_marker_${marker.pos[0]}_${marker.pos[1]}`,
|
|
35
|
+
pos: marker.pos,
|
|
36
|
+
range: marker.renderDistance,
|
|
37
|
+
action: async () => {
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
39
|
+
if (marker.textureDict && !Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
|
|
40
|
+
Cfx.Client.RequestStreamedTextureDict(marker.textureDict, true);
|
|
41
|
+
while (!Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
|
|
42
|
+
await (0, fivem_framework_common_1.Delay)(100);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
Cfx.Client.DrawMarker(marker.marker, marker.pos[0], marker.pos[1], marker.pos[2], 0.0, 0.0, 0.0, ((_a = marker.rotation) === null || _a === void 0 ? void 0 : _a[0]) || 0.0, ((_b = marker.rotation) === null || _b === void 0 ? void 0 : _b[1]) || 0.0, ((_c = marker.rotation) === null || _c === void 0 ? void 0 : _c[2]) || 0.0, marker.scale, marker.scale, marker.scale, marker.rgba[0], marker.rgba[1], marker.rgba[2], marker.rgba[3], false, true, 2, false, (marker.textureDict || null), (marker.textureName || null), false);
|
|
46
|
+
if (marker.underlyingCircle) {
|
|
47
|
+
Cfx.Client.DrawMarker(marker.underlyingCircle.marker, marker.pos[0], marker.pos[1], marker.pos[2] - 0.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, marker.underlyingCircle.scale, marker.underlyingCircle.scale, marker.underlyingCircle.scale, ((_d = marker.underlyingCircle.rgba) === null || _d === void 0 ? void 0 : _d[0]) || marker.rgba[0], ((_e = marker.underlyingCircle.rgba) === null || _e === void 0 ? void 0 : _e[1]) || marker.rgba[1], ((_f = marker.underlyingCircle.rgba) === null || _f === void 0 ? void 0 : _f[2]) || marker.rgba[2], ((_g = marker.underlyingCircle.rgba) === null || _g === void 0 ? void 0 : _g[3]) || marker.rgba[3], false, true, 2, false, null, null, false);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
})));
|
|
51
|
+
}
|
|
52
|
+
clearMarkers() {
|
|
53
|
+
this.markers.forEach((_marker) => {
|
|
54
|
+
this.clearActionPoint(`${Cfx.Client.GetCurrentResourceName()}_marker_${_marker.pos[0]}_${_marker.pos[1]}`);
|
|
55
|
+
});
|
|
56
|
+
super.clearMarkers();
|
|
57
|
+
}
|
|
58
|
+
/** Creates one or multiple Action Points. Action points DO NOT include markers and/or blips.
|
|
59
|
+
* They only contain the logic executed when a position is met.
|
|
60
|
+
*/
|
|
61
|
+
createActionPoints(...actionPoints) {
|
|
62
|
+
actionPoints.forEach((actionPoint) => {
|
|
63
|
+
this.createActionPoint(actionPoint);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
createActionPoint(actionPoint) {
|
|
67
|
+
const nearestX = this.roundToNearest(actionPoint.pos[0], this.chunkRadius);
|
|
68
|
+
const nearestY = this.roundToNearest(actionPoint.pos[1], this.chunkRadius);
|
|
69
|
+
if (!this._actionPoints[nearestX]) {
|
|
70
|
+
this._actionPoints[nearestX] = {};
|
|
71
|
+
}
|
|
72
|
+
if (!this.actionPoints[nearestX][nearestY]) {
|
|
73
|
+
this._actionPoints[nearestX][nearestY] = [];
|
|
74
|
+
}
|
|
75
|
+
this._actionPoints[nearestX][nearestY].push(actionPoint);
|
|
76
|
+
}
|
|
77
|
+
clearActionPoint(id) {
|
|
78
|
+
Object.keys(this._actionPoints).forEach((posXAsStr) => {
|
|
79
|
+
const posX = Number(posXAsStr);
|
|
80
|
+
Object.keys(this._actionPoints[posX]).forEach((posYAsStr) => {
|
|
81
|
+
const posY = Number(posYAsStr);
|
|
82
|
+
this._actionPoints[posX][posY] =
|
|
83
|
+
this._actionPoints[posX][posY].filter((_actionPoint) => _actionPoint.id != id);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
clearActionPoints() {
|
|
88
|
+
this._actionPoints = {};
|
|
89
|
+
this.removeFromTick(`${Cfx.Client.GetCurrentResourceName()}_actionpoints`);
|
|
90
|
+
}
|
|
91
|
+
actionPointExistsAtPosition(posX, posY, posZ) {
|
|
92
|
+
const roundedPosX = this.roundToNearest(posX, this.chunkRadius);
|
|
93
|
+
const roundedPosY = this.roundToNearest(posY, this.chunkRadius);
|
|
94
|
+
if (!this.actionPoints[roundedPosX] || !this.actionPoints[roundedPosX][roundedPosY]) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (this.actionPoints[roundedPosX][roundedPosY].find((actionPoint) => actionPoint.pos[0] == posX
|
|
98
|
+
&& actionPoint.pos[1] == posY
|
|
99
|
+
&& actionPoint.pos[2] == posZ)) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
removeActionPoint(actionPoint) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
if ((_b = (_a = this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)]) === null || _a === void 0 ? void 0 : _a[this.roundToNearest(actionPoint.pos[1], this.chunkRadius)]) === null || _b === void 0 ? void 0 : _b.length) {
|
|
107
|
+
this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)] =
|
|
108
|
+
this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)].filter((_actionPoint) => _actionPoint.id != actionPoint.id);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
onThreadTriggered(optimizationType) {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
if (optimizationType === 'chunk-checker') {
|
|
114
|
+
this._cachedPlayerPosition = Cfx.Client.GetEntityCoords(Cfx.Client.PlayerPedId(), true);
|
|
115
|
+
const [nearestX, nearestY] = [this.roundToNearest(this._cachedPlayerPosition[0], this.chunkRadius), this.roundToNearest(this._cachedPlayerPosition[1], this.chunkRadius)];
|
|
116
|
+
if (this._cachedPlayerRoundedPosition[0] == nearestX && this._cachedPlayerRoundedPosition[1] == nearestY) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this._cachedPlayerRoundedPosition = [nearestX, nearestY];
|
|
120
|
+
this._cachedIsPlayerInAnyVehicle = Cfx.Client.IsPedInAnyVehicle(Cfx.Client.PlayerPedId(), false);
|
|
121
|
+
if ((_b = (_a = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _a === void 0 ? void 0 : _a[this._cachedPlayerRoundedPosition[1]]) === null || _b === void 0 ? void 0 : _b.length) {
|
|
122
|
+
this.addToTickUnique({
|
|
123
|
+
id: `${Cfx.Client.GetCurrentResourceName()}_actionpoints`,
|
|
124
|
+
function: (() => {
|
|
125
|
+
var _a, _b, _c, _d;
|
|
126
|
+
for (let i = 0; i < ((_b = (_a = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _a === void 0 ? void 0 : _a[this._cachedPlayerRoundedPosition[1]]) === null || _b === void 0 ? void 0 : _b.length); i++) {
|
|
127
|
+
const _actionPoint = (_c = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _c === void 0 ? void 0 : _c[this._cachedPlayerRoundedPosition[1]][i];
|
|
128
|
+
if ((0, fivem_framework_common_1.calculateDistance)([_actionPoint.pos[0], _actionPoint.pos[1], _actionPoint.pos[2], this._cachedPlayerPosition[0], this._cachedPlayerPosition[1], _actionPoint.pos[2]]) <= (_actionPoint.range || 1.0) + (this._cachedIsPlayerInAnyVehicle && !_actionPoint.onfootOnly ? 5 : 0)) {
|
|
129
|
+
const actionPassed = (!_actionPoint.onceIf || _actionPoint.onceIf()) && (!_actionPoint.onfootOnly || !Cfx.Client.IsPedInAnyVehicle(Cfx.Client.PlayerPedId(), false)) && (!_actionPoint.inVehicleOnly || Cfx.Client.IsPedInAnyVehicle(Cfx.Client.PlayerPedId(), false));
|
|
130
|
+
if (actionPassed) {
|
|
131
|
+
_actionPoint.action();
|
|
132
|
+
}
|
|
133
|
+
if ((_actionPoint.once || _actionPoint.onceIf) && actionPassed) {
|
|
134
|
+
(_d = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _d === void 0 ? void 0 : _d[this._cachedPlayerRoundedPosition[1]].splice(i, 1);
|
|
135
|
+
i--;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
this.removeFromTick(`${Cfx.Client.GetCurrentResourceName()}_actionpoints`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
debug_ActionPoints() {
|
|
148
|
+
var _a, _b;
|
|
149
|
+
let totalActionPoints = 0;
|
|
150
|
+
const currentAreaActionPoints = ((_b = (_a = this.actionPoints[this.roundToNearest(this._cachedPlayerPosition[0], this.chunkRadius)]) === null || _a === void 0 ? void 0 : _a[this.roundToNearest(this._cachedPlayerPosition[1], this.chunkRadius)]) === null || _b === void 0 ? void 0 : _b.length) || 0;
|
|
151
|
+
Object.keys(this.actionPoints).forEach((posXAsStr) => {
|
|
152
|
+
const posX = Number(posXAsStr);
|
|
153
|
+
Object.keys(this.actionPoints[posX]).forEach((posYAsStr) => {
|
|
154
|
+
const posY = Number(posYAsStr);
|
|
155
|
+
totalActionPoints += this.actionPoints[posX][posY].length;
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
console.log(`Total action points: ${totalActionPoints}. Action points in this area: ${currentAreaActionPoints}`);
|
|
159
|
+
}
|
|
160
|
+
roundToNearest(num, multiple) {
|
|
161
|
+
return Math.round(num / multiple) * multiple;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
exports.ClientActionPoints = ClientActionPoints;
|
|
165
|
+
__decorate([
|
|
166
|
+
(0, fivem_framework_common_1.EventListener)({ eventName: 'armoury:thread-triggerer', direction: fivem_framework_common_1.EVENT_DIRECTIONS.CLIENT_TO_CLIENT }),
|
|
167
|
+
__metadata("design:type", Function),
|
|
168
|
+
__metadata("design:paramtypes", [String]),
|
|
169
|
+
__metadata("design:returntype", void 0)
|
|
170
|
+
], ClientActionPoints.prototype, "onThreadTriggered", null);
|
|
171
|
+
__decorate([
|
|
172
|
+
(0, fivem_framework_common_1.Command)({ suffix: `_${Cfx.Client.GetCurrentResourceName()}` }),
|
|
173
|
+
__metadata("design:type", Function),
|
|
174
|
+
__metadata("design:paramtypes", []),
|
|
175
|
+
__metadata("design:returntype", void 0)
|
|
176
|
+
], ClientActionPoints.prototype, "debug_ActionPoints", null);
|
|
177
|
+
exports.ClientActionPoints = ClientActionPoints = __decorate([
|
|
178
|
+
(0, fivem_framework_common_1.Controller)()
|
|
179
|
+
], ClientActionPoints);
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
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
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ClientEntities = void 0;
|
|
13
|
+
// TODO: Remove
|
|
14
|
+
const color_mappings_1 = require("./constants/color.mappings");
|
|
15
|
+
const client_base_1 = require("./client.base");
|
|
16
|
+
const fivem_framework_common_1 = require("@armoury/fivem-framework-common");
|
|
17
|
+
let ClientEntities = class ClientEntities extends client_base_1.ClientBase {
|
|
18
|
+
get blips() {
|
|
19
|
+
return this._blips;
|
|
20
|
+
}
|
|
21
|
+
get markers() {
|
|
22
|
+
return this._markers;
|
|
23
|
+
}
|
|
24
|
+
get vehicles() {
|
|
25
|
+
return this._vehicles;
|
|
26
|
+
}
|
|
27
|
+
get peds() {
|
|
28
|
+
return this._peds;
|
|
29
|
+
}
|
|
30
|
+
get waypoints() {
|
|
31
|
+
return this._waypoints;
|
|
32
|
+
}
|
|
33
|
+
get checkpoints() {
|
|
34
|
+
return this._checkpoints;
|
|
35
|
+
}
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
this._blips = [];
|
|
39
|
+
this._markers = [];
|
|
40
|
+
this._vehicles = [];
|
|
41
|
+
this._peds = [];
|
|
42
|
+
this._waypoints = [];
|
|
43
|
+
this._checkpoints = new Map();
|
|
44
|
+
this.assignDefaultEntityListeners();
|
|
45
|
+
}
|
|
46
|
+
createBlips(blips) {
|
|
47
|
+
const _blips = blips.map((blip) => (Object.assign(Object.assign({}, blip), { instance: null })));
|
|
48
|
+
this._blips.push(..._blips);
|
|
49
|
+
this.refreshBlips();
|
|
50
|
+
}
|
|
51
|
+
createBlip(blip) {
|
|
52
|
+
var _a;
|
|
53
|
+
const _blip = (!blip.type || blip.type === 'coords'
|
|
54
|
+
? Cfx.Client.AddBlipForCoord(blip.pos[0], blip.pos[1], blip.pos[2])
|
|
55
|
+
: (blip.type === 'range'
|
|
56
|
+
? Cfx.Client.AddBlipForRadius(blip.pos[0], blip.pos[1], blip.pos[2], blip.scale || 1.0)
|
|
57
|
+
: Cfx.Client.AddBlipForEntity((_a = blip.entityId) !== null && _a !== void 0 ? _a : Cfx.Client.PlayerPedId())));
|
|
58
|
+
if (!blip.type || blip.type !== 'range') {
|
|
59
|
+
Cfx.Client.SetBlipScale(_blip, blip.scale || 1.0);
|
|
60
|
+
}
|
|
61
|
+
Cfx.Client.SetBlipSprite(_blip, blip.id);
|
|
62
|
+
Cfx.Client.SetBlipDisplay(_blip, 4);
|
|
63
|
+
Cfx.Client.SetBlipColour(_blip, blip.color);
|
|
64
|
+
Cfx.Client.SetBlipAlpha(_blip, blip.alpha || 255);
|
|
65
|
+
Cfx.Client.SetBlipAsShortRange(_blip, !blip.longRange);
|
|
66
|
+
Cfx.Client.BeginTextCommandSetBlipName('STRING');
|
|
67
|
+
Cfx.Client.AddTextComponentString(blip.title);
|
|
68
|
+
Cfx.Client.EndTextCommandSetBlipName(_blip);
|
|
69
|
+
return _blip;
|
|
70
|
+
}
|
|
71
|
+
clearBlip(blipId) {
|
|
72
|
+
this._blips = this._blips.filter((_blip) => _blip.instance !== blipId);
|
|
73
|
+
if (Cfx.Client.DoesBlipExist(blipId)) {
|
|
74
|
+
Cfx.Client.RemoveBlip(blipId);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
clearBlips() {
|
|
78
|
+
this._blips.forEach((blip) => {
|
|
79
|
+
Cfx.Client.RemoveBlip(blip.instance);
|
|
80
|
+
});
|
|
81
|
+
this._blips = [];
|
|
82
|
+
}
|
|
83
|
+
refreshBlips() {
|
|
84
|
+
this.blips.forEach((blip) => {
|
|
85
|
+
if (!blip.instance) {
|
|
86
|
+
blip.instance = this.createBlip(blip);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** Defines a custom, irreplaceable waypoint */
|
|
91
|
+
createWaypoint(pos, title, color, id, routeColor, diameter = 3.0) {
|
|
92
|
+
const currentResource = Cfx.Client.GetCurrentResourceName().replace('-', ' ');
|
|
93
|
+
const defaultTitle = `${currentResource.slice(0, 1).toUpperCase()}${currentResource.slice(1)}`;
|
|
94
|
+
const _waypoint = this.createBlip({
|
|
95
|
+
id: id || 1,
|
|
96
|
+
color: color || 69,
|
|
97
|
+
title: title || defaultTitle,
|
|
98
|
+
pos,
|
|
99
|
+
longRange: true
|
|
100
|
+
});
|
|
101
|
+
this.createCheckpoint(2, pos[0], pos[1], pos[2], null, null, null, diameter, color_mappings_1.COLOR_MAPPINGS[color !== null && color !== void 0 ? color : 0][0], color_mappings_1.COLOR_MAPPINGS[color !== null && color !== void 0 ? color : 0][1], color_mappings_1.COLOR_MAPPINGS[color !== null && color !== void 0 ? color : 0][2], 255, 0);
|
|
102
|
+
if (routeColor !== -1) {
|
|
103
|
+
Cfx.Client.SetBlipRoute(_waypoint, true);
|
|
104
|
+
if (routeColor) {
|
|
105
|
+
Cfx.Client.SetBlipRouteColour(_waypoint, routeColor);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
this._waypoints.push(_waypoint);
|
|
109
|
+
return _waypoint;
|
|
110
|
+
}
|
|
111
|
+
clearWaypoints() {
|
|
112
|
+
this._waypoints.forEach((waypoint) => {
|
|
113
|
+
this.clearWaypoint(waypoint, true);
|
|
114
|
+
});
|
|
115
|
+
this._waypoints = [];
|
|
116
|
+
}
|
|
117
|
+
clearWaypoint(waypoint, ignoreSplice = false) {
|
|
118
|
+
this.clearCheckpointByPosition(Cfx.Client.GetBlipCoords(waypoint));
|
|
119
|
+
Cfx.Client.SetBlipRoute(waypoint, false);
|
|
120
|
+
Cfx.Client.RemoveBlip(waypoint);
|
|
121
|
+
if (!ignoreSplice) {
|
|
122
|
+
this._waypoints.splice(this._waypoints.indexOf(waypoint), 1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
createCheckpoint(type, posX1, posY1, posZ1, posX2, posY2, posZ2, diameter, red, green, blue, alpha, reserved) {
|
|
126
|
+
const checkpoint = Cfx.Client.CreateCheckpoint(type, posX1, posY1, posZ1, posX2, posY2, posZ2, diameter, red, green, blue, alpha, reserved);
|
|
127
|
+
this._checkpoints.set(checkpoint, [posX1, posY1, posZ1, posX2, posY2, posZ2]);
|
|
128
|
+
return checkpoint;
|
|
129
|
+
}
|
|
130
|
+
clearCheckpoint(checkpoint) {
|
|
131
|
+
Cfx.Client.DeleteCheckpoint(checkpoint);
|
|
132
|
+
if (this._checkpoints.has(checkpoint)) {
|
|
133
|
+
this._checkpoints.delete(checkpoint);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
clearCheckpointByPosition(pos) {
|
|
137
|
+
const checkpoint = Array.from(this._checkpoints.keys()).find((_checkpoint) => Math.floor(this._checkpoints.get(_checkpoint)[0]) === Math.floor(pos[0])
|
|
138
|
+
&& Math.floor(this._checkpoints.get(_checkpoint)[1]) === Math.floor(pos[1])
|
|
139
|
+
&& Math.floor(this._checkpoints.get(_checkpoint)[2]) === Math.floor(pos[2]));
|
|
140
|
+
if (checkpoint) {
|
|
141
|
+
this.clearCheckpoint(checkpoint);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** Defines permanent markers. Handles draw-per-tick automatically. */
|
|
145
|
+
createMarkers(markers) {
|
|
146
|
+
const _markers = markers.map((marker) => (Object.assign(Object.assign({}, marker), { instance: null })));
|
|
147
|
+
this._markers.push(..._markers);
|
|
148
|
+
}
|
|
149
|
+
clearMarkers() {
|
|
150
|
+
this._markers = [];
|
|
151
|
+
}
|
|
152
|
+
/** Wrapper of FiveM's native CreateVehicle - includes requesting the model */
|
|
153
|
+
async createVehicleAsync(modelHash, x, y, z, heading, isNetwork, netMissionEntity, putPlayerInVehicle = false) {
|
|
154
|
+
let attempts = 0;
|
|
155
|
+
Cfx.Client.RequestModel(modelHash);
|
|
156
|
+
while (!Cfx.Client.HasModelLoaded(modelHash)) {
|
|
157
|
+
if (attempts > 10) {
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
|
160
|
+
await (0, fivem_framework_common_1.Delay)(100);
|
|
161
|
+
attempts++;
|
|
162
|
+
}
|
|
163
|
+
const createdVehicle = Cfx.Client.CreateVehicle(modelHash, x, y, z, heading, isNetwork, netMissionEntity);
|
|
164
|
+
if (createdVehicle) {
|
|
165
|
+
if (netMissionEntity) {
|
|
166
|
+
this._vehicles.push(createdVehicle);
|
|
167
|
+
}
|
|
168
|
+
if (putPlayerInVehicle) {
|
|
169
|
+
Cfx.Client.TaskWarpPedIntoVehicle(Cfx.Client.GetPlayerPed(-1), createdVehicle, -1);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return createdVehicle;
|
|
173
|
+
}
|
|
174
|
+
removeVehicle(vehicle) {
|
|
175
|
+
if (Cfx.Client.DoesEntityExist(vehicle)) {
|
|
176
|
+
Cfx.Client.DeleteEntity(vehicle);
|
|
177
|
+
}
|
|
178
|
+
if (this._vehicles.indexOf(vehicle) > -1) {
|
|
179
|
+
this._vehicles.splice(this._vehicles.indexOf(vehicle), 1);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
removePed(ped) {
|
|
183
|
+
if (Cfx.Client.DoesEntityExist(ped)) {
|
|
184
|
+
Cfx.Client.DeleteEntity(ped);
|
|
185
|
+
}
|
|
186
|
+
if (this._peds.indexOf(ped) > -1) {
|
|
187
|
+
this._peds.splice(this._peds.indexOf(ped), 1);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
async createPedInsideVehicleAsync(vehicle, pedType, modelHash, seat, isNetwork, bScriptHostPed) {
|
|
191
|
+
let attempts = 0;
|
|
192
|
+
Cfx.Client.RequestModel(modelHash);
|
|
193
|
+
while (!Cfx.Client.HasModelLoaded(modelHash)) {
|
|
194
|
+
if (attempts > 10) {
|
|
195
|
+
return 0;
|
|
196
|
+
}
|
|
197
|
+
await (0, fivem_framework_common_1.Delay)(100);
|
|
198
|
+
attempts++;
|
|
199
|
+
}
|
|
200
|
+
const createdPed = Cfx.Client.CreatePedInsideVehicle(vehicle, pedType, modelHash, seat, isNetwork, bScriptHostPed);
|
|
201
|
+
if (createdPed) {
|
|
202
|
+
this._peds.push(createdPed);
|
|
203
|
+
}
|
|
204
|
+
return createdPed;
|
|
205
|
+
}
|
|
206
|
+
async createPedAsync(pedType, modelHash, x, y, z, heading, isNetwork, bScriptHostPed) {
|
|
207
|
+
let attempts = 0;
|
|
208
|
+
Cfx.Client.RequestModel(modelHash);
|
|
209
|
+
while (!Cfx.Client.HasModelLoaded(modelHash)) {
|
|
210
|
+
if (attempts > 10) {
|
|
211
|
+
return 0;
|
|
212
|
+
}
|
|
213
|
+
await (0, fivem_framework_common_1.Delay)(100);
|
|
214
|
+
attempts++;
|
|
215
|
+
}
|
|
216
|
+
const createdPed = Cfx.Client.CreatePed(pedType, modelHash, x, y, z, heading, isNetwork, bScriptHostPed);
|
|
217
|
+
if (createdPed) {
|
|
218
|
+
this._peds.push(createdPed);
|
|
219
|
+
}
|
|
220
|
+
return createdPed;
|
|
221
|
+
}
|
|
222
|
+
async playAnimForPed(ped, animationDict, animationName, duration, flag = 0, blendInSpeed = 8.0, blendOutSpeed = 8.0) {
|
|
223
|
+
let attempts = 0;
|
|
224
|
+
Cfx.Client.RequestAnimDict(animationDict);
|
|
225
|
+
while (!Cfx.Client.HasAnimDictLoaded(animationDict)) {
|
|
226
|
+
if (attempts > 10) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
await (0, fivem_framework_common_1.Delay)(100);
|
|
230
|
+
attempts++;
|
|
231
|
+
}
|
|
232
|
+
if (Cfx.Client.HasAnimDictLoaded(animationDict)) {
|
|
233
|
+
Cfx.Client.TaskPlayAnim(ped, animationDict, animationName, blendInSpeed, blendOutSpeed, duration, flag, 0, false, false, false);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
async setPedModelAsync(ped, modelHash) {
|
|
237
|
+
let attempts = 0;
|
|
238
|
+
Cfx.Client.RequestModel(modelHash);
|
|
239
|
+
while (!Cfx.Client.HasModelLoaded(modelHash)) {
|
|
240
|
+
if (attempts > 10) {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
await (0, fivem_framework_common_1.Delay)(100);
|
|
244
|
+
attempts++;
|
|
245
|
+
}
|
|
246
|
+
Cfx.Client.SetPlayerModel(ped, modelHash);
|
|
247
|
+
Cfx.Client.SetModelAsNoLongerNeeded(modelHash);
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
assignDefaultEntityListeners() {
|
|
251
|
+
Cfx.Client.onNet('onResourceStop', (resourceName) => {
|
|
252
|
+
if (resourceName === Cfx.Client.GetCurrentResourceName()) {
|
|
253
|
+
this._vehicles.forEach((vehicle) => {
|
|
254
|
+
this.removeVehicle(vehicle);
|
|
255
|
+
});
|
|
256
|
+
this._peds.forEach((ped) => {
|
|
257
|
+
this.removePed(ped);
|
|
258
|
+
});
|
|
259
|
+
this._vehicles = [];
|
|
260
|
+
this._peds = [];
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
onRefreshPlayersInVirtualWorld() {
|
|
265
|
+
const activePlayers = Cfx.Client.GetActivePlayers();
|
|
266
|
+
activePlayers.forEach((activePlayer) => {
|
|
267
|
+
const playerServerId = Cfx.Client.GetPlayerServerId(activePlayer);
|
|
268
|
+
if (this.getPlayerInfo('virtualWorld') === this.getPlayerInfo('virtualWorld', playerServerId)) {
|
|
269
|
+
Cfx.Client.NetworkConcealPlayer(activePlayer, false, false);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
Cfx.Client.NetworkConcealPlayer(activePlayer, true, false);
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
exports.ClientEntities = ClientEntities;
|
|
278
|
+
__decorate([
|
|
279
|
+
(0, fivem_framework_common_1.EventListener)({ eventName: `${Cfx.Client.GetCurrentResourceName()}:refresh-virtual-world` }),
|
|
280
|
+
__metadata("design:type", Function),
|
|
281
|
+
__metadata("design:paramtypes", []),
|
|
282
|
+
__metadata("design:returntype", void 0)
|
|
283
|
+
], ClientEntities.prototype, "onRefreshPlayersInVirtualWorld", null);
|
|
284
|
+
exports.ClientEntities = ClientEntities = __decorate([
|
|
285
|
+
(0, fivem_framework_common_1.Controller)(),
|
|
286
|
+
__metadata("design:paramtypes", [])
|
|
287
|
+
], ClientEntities);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientHudController = void 0;
|
|
4
|
+
// TODO: Remove
|
|
5
|
+
const client_action_points_1 = require("./client-action-points");
|
|
6
|
+
class ClientHudController extends client_action_points_1.ClientActionPoints {
|
|
7
|
+
addToFeed(feedItemLength = 8000, ...texts) {
|
|
8
|
+
texts.forEach((text, index) => {
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
Cfx.Client.BeginTextCommandThefeedPost('STRING');
|
|
11
|
+
Cfx.Client.AddTextComponentSubstringPlayerName(text);
|
|
12
|
+
Cfx.Client.EndTextCommandThefeedPostTicker(false, true);
|
|
13
|
+
}, index * feedItemLength);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ClientHudController = ClientHudController;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ClientWithUIController = void 0;
|
|
7
|
+
// TODO: Remove
|
|
8
|
+
const events_1 = __importDefault(require("events"));
|
|
9
|
+
const client_controller_1 = require("./client.controller");
|
|
10
|
+
class ClientWithUIController extends client_controller_1.ClientController {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.uiDisplay = false;
|
|
14
|
+
this.uiDisplayCooldownTimestamp = 0;
|
|
15
|
+
this.onIncomingUIMessageEvent = new events_1.default();
|
|
16
|
+
this.addDefaultListeners();
|
|
17
|
+
}
|
|
18
|
+
isUIShowing() {
|
|
19
|
+
return this.uiDisplay;
|
|
20
|
+
}
|
|
21
|
+
isUIOnCooldown() {
|
|
22
|
+
return Date.now() < this.uiDisplayCooldownTimestamp;
|
|
23
|
+
}
|
|
24
|
+
showUI(ignoreCursorMode = false, ignoreFocus = false) {
|
|
25
|
+
if (!this.isUIShowing()) {
|
|
26
|
+
if (!ignoreCursorMode) {
|
|
27
|
+
Cfx.Client.EnterCursorMode();
|
|
28
|
+
}
|
|
29
|
+
if (!ignoreFocus) {
|
|
30
|
+
Cfx.Client.SetNuiFocus(true, true);
|
|
31
|
+
Cfx.Client.SetNuiFocusKeepInput(false);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
this.uiDisplay = true;
|
|
35
|
+
this.addToTickUnique({
|
|
36
|
+
id: `${Cfx.Client.GetCurrentResourceName()}_UI`,
|
|
37
|
+
function: () => {
|
|
38
|
+
Cfx.Client.DisableControlAction(0, 1, this.uiDisplay);
|
|
39
|
+
Cfx.Client.DisableControlAction(0, 2, this.uiDisplay);
|
|
40
|
+
Cfx.Client.DisableControlAction(0, 142, this.uiDisplay);
|
|
41
|
+
Cfx.Client.DisableControlAction(0, 18, this.uiDisplay);
|
|
42
|
+
Cfx.Client.DisableControlAction(0, 322, this.uiDisplay);
|
|
43
|
+
Cfx.Client.DisableControlAction(0, 106, this.uiDisplay);
|
|
44
|
+
if (!this.uiDisplay) {
|
|
45
|
+
this.removeFromTick(`${Cfx.Client.GetCurrentResourceName()}_UI`);
|
|
46
|
+
Cfx.Client.SetNuiFocus(false, false);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
hideUI() {
|
|
52
|
+
this.uiDisplayCooldownTimestamp = Date.now() + (1000 * 3);
|
|
53
|
+
Cfx.Client.LeaveCursorMode();
|
|
54
|
+
this.uiDisplay = false;
|
|
55
|
+
Cfx.Client.SendNuiMessage(JSON.stringify({
|
|
56
|
+
type: 'dismiss'
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
addUIListener(name) {
|
|
60
|
+
Cfx.Client.RegisterNuiCallbackType(name);
|
|
61
|
+
Cfx.Client.on(`__cfx_nui:${name}`, (data, callback) => {
|
|
62
|
+
this.onIncomingUIMessageEvent.emit(name, data);
|
|
63
|
+
callback('ok');
|
|
64
|
+
});
|
|
65
|
+
this.onIncomingUIMessageEvent.on(name, (eventData) => { this.onIncomingUIMessage.call(this, name, eventData); });
|
|
66
|
+
}
|
|
67
|
+
/** Remember that you NEED to use addUIListener in order to be able to listen for events */
|
|
68
|
+
onIncomingUIMessage(eventName, eventData) { }
|
|
69
|
+
onForceShowUI(data, ignoreCursorMode = false, ignoreFocus = false) {
|
|
70
|
+
this.showUI(ignoreCursorMode, ignoreFocus);
|
|
71
|
+
}
|
|
72
|
+
onForceHideUI() {
|
|
73
|
+
this.hideUI();
|
|
74
|
+
}
|
|
75
|
+
addDefaultListeners() {
|
|
76
|
+
Cfx.Client.RegisterNuiCallbackType('dismiss');
|
|
77
|
+
Cfx.Client.on(`__cfx_nui:dismiss`, (data, callback) => {
|
|
78
|
+
this.onForceHideUI();
|
|
79
|
+
Cfx.Client.TriggerServerEvent(`${Cfx.Client.GetCurrentResourceName()}:on-force-hidden`);
|
|
80
|
+
Cfx.Client.emit(`${Cfx.Client.GetCurrentResourceName()}:on-force-hidden`);
|
|
81
|
+
callback('ok');
|
|
82
|
+
});
|
|
83
|
+
Cfx.Client.onNet(`${Cfx.Client.GetCurrentResourceName()}:force-showui`, (data) => {
|
|
84
|
+
this.onForceShowUI(data);
|
|
85
|
+
});
|
|
86
|
+
Cfx.Client.onNet(`${Cfx.Client.GetCurrentResourceName()}:force-hideui`, () => {
|
|
87
|
+
this.onForceHideUI();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.ClientWithUIController = ClientWithUIController;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientBase = void 0;
|
|
4
|
+
// TODO: Remove
|
|
5
|
+
const fivem_framework_common_1 = require("@armoury/fivem-framework-common");
|
|
6
|
+
class ClientBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.tickInstance = null;
|
|
9
|
+
this.tickFunctions = [];
|
|
10
|
+
this.routingBucket = 0;
|
|
11
|
+
this.assignBaseListeners();
|
|
12
|
+
}
|
|
13
|
+
/** ATTENTION! The ID of a tick function needs to be UNIQUE! */
|
|
14
|
+
addToTick(...functions) {
|
|
15
|
+
functions.forEach((func) => {
|
|
16
|
+
if (this.tickFunctions.findIndex((_func) => _func.id === func.id) !== -1) {
|
|
17
|
+
console.error(`[ClientBase]: A tick function with the id ${func.id} already exists in the stack! The newly added tick function will not be executed.`);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
this.tickFunctions.push(...functions);
|
|
21
|
+
this.removeTickDuplicates();
|
|
22
|
+
this.refreshTicks();
|
|
23
|
+
}
|
|
24
|
+
addToTickUnique(...functions) {
|
|
25
|
+
functions.forEach((func) => {
|
|
26
|
+
this.removeFromTick(func.id);
|
|
27
|
+
});
|
|
28
|
+
this.addToTick(...functions);
|
|
29
|
+
}
|
|
30
|
+
/** Removes tick function with the provided id. */
|
|
31
|
+
removeFromTick(id) {
|
|
32
|
+
this.tickFunctions = this.tickFunctions.filter((func) => func.id != id);
|
|
33
|
+
}
|
|
34
|
+
refreshTicks() {
|
|
35
|
+
if (this.tickInstance) {
|
|
36
|
+
Cfx.Client.clearTick(this.tickInstance);
|
|
37
|
+
this.tickInstance = null;
|
|
38
|
+
}
|
|
39
|
+
if (this.tickFunctions.length > 0) {
|
|
40
|
+
this.tickInstance = Cfx.Client.setTick(() => {
|
|
41
|
+
if (!this.tickFunctions.length) {
|
|
42
|
+
Cfx.Client.clearTick(this.tickInstance);
|
|
43
|
+
this.tickInstance = null;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.tickFunctions.forEach((tick) => {
|
|
47
|
+
tick.function();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
removeTickDuplicates() {
|
|
53
|
+
this.tickFunctions = this.tickFunctions.filter((func) => this.tickFunctions.findIndex((_func) => _func.id == func.id) == this.tickFunctions.indexOf(func));
|
|
54
|
+
}
|
|
55
|
+
assignBaseListeners() {
|
|
56
|
+
Cfx.Client.onNet(`${Cfx.Client.GetCurrentResourceName()}:set-routing-bucket`, (routingBucket) => {
|
|
57
|
+
this.routingBucket = routingBucket;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
setEntityRoutingBucket(routingBucket) {
|
|
61
|
+
Cfx.Client.TriggerServerEvent(`${Cfx.Client.GetCurrentResourceName()}:set-client-routing-bucket`, routingBucket);
|
|
62
|
+
this.routingBucket = routingBucket;
|
|
63
|
+
}
|
|
64
|
+
getPlayerInfo(stat, playerId) {
|
|
65
|
+
let value = Cfx.Client.GetConvar(`${playerId || Cfx.Client.GetPlayerServerId(Cfx.Client.PlayerId())}_PI_${stat}`, '-1');
|
|
66
|
+
if ((0, fivem_framework_common_1.isJSON)(value.toString())) {
|
|
67
|
+
value = JSON.parse(value.toString(), function (_k, v) { return (typeof v === "object" || isNaN(v)) ? v : Number(v); });
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.ClientBase = ClientBase;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientController = void 0;
|
|
4
|
+
// TODO: Remove
|
|
5
|
+
const client_hud_controller_1 = require("./client-hud.controller");
|
|
6
|
+
class ClientController extends client_hud_controller_1.ClientHudController {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this._translationLanguage = 'en';
|
|
10
|
+
}
|
|
11
|
+
get translationLanguage() {
|
|
12
|
+
return this._translationLanguage;
|
|
13
|
+
}
|
|
14
|
+
translate(key, params) {
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
let content = this.translationFile[this._translationLanguage][key];
|
|
17
|
+
if (params) {
|
|
18
|
+
Object.keys(params).forEach((param) => {
|
|
19
|
+
content = content.replace(`{${param}}`, params[param]);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return content;
|
|
23
|
+
}
|
|
24
|
+
setTranslationLanguage(language) {
|
|
25
|
+
this._translationLanguage = language;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.ClientController = ClientController;
|