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