@armoury/fivem-framework-client 0.0.0-stage → 1.0.7

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 +30 -5
  87. package/README.md +0 -3
@@ -0,0 +1,155 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { Inject, Injectable } from 'injection-js';
14
+ import { ClientTicksService } from './client-ticks.service';
15
+ import { Command, EventListener, calculateDistance } from '@armoury/fivem-framework-common';
16
+ // TODO: Lower chunk radius and make chunk-checker check adjacent chunks as well
17
+ let ClientActionPointsService = class ClientActionPointsService {
18
+ get actionPoints() {
19
+ return this._actionPoints;
20
+ }
21
+ get cachedPlayerPosition() {
22
+ return this._cachedPlayerPosition;
23
+ }
24
+ constructor(_ticksService) {
25
+ this._ticksService = _ticksService;
26
+ this.chunkRadius = 80;
27
+ this._actionPoints = {};
28
+ this._cachedPlayerPosition = [NaN, NaN];
29
+ this._cachedPlayerRoundedPosition = [NaN, NaN];
30
+ this._cachedIsPlayerInAnyVehicle = false;
31
+ }
32
+ /** Creates one or multiple Action Points. Action points DO NOT include markers and/or blips.
33
+ * They only contain the logic executed when a position is met.
34
+ */
35
+ create(...actionPoints) {
36
+ actionPoints.forEach((actionPoint) => {
37
+ this.createActionPoint(actionPoint);
38
+ });
39
+ }
40
+ createActionPoint(actionPoint) {
41
+ const nearestX = this.roundToNearest(actionPoint.pos[0], this.chunkRadius);
42
+ const nearestY = this.roundToNearest(actionPoint.pos[1], this.chunkRadius);
43
+ if (!this._actionPoints[nearestX]) {
44
+ this._actionPoints[nearestX] = {};
45
+ }
46
+ if (!this.actionPoints[nearestX][nearestY]) {
47
+ this._actionPoints[nearestX][nearestY] = [];
48
+ }
49
+ this._actionPoints[nearestX][nearestY].push(actionPoint);
50
+ }
51
+ remove(actionPoint) {
52
+ var _a, _b;
53
+ 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) {
54
+ this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)] =
55
+ this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)].filter((_actionPoint) => _actionPoint.id != actionPoint.id);
56
+ }
57
+ }
58
+ removeById(id) {
59
+ Object.keys(this._actionPoints).forEach((posXAsStr) => {
60
+ const posX = Number(posXAsStr);
61
+ Object.keys(this._actionPoints[posX]).forEach((posYAsStr) => {
62
+ const posY = Number(posYAsStr);
63
+ this._actionPoints[posX][posY] =
64
+ this._actionPoints[posX][posY].filter((_actionPoint) => _actionPoint.id != id);
65
+ });
66
+ });
67
+ }
68
+ removeAll() {
69
+ this._actionPoints = {};
70
+ this._ticksService.remove(`${Cfx.Client.GetCurrentResourceName()}_actionpoints`);
71
+ }
72
+ existsAtPosition(posX, posY, posZ) {
73
+ const roundedPosX = this.roundToNearest(posX, this.chunkRadius);
74
+ const roundedPosY = this.roundToNearest(posY, this.chunkRadius);
75
+ if (!this.actionPoints[roundedPosX] || !this.actionPoints[roundedPosX][roundedPosY]) {
76
+ return false;
77
+ }
78
+ if (this.actionPoints[roundedPosX][roundedPosY].find((actionPoint) => actionPoint.pos[0] == posX
79
+ && actionPoint.pos[1] == posY
80
+ && actionPoint.pos[2] == posZ)) {
81
+ return true;
82
+ }
83
+ return false;
84
+ }
85
+ onThreadTriggered(optimizationType) {
86
+ var _a, _b;
87
+ if (optimizationType === 'chunk-checker') {
88
+ this._cachedPlayerPosition = Cfx.Client.GetEntityCoords(Cfx.Client.PlayerPedId(), true);
89
+ const [nearestX, nearestY] = [this.roundToNearest(this._cachedPlayerPosition[0], this.chunkRadius), this.roundToNearest(this._cachedPlayerPosition[1], this.chunkRadius)];
90
+ if (this._cachedPlayerRoundedPosition[0] == nearestX && this._cachedPlayerRoundedPosition[1] == nearestY) {
91
+ return;
92
+ }
93
+ this._cachedPlayerRoundedPosition = [nearestX, nearestY];
94
+ this._cachedIsPlayerInAnyVehicle = Cfx.Client.IsPedInAnyVehicle(Cfx.Client.PlayerPedId(), false);
95
+ 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) {
96
+ this._ticksService.addUnique({
97
+ id: `${Cfx.Client.GetCurrentResourceName()}_actionpoints`,
98
+ function: (() => {
99
+ var _a, _b, _c, _d;
100
+ 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++) {
101
+ const _actionPoint = (_c = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _c === void 0 ? void 0 : _c[this._cachedPlayerRoundedPosition[1]][i];
102
+ if (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)) {
103
+ const actionPassed = (!_actionPoint.onceIf || _actionPoint.onceIf()) && (!_actionPoint.onfootOnly || !Cfx.Client.IsPedInAnyVehicle(Cfx.Client.PlayerPedId(), false)) && (!_actionPoint.inVehicleOnly || Cfx.Client.IsPedInAnyVehicle(Cfx.Client.PlayerPedId(), false));
104
+ if (actionPassed) {
105
+ _actionPoint.action();
106
+ }
107
+ if ((_actionPoint.once || _actionPoint.onceIf) && actionPassed) {
108
+ (_d = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _d === void 0 ? void 0 : _d[this._cachedPlayerRoundedPosition[1]].splice(i, 1);
109
+ i--;
110
+ }
111
+ }
112
+ }
113
+ })
114
+ });
115
+ }
116
+ else {
117
+ this._ticksService.remove(`${Cfx.Client.GetCurrentResourceName()}_actionpoints`);
118
+ }
119
+ }
120
+ }
121
+ debug_ActionPoints() {
122
+ var _a, _b;
123
+ let totalActionPoints = 0;
124
+ 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;
125
+ Object.keys(this.actionPoints).forEach((posXAsStr) => {
126
+ const posX = Number(posXAsStr);
127
+ Object.keys(this.actionPoints[posX]).forEach((posYAsStr) => {
128
+ const posY = Number(posYAsStr);
129
+ totalActionPoints += this.actionPoints[posX][posY].length;
130
+ });
131
+ });
132
+ console.log(`Total action points: ${totalActionPoints}. Action points in this area: ${currentAreaActionPoints}`);
133
+ }
134
+ roundToNearest(num, multiple) {
135
+ return Math.round(num / multiple) * multiple;
136
+ }
137
+ };
138
+ __decorate([
139
+ EventListener({ eventName: 'armoury:thread-triggerer' }),
140
+ __metadata("design:type", Function),
141
+ __metadata("design:paramtypes", [String]),
142
+ __metadata("design:returntype", void 0)
143
+ ], ClientActionPointsService.prototype, "onThreadTriggered", null);
144
+ __decorate([
145
+ Command({ suffix: `_${Cfx.Client.GetCurrentResourceName()}` }),
146
+ __metadata("design:type", Function),
147
+ __metadata("design:paramtypes", []),
148
+ __metadata("design:returntype", void 0)
149
+ ], ClientActionPointsService.prototype, "debug_ActionPoints", null);
150
+ ClientActionPointsService = __decorate([
151
+ Injectable(),
152
+ __param(0, Inject(ClientTicksService)),
153
+ __metadata("design:paramtypes", [ClientTicksService])
154
+ ], ClientActionPointsService);
155
+ export { ClientActionPointsService };
@@ -0,0 +1,77 @@
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
+ import { Injectable } from "injection-js";
8
+ let ClientBlipsService = class ClientBlipsService {
9
+ constructor() {
10
+ this._blips = [];
11
+ // @EventListener({ eventName: `${Cfx.Client.GetCurrentResourceName()}:refresh-virtual-world` })
12
+ // protected onRefreshPlayersInVirtualWorld(): void {
13
+ // const activePlayers: number[] = Cfx.Client.GetActivePlayers();
14
+ //
15
+ // activePlayers.forEach((activePlayer: number) => {
16
+ // const playerServerId: number = Cfx.Client.GetPlayerServerId(activePlayer);
17
+ // if (this.getPlayerInfo('virtualWorld') === this.getPlayerInfo('virtualWorld', playerServerId)) {
18
+ // Cfx.Client.NetworkConcealPlayer(activePlayer, false, false);
19
+ // } else {
20
+ // Cfx.Client.NetworkConcealPlayer(activePlayer, true, false);
21
+ // }
22
+ // });
23
+ // }
24
+ }
25
+ get blips() {
26
+ return this._blips;
27
+ }
28
+ // TODO: Why is createMultiple() not calling create()?
29
+ createMultiple(...blips) {
30
+ const _blips = blips.map((blip) => (Object.assign(Object.assign({}, blip), { instance: null })));
31
+ this._blips.push(..._blips);
32
+ this.refresh();
33
+ }
34
+ create(blip) {
35
+ var _a;
36
+ const _blip = (!blip.type || blip.type === 'coords'
37
+ ? Cfx.Client.AddBlipForCoord(blip.pos[0], blip.pos[1], blip.pos[2])
38
+ : (blip.type === 'range'
39
+ ? Cfx.Client.AddBlipForRadius(blip.pos[0], blip.pos[1], blip.pos[2], blip.scale || 1.0)
40
+ : Cfx.Client.AddBlipForEntity((_a = blip.entityId) !== null && _a !== void 0 ? _a : Cfx.Client.PlayerPedId())));
41
+ if (!blip.type || blip.type !== 'range') {
42
+ Cfx.Client.SetBlipScale(_blip, blip.scale || 1.0);
43
+ }
44
+ Cfx.Client.SetBlipSprite(_blip, blip.id);
45
+ Cfx.Client.SetBlipDisplay(_blip, 4);
46
+ Cfx.Client.SetBlipColour(_blip, blip.color);
47
+ Cfx.Client.SetBlipAlpha(_blip, blip.alpha || 255);
48
+ Cfx.Client.SetBlipAsShortRange(_blip, !blip.longRange);
49
+ Cfx.Client.BeginTextCommandSetBlipName('STRING');
50
+ Cfx.Client.AddTextComponentString(blip.title);
51
+ Cfx.Client.EndTextCommandSetBlipName(_blip);
52
+ return _blip;
53
+ }
54
+ clear(blipId) {
55
+ this._blips = this._blips.filter((_blip) => _blip.instance !== blipId);
56
+ if (Cfx.Client.DoesBlipExist(blipId)) {
57
+ Cfx.Client.RemoveBlip(blipId);
58
+ }
59
+ }
60
+ clearAll() {
61
+ this._blips.forEach((blip) => {
62
+ Cfx.Client.RemoveBlip(blip.instance);
63
+ });
64
+ this._blips = [];
65
+ }
66
+ refresh() {
67
+ this.blips.forEach((blip) => {
68
+ if (!blip.instance) {
69
+ blip.instance = this.create(blip);
70
+ }
71
+ });
72
+ }
73
+ };
74
+ ClientBlipsService = __decorate([
75
+ Injectable()
76
+ ], ClientBlipsService);
77
+ export { ClientBlipsService };
@@ -0,0 +1,38 @@
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
+ import { Injectable } from "injection-js";
8
+ let ClientCheckpointsService = class ClientCheckpointsService {
9
+ constructor() {
10
+ this._checkpoints = new Map();
11
+ }
12
+ get checkpoints() {
13
+ return this._checkpoints;
14
+ }
15
+ create(type, posX1, posY1, posZ1, posX2, posY2, posZ2, diameter, red, green, blue, alpha, reserved) {
16
+ const checkpoint = Cfx.Client.CreateCheckpoint(type, posX1, posY1, posZ1, posX2, posY2, posZ2, diameter, red, green, blue, alpha, reserved);
17
+ this._checkpoints.set(checkpoint, [posX1, posY1, posZ1, posX2, posY2, posZ2]);
18
+ return checkpoint;
19
+ }
20
+ clear(checkpoint) {
21
+ Cfx.Client.DeleteCheckpoint(checkpoint);
22
+ if (this._checkpoints.has(checkpoint)) {
23
+ this._checkpoints.delete(checkpoint);
24
+ }
25
+ }
26
+ clearByPosition(pos) {
27
+ const checkpoint = Array.from(this._checkpoints.keys()).find((_checkpoint) => Math.floor(this._checkpoints.get(_checkpoint)[0]) === Math.floor(pos[0])
28
+ && Math.floor(this._checkpoints.get(_checkpoint)[1]) === Math.floor(pos[1])
29
+ && Math.floor(this._checkpoints.get(_checkpoint)[2]) === Math.floor(pos[2]));
30
+ if (checkpoint) {
31
+ this.clear(checkpoint);
32
+ }
33
+ }
34
+ };
35
+ ClientCheckpointsService = __decorate([
36
+ Injectable()
37
+ ], ClientCheckpointsService);
38
+ export { ClientCheckpointsService };
@@ -0,0 +1,22 @@
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
+ import { Injectable } from "injection-js";
8
+ let ClientHudService = class ClientHudService {
9
+ addToFeed(feedItemLength = 8000, ...texts) {
10
+ texts.forEach((text, index) => {
11
+ setTimeout(() => {
12
+ Cfx.Client.BeginTextCommandThefeedPost('STRING');
13
+ Cfx.Client.AddTextComponentSubstringPlayerName(text);
14
+ Cfx.Client.EndTextCommandThefeedPostTicker(false, true);
15
+ }, index * feedItemLength);
16
+ });
17
+ }
18
+ };
19
+ ClientHudService = __decorate([
20
+ Injectable()
21
+ ], ClientHudService);
22
+ export { ClientHudService };
@@ -0,0 +1,59 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { Inject, Injectable } from "injection-js";
14
+ import { ClientActionPointsService } from "./client-action-points.service";
15
+ import { Delay } from '@armoury/fivem-framework-common';
16
+ let ClientMarkersService = class ClientMarkersService {
17
+ get markers() {
18
+ return this._markers;
19
+ }
20
+ constructor(_actionPoints) {
21
+ this._actionPoints = _actionPoints;
22
+ this._markers = [];
23
+ }
24
+ /** Defines permanent markers. Handles draw-per-tick automatically. */
25
+ create(...markers) {
26
+ const _markers = markers.map((marker) => (Object.assign(Object.assign({}, marker), { instance: null })));
27
+ this._markers.push(..._markers);
28
+ this._actionPoints.create(...markers.map((marker) => ({
29
+ id: `${Cfx.Client.GetCurrentResourceName()}_marker_${marker.pos[0]}_${marker.pos[1]}`,
30
+ pos: marker.pos,
31
+ range: marker.renderDistance,
32
+ action: async () => {
33
+ var _a, _b, _c, _d, _e, _f, _g;
34
+ if (marker.textureDict && !Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
35
+ Cfx.Client.RequestStreamedTextureDict(marker.textureDict, true);
36
+ while (!Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
37
+ await Delay(100);
38
+ }
39
+ }
40
+ 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);
41
+ if (marker.underlyingCircle) {
42
+ 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);
43
+ }
44
+ }
45
+ })));
46
+ }
47
+ clearAll() {
48
+ this.markers.forEach((_marker) => {
49
+ this._actionPoints.removeById(`${Cfx.Client.GetCurrentResourceName()}_marker_${_marker.pos[0]}_${_marker.pos[1]}`);
50
+ });
51
+ this._markers = [];
52
+ }
53
+ };
54
+ ClientMarkersService = __decorate([
55
+ Injectable(),
56
+ __param(0, Inject(ClientActionPointsService)),
57
+ __metadata("design:paramtypes", [ClientActionPointsService])
58
+ ], ClientMarkersService);
59
+ export { ClientMarkersService };
@@ -0,0 +1,101 @@
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
+ import { Injectable } from "injection-js";
11
+ import { Delay } from '@armoury/fivem-framework-common';
12
+ let ClientPedsService = class ClientPedsService {
13
+ get peds() {
14
+ return this._peds;
15
+ }
16
+ // TODO: Use $onInit
17
+ constructor() {
18
+ this._peds = [];
19
+ Cfx.Client.onNet('onResourceStop', (resourceName) => {
20
+ if (resourceName === Cfx.Client.GetCurrentResourceName()) {
21
+ this._peds.forEach((ped) => {
22
+ this.remove(ped);
23
+ });
24
+ this._peds = [];
25
+ }
26
+ });
27
+ }
28
+ remove(ped) {
29
+ if (Cfx.Client.DoesEntityExist(ped)) {
30
+ Cfx.Client.DeleteEntity(ped);
31
+ }
32
+ if (this._peds.indexOf(ped) > -1) {
33
+ this._peds.splice(this._peds.indexOf(ped), 1);
34
+ }
35
+ }
36
+ async createInsideVehicleAsync(vehicle, pedType, modelHash, seat, isNetwork, bScriptHostPed) {
37
+ let attempts = 0;
38
+ Cfx.Client.RequestModel(modelHash);
39
+ while (!Cfx.Client.HasModelLoaded(modelHash)) {
40
+ if (attempts > 10) {
41
+ return 0;
42
+ }
43
+ await Delay(100);
44
+ attempts++;
45
+ }
46
+ const createdPed = Cfx.Client.CreatePedInsideVehicle(vehicle, pedType, modelHash, seat, isNetwork, bScriptHostPed);
47
+ if (createdPed) {
48
+ this._peds.push(createdPed);
49
+ }
50
+ return createdPed;
51
+ }
52
+ async createAsync(pedType, modelHash, x, y, z, heading, isNetwork, bScriptHostPed) {
53
+ let attempts = 0;
54
+ Cfx.Client.RequestModel(modelHash);
55
+ while (!Cfx.Client.HasModelLoaded(modelHash)) {
56
+ if (attempts > 10) {
57
+ return 0;
58
+ }
59
+ await Delay(100);
60
+ attempts++;
61
+ }
62
+ const createdPed = Cfx.Client.CreatePed(pedType, modelHash, x, y, z, heading, isNetwork, bScriptHostPed);
63
+ if (createdPed) {
64
+ this._peds.push(createdPed);
65
+ }
66
+ return createdPed;
67
+ }
68
+ async playAnim(ped, animationDict, animationName, duration, flag = 0, blendInSpeed = 8.0, blendOutSpeed = 8.0) {
69
+ let attempts = 0;
70
+ Cfx.Client.RequestAnimDict(animationDict);
71
+ while (!Cfx.Client.HasAnimDictLoaded(animationDict)) {
72
+ if (attempts > 10) {
73
+ return;
74
+ }
75
+ await Delay(100);
76
+ attempts++;
77
+ }
78
+ if (Cfx.Client.HasAnimDictLoaded(animationDict)) {
79
+ Cfx.Client.TaskPlayAnim(ped, animationDict, animationName, blendInSpeed, blendOutSpeed, duration, flag, 0, false, false, false);
80
+ }
81
+ }
82
+ async setModelAsync(ped, modelHash) {
83
+ let attempts = 0;
84
+ Cfx.Client.RequestModel(modelHash);
85
+ while (!Cfx.Client.HasModelLoaded(modelHash)) {
86
+ if (attempts > 10) {
87
+ return false;
88
+ }
89
+ await Delay(100);
90
+ attempts++;
91
+ }
92
+ Cfx.Client.SetPlayerModel(ped, modelHash);
93
+ Cfx.Client.SetModelAsNoLongerNeeded(modelHash);
94
+ return true;
95
+ }
96
+ };
97
+ ClientPedsService = __decorate([
98
+ Injectable(),
99
+ __metadata("design:paramtypes", [])
100
+ ], ClientPedsService);
101
+ export { ClientPedsService };
@@ -0,0 +1,21 @@
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
+ import { Injectable } from "injection-js";
8
+ import { isJSON } from '@armoury/fivem-framework-common';
9
+ let ClientSessionService = class ClientSessionService {
10
+ getPlayerInfo(stat, playerId) {
11
+ let value = Cfx.Client.GetConvar(`${playerId || Cfx.Client.GetPlayerServerId(Cfx.Client.PlayerId())}_PI_${stat}`, '-1');
12
+ if (isJSON(value.toString())) {
13
+ value = JSON.parse(value.toString(), function (_k, v) { return (typeof v === "object" || isNaN(v)) ? v : Number(v); });
14
+ }
15
+ return value;
16
+ }
17
+ };
18
+ ClientSessionService = __decorate([
19
+ Injectable()
20
+ ], ClientSessionService);
21
+ export { ClientSessionService };
@@ -0,0 +1,74 @@
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
+ import { Injectable } from "injection-js";
11
+ let ClientTicksService = class ClientTicksService {
12
+ constructor() {
13
+ this.tickInstance = null;
14
+ this.tickFunctions = [];
15
+ this.routingBucket = 0;
16
+ this.assignBaseListeners();
17
+ }
18
+ /** ATTENTION! The ID of a tick function needs to be UNIQUE! */
19
+ add(...functions) {
20
+ functions.forEach((func) => {
21
+ if (this.tickFunctions.findIndex((_func) => _func.id === func.id) !== -1) {
22
+ 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.`);
23
+ }
24
+ });
25
+ this.tickFunctions.push(...functions);
26
+ this.removeTickDuplicates();
27
+ this.refreshTicks();
28
+ }
29
+ addUnique(...functions) {
30
+ functions.forEach((func) => {
31
+ this.remove(func.id);
32
+ });
33
+ this.add(...functions);
34
+ }
35
+ /** Removes tick function with the provided id. */
36
+ remove(id) {
37
+ this.tickFunctions = this.tickFunctions.filter((func) => func.id != id);
38
+ }
39
+ refreshTicks() {
40
+ if (this.tickInstance) {
41
+ Cfx.Client.clearTick(this.tickInstance);
42
+ this.tickInstance = null;
43
+ }
44
+ if (this.tickFunctions.length > 0) {
45
+ this.tickInstance = Cfx.Client.setTick(() => {
46
+ if (!this.tickFunctions.length) {
47
+ Cfx.Client.clearTick(this.tickInstance);
48
+ this.tickInstance = null;
49
+ return;
50
+ }
51
+ this.tickFunctions.forEach((tick) => {
52
+ tick.function();
53
+ });
54
+ });
55
+ }
56
+ }
57
+ removeTickDuplicates() {
58
+ this.tickFunctions = this.tickFunctions.filter((func) => this.tickFunctions.findIndex((_func) => _func.id == func.id) == this.tickFunctions.indexOf(func));
59
+ }
60
+ assignBaseListeners() {
61
+ Cfx.Client.onNet(`${Cfx.Client.GetCurrentResourceName()}:set-routing-bucket`, (routingBucket) => {
62
+ this.routingBucket = routingBucket;
63
+ });
64
+ }
65
+ setEntityRoutingBucket(routingBucket) {
66
+ Cfx.Client.TriggerServerEvent(`${Cfx.Client.GetCurrentResourceName()}:set-client-routing-bucket`, routingBucket);
67
+ this.routingBucket = routingBucket;
68
+ }
69
+ };
70
+ ClientTicksService = __decorate([
71
+ Injectable(),
72
+ __metadata("design:paramtypes", [])
73
+ ], ClientTicksService);
74
+ export { ClientTicksService };
@@ -0,0 +1,38 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { Inject, Injectable } from "injection-js";
14
+ import { ClientSessionService } from "./client-session.service";
15
+ let ClientTranslateService = class ClientTranslateService {
16
+ get language() {
17
+ if (!this._language) {
18
+ this._language = this._session.getPlayerInfo('language');
19
+ }
20
+ return this._language || 'en';
21
+ }
22
+ constructor(_translations, _session) {
23
+ this._translations = _translations;
24
+ this._session = _session;
25
+ this._language = null;
26
+ }
27
+ instant(key) {
28
+ var _a;
29
+ return ((_a = this._translations[this.language]) === null || _a === void 0 ? void 0 : _a[key]) || key;
30
+ }
31
+ };
32
+ ClientTranslateService = __decorate([
33
+ Injectable(),
34
+ __param(0, Inject('translations')),
35
+ __param(1, Inject(ClientSessionService)),
36
+ __metadata("design:paramtypes", [Object, ClientSessionService])
37
+ ], ClientTranslateService);
38
+ export { ClientTranslateService };