@armoury/fivem-framework-client 1.0.53 → 1.0.55

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 (27) hide show
  1. package/dist/cjs/client/client-action-points.js +8 -13
  2. package/dist/cjs/client/client-entities.js +4 -5
  3. package/dist/cjs/client/index.js +3 -1
  4. package/dist/cjs/client/services/client-action-points.service.js +6 -10
  5. package/dist/cjs/client/services/client-blips.service.js +2 -3
  6. package/dist/cjs/client/services/client-markers.service.js +3 -4
  7. package/dist/cjs/client/services/client-translate.service.js +1 -2
  8. package/dist/cjs/client/services/client-waypoints.service.js +1 -1
  9. package/dist/cjs/client/services/i18n/i18n.changer.js +32 -0
  10. package/dist/cjs/client/services/i18n/i18n.service.js +4 -20
  11. package/dist/cjs/client/services/i18n/index.js +1 -0
  12. package/dist/esm/client/client-action-points.js +8 -13
  13. package/dist/esm/client/client-entities.js +4 -5
  14. package/dist/esm/client/index.js +3 -1
  15. package/dist/esm/client/services/client-action-points.service.js +6 -10
  16. package/dist/esm/client/services/client-blips.service.js +2 -3
  17. package/dist/esm/client/services/client-markers.service.js +3 -4
  18. package/dist/esm/client/services/client-translate.service.js +1 -2
  19. package/dist/esm/client/services/client-waypoints.service.js +1 -1
  20. package/dist/esm/client/services/i18n/i18n.changer.js +29 -0
  21. package/dist/esm/client/services/i18n/i18n.service.js +5 -21
  22. package/dist/esm/client/services/i18n/index.js +1 -0
  23. package/dist/types/client/index.d.ts +2 -1
  24. package/dist/types/client/services/i18n/i18n.changer.d.ts +3 -0
  25. package/dist/types/client/services/i18n/i18n.service.d.ts +0 -1
  26. package/dist/types/client/services/i18n/index.d.ts +1 -0
  27. package/package.json +2 -2
@@ -35,16 +35,15 @@ let ClientActionPoints = class ClientActionPoints extends client_entities_1.Clie
35
35
  pos: marker.pos,
36
36
  range: marker.renderDistance,
37
37
  action: async () => {
38
- var _a, _b, _c, _d, _e, _f, _g;
39
38
  if (marker.textureDict && !Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
40
39
  Cfx.Client.RequestStreamedTextureDict(marker.textureDict, true);
41
40
  while (!Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
42
41
  await (0, fivem_framework_common_1.Delay)(100);
43
42
  }
44
43
  }
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);
44
+ Cfx.Client.DrawMarker(marker.marker, marker.pos[0], marker.pos[1], marker.pos[2], 0.0, 0.0, 0.0, marker.rotation?.[0] || 0.0, marker.rotation?.[1] || 0.0, marker.rotation?.[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
45
  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);
46
+ 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, marker.underlyingCircle.rgba?.[0] || marker.rgba[0], marker.underlyingCircle.rgba?.[1] || marker.rgba[1], marker.underlyingCircle.rgba?.[2] || marker.rgba[2], marker.underlyingCircle.rgba?.[3] || marker.rgba[3], false, true, 2, false, null, null, false);
48
47
  }
49
48
  }
50
49
  })));
@@ -102,14 +101,12 @@ let ClientActionPoints = class ClientActionPoints extends client_entities_1.Clie
102
101
  return false;
103
102
  }
104
103
  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) {
104
+ if (this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)]?.[this.roundToNearest(actionPoint.pos[1], this.chunkRadius)]?.length) {
107
105
  this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)] =
108
106
  this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)].filter((_actionPoint) => _actionPoint.id != actionPoint.id);
109
107
  }
110
108
  }
111
109
  onThreadTriggered(optimizationType) {
112
- var _a, _b;
113
110
  if (optimizationType === 'chunk-checker') {
114
111
  this._cachedPlayerPosition = Cfx.Client.GetEntityCoords(Cfx.Client.PlayerPedId(), true);
115
112
  const [nearestX, nearestY] = [this.roundToNearest(this._cachedPlayerPosition[0], this.chunkRadius), this.roundToNearest(this._cachedPlayerPosition[1], this.chunkRadius)];
@@ -118,20 +115,19 @@ let ClientActionPoints = class ClientActionPoints extends client_entities_1.Clie
118
115
  }
119
116
  this._cachedPlayerRoundedPosition = [nearestX, nearestY];
120
117
  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) {
118
+ if (this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]]?.length) {
122
119
  this.addToTickUnique({
123
120
  id: `${Cfx.Client.GetCurrentResourceName()}_actionpoints`,
124
121
  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];
122
+ for (let i = 0; i < this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]]?.length; i++) {
123
+ const _actionPoint = this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]][i];
128
124
  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
125
  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
126
  if (actionPassed) {
131
127
  _actionPoint.action();
132
128
  }
133
129
  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);
130
+ this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]].splice(i, 1);
135
131
  i--;
136
132
  }
137
133
  }
@@ -145,9 +141,8 @@ let ClientActionPoints = class ClientActionPoints extends client_entities_1.Clie
145
141
  }
146
142
  }
147
143
  debug_ActionPoints() {
148
- var _a, _b;
149
144
  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;
145
+ const currentAreaActionPoints = this.actionPoints[this.roundToNearest(this._cachedPlayerPosition[0], this.chunkRadius)]?.[this.roundToNearest(this._cachedPlayerPosition[1], this.chunkRadius)]?.length || 0;
151
146
  Object.keys(this.actionPoints).forEach((posXAsStr) => {
152
147
  const posX = Number(posXAsStr);
153
148
  Object.keys(this.actionPoints[posX]).forEach((posYAsStr) => {
@@ -44,17 +44,16 @@ let ClientEntities = class ClientEntities extends client_base_1.ClientBase {
44
44
  this.assignDefaultEntityListeners();
45
45
  }
46
46
  createBlips(blips) {
47
- const _blips = blips.map((blip) => (Object.assign(Object.assign({}, blip), { instance: null })));
47
+ const _blips = blips.map((blip) => ({ ...blip, instance: null }));
48
48
  this._blips.push(..._blips);
49
49
  this.refreshBlips();
50
50
  }
51
51
  createBlip(blip) {
52
- var _a;
53
52
  const _blip = (!blip.type || blip.type === 'coords'
54
53
  ? Cfx.Client.AddBlipForCoord(blip.pos[0], blip.pos[1], blip.pos[2])
55
54
  : (blip.type === 'range'
56
55
  ? 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())));
56
+ : Cfx.Client.AddBlipForEntity(blip.entityId ?? Cfx.Client.PlayerPedId())));
58
57
  if (!blip.type || blip.type !== 'range') {
59
58
  Cfx.Client.SetBlipScale(_blip, blip.scale || 1.0);
60
59
  }
@@ -98,7 +97,7 @@ let ClientEntities = class ClientEntities extends client_base_1.ClientBase {
98
97
  pos,
99
98
  longRange: true
100
99
  });
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);
100
+ this.createCheckpoint(2, pos[0], pos[1], pos[2], null, null, null, diameter, color_mappings_1.COLOR_MAPPINGS[color ?? 0][0], color_mappings_1.COLOR_MAPPINGS[color ?? 0][1], color_mappings_1.COLOR_MAPPINGS[color ?? 0][2], 255, 0);
102
101
  if (routeColor !== -1) {
103
102
  Cfx.Client.SetBlipRoute(_waypoint, true);
104
103
  if (routeColor) {
@@ -143,7 +142,7 @@ let ClientEntities = class ClientEntities extends client_base_1.ClientBase {
143
142
  }
144
143
  /** Defines permanent markers. Handles draw-per-tick automatically. */
145
144
  createMarkers(markers) {
146
- const _markers = markers.map((marker) => (Object.assign(Object.assign({}, marker), { instance: null })));
145
+ const _markers = markers.map((marker) => ({ ...marker, instance: null }));
147
146
  this._markers.push(..._markers);
148
147
  }
149
148
  clearMarkers() {
@@ -20,6 +20,7 @@ exports.bootstrap = bootstrap;
20
20
  require("reflect-metadata");
21
21
  const services_1 = require("./services");
22
22
  const fivem_framework_common_1 = require("@armoury/fivem-framework-common");
23
+ const i18n_changer_1 = require("./services/i18n/i18n.changer");
23
24
  exports.CLIENT_PROVIDERS = [
24
25
  services_1.ClientActionPointsService,
25
26
  services_1.ClientBlipsService,
@@ -34,7 +35,8 @@ exports.CLIENT_PROVIDERS = [
34
35
  services_1.ClientWaypointsService,
35
36
  ];
36
37
  exports.CLIENT_EAGER_PROVIDERS = [
37
- services_1.UI
38
+ services_1.UI,
39
+ i18n_changer_1.I18nChanger
38
40
  ];
39
41
  async function bootstrap(_class, options = {}) {
40
42
  return (0, fivem_framework_common_1.bootstrapWithProviders)(_class, exports.CLIENT_PROVIDERS, options, fivem_framework_common_1.DecorationType.CLIENT, (key, index) => Cfx.Client.GetResourceMetadata(Cfx.Client.GetCurrentResourceName(), key, index), (resourceName) => Cfx.exports[resourceName], exports.CLIENT_EAGER_PROVIDERS);
@@ -52,8 +52,7 @@ let ClientActionPointsService = class ClientActionPointsService {
52
52
  this._actionPoints[nearestX][nearestY].push(actionPoint);
53
53
  }
54
54
  remove(actionPoint) {
55
- var _a, _b;
56
- 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) {
55
+ if (this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)]?.[this.roundToNearest(actionPoint.pos[1], this.chunkRadius)]?.length) {
57
56
  this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)] =
58
57
  this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)].filter((_actionPoint) => _actionPoint.id != actionPoint.id);
59
58
  }
@@ -86,7 +85,6 @@ let ClientActionPointsService = class ClientActionPointsService {
86
85
  return false;
87
86
  }
88
87
  onThreadTriggered(optimizationType) {
89
- var _a, _b;
90
88
  if (optimizationType === 'chunk-checker') {
91
89
  this._cachedPlayerPosition = Cfx.Client.GetEntityCoords(Cfx.Client.PlayerPedId(), true);
92
90
  const [nearestX, nearestY] = [this.roundToNearest(this._cachedPlayerPosition[0], this.chunkRadius), this.roundToNearest(this._cachedPlayerPosition[1], this.chunkRadius)];
@@ -95,20 +93,19 @@ let ClientActionPointsService = class ClientActionPointsService {
95
93
  }
96
94
  this._cachedPlayerRoundedPosition = [nearestX, nearestY];
97
95
  this._cachedIsPlayerInAnyVehicle = Cfx.Client.IsPedInAnyVehicle(Cfx.Client.PlayerPedId(), false);
98
- 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
+ if (this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]]?.length) {
99
97
  this._ticksService.addUnique({
100
98
  id: `${Cfx.Client.GetCurrentResourceName()}_actionpoints`,
101
99
  function: (() => {
102
- var _a, _b, _c, _d;
103
- 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++) {
104
- const _actionPoint = (_c = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _c === void 0 ? void 0 : _c[this._cachedPlayerRoundedPosition[1]][i];
100
+ for (let i = 0; i < this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]]?.length; i++) {
101
+ const _actionPoint = this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]][i];
105
102
  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)) {
106
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));
107
104
  if (actionPassed) {
108
105
  _actionPoint.action();
109
106
  }
110
107
  if ((_actionPoint.once || _actionPoint.onceIf) && actionPassed) {
111
- (_d = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _d === void 0 ? void 0 : _d[this._cachedPlayerRoundedPosition[1]].splice(i, 1);
108
+ this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]].splice(i, 1);
112
109
  i--;
113
110
  }
114
111
  }
@@ -122,9 +119,8 @@ let ClientActionPointsService = class ClientActionPointsService {
122
119
  }
123
120
  }
124
121
  debug_ActionPoints() {
125
- var _a, _b;
126
122
  let totalActionPoints = 0;
127
- 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;
123
+ const currentAreaActionPoints = this.actionPoints[this.roundToNearest(this._cachedPlayerPosition[0], this.chunkRadius)]?.[this.roundToNearest(this._cachedPlayerPosition[1], this.chunkRadius)]?.length || 0;
128
124
  Object.keys(this.actionPoints).forEach((posXAsStr) => {
129
125
  const posX = Number(posXAsStr);
130
126
  Object.keys(this.actionPoints[posX]).forEach((posYAsStr) => {
@@ -30,17 +30,16 @@ let ClientBlipsService = class ClientBlipsService {
30
30
  }
31
31
  // TODO: Why is createMultiple() not calling create()?
32
32
  createMultiple(...blips) {
33
- const _blips = blips.map((blip) => (Object.assign(Object.assign({}, blip), { instance: null })));
33
+ const _blips = blips.map((blip) => ({ ...blip, instance: null }));
34
34
  this._blips.push(..._blips);
35
35
  this.refresh();
36
36
  }
37
37
  create(blip) {
38
- var _a;
39
38
  const _blip = (!blip.type || blip.type === 'coords'
40
39
  ? Cfx.Client.AddBlipForCoord(blip.pos[0], blip.pos[1], blip.pos[2])
41
40
  : (blip.type === 'range'
42
41
  ? Cfx.Client.AddBlipForRadius(blip.pos[0], blip.pos[1], blip.pos[2], blip.scale || 1.0)
43
- : Cfx.Client.AddBlipForEntity((_a = blip.entityId) !== null && _a !== void 0 ? _a : Cfx.Client.PlayerPedId())));
42
+ : Cfx.Client.AddBlipForEntity(blip.entityId ?? Cfx.Client.PlayerPedId())));
44
43
  if (!blip.type || blip.type !== 'range') {
45
44
  Cfx.Client.SetBlipScale(_blip, blip.scale || 1.0);
46
45
  }
@@ -26,23 +26,22 @@ let ClientMarkersService = class ClientMarkersService {
26
26
  }
27
27
  /** Defines permanent markers. Handles draw-per-tick automatically. */
28
28
  create(...markers) {
29
- const _markers = markers.map((marker) => (Object.assign(Object.assign({}, marker), { instance: null })));
29
+ const _markers = markers.map((marker) => ({ ...marker, instance: null }));
30
30
  this._markers.push(..._markers);
31
31
  this._actionPoints.create(...markers.map((marker) => ({
32
32
  id: `${Cfx.Client.GetCurrentResourceName()}_marker_${marker.pos[0]}_${marker.pos[1]}`,
33
33
  pos: marker.pos,
34
34
  range: marker.renderDistance,
35
35
  action: async () => {
36
- var _a, _b, _c, _d, _e, _f, _g;
37
36
  if (marker.textureDict && !Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
38
37
  Cfx.Client.RequestStreamedTextureDict(marker.textureDict, true);
39
38
  while (!Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
40
39
  await (0, fivem_framework_common_1.Delay)(100);
41
40
  }
42
41
  }
43
- 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);
42
+ Cfx.Client.DrawMarker(marker.marker, marker.pos[0], marker.pos[1], marker.pos[2], 0.0, 0.0, 0.0, marker.rotation?.[0] || 0.0, marker.rotation?.[1] || 0.0, marker.rotation?.[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);
44
43
  if (marker.underlyingCircle) {
45
- 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);
44
+ 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, marker.underlyingCircle.rgba?.[0] || marker.rgba[0], marker.underlyingCircle.rgba?.[1] || marker.rgba[1], marker.underlyingCircle.rgba?.[2] || marker.rgba[2], marker.underlyingCircle.rgba?.[3] || marker.rgba[3], false, true, 2, false, null, null, false);
46
45
  }
47
46
  }
48
47
  })));
@@ -28,8 +28,7 @@ let ClientTranslateService = class ClientTranslateService {
28
28
  this._language = null;
29
29
  }
30
30
  instant(key) {
31
- var _a;
32
- return ((_a = this._translations[this.language]) === null || _a === void 0 ? void 0 : _a[key]) || key;
31
+ return this._translations[this.language]?.[key] || key;
33
32
  }
34
33
  };
35
34
  exports.ClientTranslateService = ClientTranslateService;
@@ -37,7 +37,7 @@ let ClientWaypointsService = class ClientWaypointsService {
37
37
  pos,
38
38
  longRange: true
39
39
  });
40
- this._checkpointsService.create(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);
40
+ this._checkpointsService.create(2, pos[0], pos[1], pos[2], null, null, null, diameter, color_mappings_1.COLOR_MAPPINGS[color ?? 0][0], color_mappings_1.COLOR_MAPPINGS[color ?? 0][1], color_mappings_1.COLOR_MAPPINGS[color ?? 0][2], 255, 0);
41
41
  if (routeColor !== -1) {
42
42
  Cfx.Client.SetBlipRoute(_waypoint, true);
43
43
  if (routeColor) {
@@ -0,0 +1,32 @@
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.I18nChanger = void 0;
13
+ const fivem_framework_common_1 = require("@armoury/fivem-framework-common");
14
+ const injection_js_1 = require("injection-js");
15
+ const i18n_service_1 = require("./i18n.service");
16
+ let I18nChanger = class I18nChanger {
17
+ _onLanguageChangedRequestedUnsafe(language) {
18
+ console.log(`Setting language to ${language}.`);
19
+ Cfx.Client.SetResourceKvp('armoury:language', language);
20
+ i18n_service_1.I18n.setLanguage(language);
21
+ }
22
+ };
23
+ exports.I18nChanger = I18nChanger;
24
+ __decorate([
25
+ (0, fivem_framework_common_1.EventListener)({ eventName: 'armoury:unsafe:language:change:request', direction: fivem_framework_common_1.EVENT_DIRECTIONS.CLIENT_TO_CLIENT }),
26
+ __metadata("design:type", Function),
27
+ __metadata("design:paramtypes", [String]),
28
+ __metadata("design:returntype", void 0)
29
+ ], I18nChanger.prototype, "_onLanguageChangedRequestedUnsafe", null);
30
+ exports.I18nChanger = I18nChanger = __decorate([
31
+ (0, injection_js_1.Injectable)()
32
+ ], I18nChanger);
@@ -5,23 +5,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
10
  };
14
- var I18n_1;
15
11
  Object.defineProperty(exports, "__esModule", { value: true });
16
12
  exports.I18n = void 0;
17
13
  const fivem_framework_common_1 = require("@armoury/fivem-framework-common");
18
14
  const node_polyglot_1 = __importDefault(require("node-polyglot"));
19
15
  const injection_js_1 = require("injection-js");
20
- let I18n = I18n_1 = class I18n {
16
+ let I18n = class I18n {
21
17
  static withOptions(options = {}) {
22
- var _a;
23
- const language = (_a = (Cfx.Client.GetResourceKvpString('armoury:language')
24
- || options.defaultLanguage)) !== null && _a !== void 0 ? _a : 'en-US';
18
+ const language = (Cfx.Client.GetResourceKvpString('armoury:language')
19
+ || options.defaultLanguage) ?? 'en-US';
25
20
  return {
26
21
  provide: fivem_framework_common_1.APP_INITIALIZER,
27
22
  useValue: () => this.loadLanguage(language),
@@ -61,20 +56,9 @@ let I18n = I18n_1 = class I18n {
61
56
  static translate(key, params = {}) {
62
57
  return this.polyglot.t(key, params);
63
58
  }
64
- _onLanguageChangedRequestedUnsafe(language) {
65
- console.log(`Setting language to ${language}.`);
66
- Cfx.Client.SetResourceKvp('armoury:language', language);
67
- I18n_1.setLanguage(language);
68
- }
69
59
  };
70
60
  exports.I18n = I18n;
71
61
  I18n.polyglot = new node_polyglot_1.default();
72
- __decorate([
73
- (0, fivem_framework_common_1.EventListener)({ eventName: 'armoury:unsafe:language:change:request', direction: fivem_framework_common_1.EVENT_DIRECTIONS.CLIENT_TO_CLIENT }),
74
- __metadata("design:type", Function),
75
- __metadata("design:paramtypes", [String]),
76
- __metadata("design:returntype", void 0)
77
- ], I18n.prototype, "_onLanguageChangedRequestedUnsafe", null);
78
- exports.I18n = I18n = I18n_1 = __decorate([
62
+ exports.I18n = I18n = __decorate([
79
63
  (0, injection_js_1.Injectable)()
80
64
  ], I18n);
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./i18n.changer"), exports);
17
18
  __exportStar(require("./i18n.service"), exports);
@@ -32,16 +32,15 @@ let ClientActionPoints = class ClientActionPoints extends ClientEntities {
32
32
  pos: marker.pos,
33
33
  range: marker.renderDistance,
34
34
  action: async () => {
35
- var _a, _b, _c, _d, _e, _f, _g;
36
35
  if (marker.textureDict && !Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
37
36
  Cfx.Client.RequestStreamedTextureDict(marker.textureDict, true);
38
37
  while (!Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
39
38
  await Delay(100);
40
39
  }
41
40
  }
42
- 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
+ Cfx.Client.DrawMarker(marker.marker, marker.pos[0], marker.pos[1], marker.pos[2], 0.0, 0.0, 0.0, marker.rotation?.[0] || 0.0, marker.rotation?.[1] || 0.0, marker.rotation?.[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);
43
42
  if (marker.underlyingCircle) {
44
- 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
+ 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, marker.underlyingCircle.rgba?.[0] || marker.rgba[0], marker.underlyingCircle.rgba?.[1] || marker.rgba[1], marker.underlyingCircle.rgba?.[2] || marker.rgba[2], marker.underlyingCircle.rgba?.[3] || marker.rgba[3], false, true, 2, false, null, null, false);
45
44
  }
46
45
  }
47
46
  })));
@@ -99,14 +98,12 @@ let ClientActionPoints = class ClientActionPoints extends ClientEntities {
99
98
  return false;
100
99
  }
101
100
  removeActionPoint(actionPoint) {
102
- var _a, _b;
103
- 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) {
101
+ if (this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)]?.[this.roundToNearest(actionPoint.pos[1], this.chunkRadius)]?.length) {
104
102
  this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)] =
105
103
  this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)].filter((_actionPoint) => _actionPoint.id != actionPoint.id);
106
104
  }
107
105
  }
108
106
  onThreadTriggered(optimizationType) {
109
- var _a, _b;
110
107
  if (optimizationType === 'chunk-checker') {
111
108
  this._cachedPlayerPosition = Cfx.Client.GetEntityCoords(Cfx.Client.PlayerPedId(), true);
112
109
  const [nearestX, nearestY] = [this.roundToNearest(this._cachedPlayerPosition[0], this.chunkRadius), this.roundToNearest(this._cachedPlayerPosition[1], this.chunkRadius)];
@@ -115,20 +112,19 @@ let ClientActionPoints = class ClientActionPoints extends ClientEntities {
115
112
  }
116
113
  this._cachedPlayerRoundedPosition = [nearestX, nearestY];
117
114
  this._cachedIsPlayerInAnyVehicle = Cfx.Client.IsPedInAnyVehicle(Cfx.Client.PlayerPedId(), false);
118
- 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) {
115
+ if (this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]]?.length) {
119
116
  this.addToTickUnique({
120
117
  id: `${Cfx.Client.GetCurrentResourceName()}_actionpoints`,
121
118
  function: (() => {
122
- var _a, _b, _c, _d;
123
- 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++) {
124
- const _actionPoint = (_c = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _c === void 0 ? void 0 : _c[this._cachedPlayerRoundedPosition[1]][i];
119
+ for (let i = 0; i < this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]]?.length; i++) {
120
+ const _actionPoint = this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]][i];
125
121
  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)) {
126
122
  const actionPassed = (!_actionPoint.onceIf || _actionPoint.onceIf()) && (!_actionPoint.onfootOnly || !Cfx.Client.IsPedInAnyVehicle(Cfx.Client.PlayerPedId(), false)) && (!_actionPoint.inVehicleOnly || Cfx.Client.IsPedInAnyVehicle(Cfx.Client.PlayerPedId(), false));
127
123
  if (actionPassed) {
128
124
  _actionPoint.action();
129
125
  }
130
126
  if ((_actionPoint.once || _actionPoint.onceIf) && actionPassed) {
131
- (_d = this._actionPoints[this._cachedPlayerRoundedPosition[0]]) === null || _d === void 0 ? void 0 : _d[this._cachedPlayerRoundedPosition[1]].splice(i, 1);
127
+ this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]].splice(i, 1);
132
128
  i--;
133
129
  }
134
130
  }
@@ -142,9 +138,8 @@ let ClientActionPoints = class ClientActionPoints extends ClientEntities {
142
138
  }
143
139
  }
144
140
  debug_ActionPoints() {
145
- var _a, _b;
146
141
  let totalActionPoints = 0;
147
- 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;
142
+ const currentAreaActionPoints = this.actionPoints[this.roundToNearest(this._cachedPlayerPosition[0], this.chunkRadius)]?.[this.roundToNearest(this._cachedPlayerPosition[1], this.chunkRadius)]?.length || 0;
148
143
  Object.keys(this.actionPoints).forEach((posXAsStr) => {
149
144
  const posX = Number(posXAsStr);
150
145
  Object.keys(this.actionPoints[posX]).forEach((posYAsStr) => {
@@ -41,17 +41,16 @@ let ClientEntities = class ClientEntities extends ClientBase {
41
41
  this.assignDefaultEntityListeners();
42
42
  }
43
43
  createBlips(blips) {
44
- const _blips = blips.map((blip) => (Object.assign(Object.assign({}, blip), { instance: null })));
44
+ const _blips = blips.map((blip) => ({ ...blip, instance: null }));
45
45
  this._blips.push(..._blips);
46
46
  this.refreshBlips();
47
47
  }
48
48
  createBlip(blip) {
49
- var _a;
50
49
  const _blip = (!blip.type || blip.type === 'coords'
51
50
  ? Cfx.Client.AddBlipForCoord(blip.pos[0], blip.pos[1], blip.pos[2])
52
51
  : (blip.type === 'range'
53
52
  ? 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())));
53
+ : Cfx.Client.AddBlipForEntity(blip.entityId ?? Cfx.Client.PlayerPedId())));
55
54
  if (!blip.type || blip.type !== 'range') {
56
55
  Cfx.Client.SetBlipScale(_blip, blip.scale || 1.0);
57
56
  }
@@ -95,7 +94,7 @@ let ClientEntities = class ClientEntities extends ClientBase {
95
94
  pos,
96
95
  longRange: true
97
96
  });
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);
97
+ this.createCheckpoint(2, pos[0], pos[1], pos[2], null, null, null, diameter, COLOR_MAPPINGS[color ?? 0][0], COLOR_MAPPINGS[color ?? 0][1], COLOR_MAPPINGS[color ?? 0][2], 255, 0);
99
98
  if (routeColor !== -1) {
100
99
  Cfx.Client.SetBlipRoute(_waypoint, true);
101
100
  if (routeColor) {
@@ -140,7 +139,7 @@ let ClientEntities = class ClientEntities extends ClientBase {
140
139
  }
141
140
  /** Defines permanent markers. Handles draw-per-tick automatically. */
142
141
  createMarkers(markers) {
143
- const _markers = markers.map((marker) => (Object.assign(Object.assign({}, marker), { instance: null })));
142
+ const _markers = markers.map((marker) => ({ ...marker, instance: null }));
144
143
  this._markers.push(..._markers);
145
144
  }
146
145
  clearMarkers() {
@@ -2,6 +2,7 @@
2
2
  import 'reflect-metadata';
3
3
  import { ClientActionPointsService, ClientBlipsService, ClientCheckpointsService, ClientMarkersService, ClientPedsService, ClientSessionService, ClientTicksService, ClientUIService, ClientVehiclesService, ClientWaypointsService, ClientHudService, UI } from './services';
4
4
  import { bootstrapWithProviders, DecorationType } from '@armoury/fivem-framework-common';
5
+ import { I18nChanger } from './services/i18n/i18n.changer';
5
6
  export const CLIENT_PROVIDERS = [
6
7
  ClientActionPointsService,
7
8
  ClientBlipsService,
@@ -16,7 +17,8 @@ export const CLIENT_PROVIDERS = [
16
17
  ClientWaypointsService,
17
18
  ];
18
19
  export const CLIENT_EAGER_PROVIDERS = [
19
- UI
20
+ UI,
21
+ I18nChanger
20
22
  ];
21
23
  export async function bootstrap(_class, options = {}) {
22
24
  return bootstrapWithProviders(_class, CLIENT_PROVIDERS, options, DecorationType.CLIENT, (key, index) => Cfx.Client.GetResourceMetadata(Cfx.Client.GetCurrentResourceName(), key, index), (resourceName) => Cfx.exports[resourceName], CLIENT_EAGER_PROVIDERS);
@@ -49,8 +49,7 @@ let ClientActionPointsService = class ClientActionPointsService {
49
49
  this._actionPoints[nearestX][nearestY].push(actionPoint);
50
50
  }
51
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) {
52
+ if (this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)]?.[this.roundToNearest(actionPoint.pos[1], this.chunkRadius)]?.length) {
54
53
  this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)] =
55
54
  this._actionPoints[this.roundToNearest(actionPoint.pos[0], this.chunkRadius)][this.roundToNearest(actionPoint.pos[1], this.chunkRadius)].filter((_actionPoint) => _actionPoint.id != actionPoint.id);
56
55
  }
@@ -83,7 +82,6 @@ let ClientActionPointsService = class ClientActionPointsService {
83
82
  return false;
84
83
  }
85
84
  onThreadTriggered(optimizationType) {
86
- var _a, _b;
87
85
  if (optimizationType === 'chunk-checker') {
88
86
  this._cachedPlayerPosition = Cfx.Client.GetEntityCoords(Cfx.Client.PlayerPedId(), true);
89
87
  const [nearestX, nearestY] = [this.roundToNearest(this._cachedPlayerPosition[0], this.chunkRadius), this.roundToNearest(this._cachedPlayerPosition[1], this.chunkRadius)];
@@ -92,20 +90,19 @@ let ClientActionPointsService = class ClientActionPointsService {
92
90
  }
93
91
  this._cachedPlayerRoundedPosition = [nearestX, nearestY];
94
92
  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) {
93
+ if (this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]]?.length) {
96
94
  this._ticksService.addUnique({
97
95
  id: `${Cfx.Client.GetCurrentResourceName()}_actionpoints`,
98
96
  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];
97
+ for (let i = 0; i < this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]]?.length; i++) {
98
+ const _actionPoint = this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]][i];
102
99
  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
100
  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
101
  if (actionPassed) {
105
102
  _actionPoint.action();
106
103
  }
107
104
  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);
105
+ this._actionPoints[this._cachedPlayerRoundedPosition[0]]?.[this._cachedPlayerRoundedPosition[1]].splice(i, 1);
109
106
  i--;
110
107
  }
111
108
  }
@@ -119,9 +116,8 @@ let ClientActionPointsService = class ClientActionPointsService {
119
116
  }
120
117
  }
121
118
  debug_ActionPoints() {
122
- var _a, _b;
123
119
  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;
120
+ const currentAreaActionPoints = this.actionPoints[this.roundToNearest(this._cachedPlayerPosition[0], this.chunkRadius)]?.[this.roundToNearest(this._cachedPlayerPosition[1], this.chunkRadius)]?.length || 0;
125
121
  Object.keys(this.actionPoints).forEach((posXAsStr) => {
126
122
  const posX = Number(posXAsStr);
127
123
  Object.keys(this.actionPoints[posX]).forEach((posYAsStr) => {
@@ -27,17 +27,16 @@ let ClientBlipsService = class ClientBlipsService {
27
27
  }
28
28
  // TODO: Why is createMultiple() not calling create()?
29
29
  createMultiple(...blips) {
30
- const _blips = blips.map((blip) => (Object.assign(Object.assign({}, blip), { instance: null })));
30
+ const _blips = blips.map((blip) => ({ ...blip, instance: null }));
31
31
  this._blips.push(..._blips);
32
32
  this.refresh();
33
33
  }
34
34
  create(blip) {
35
- var _a;
36
35
  const _blip = (!blip.type || blip.type === 'coords'
37
36
  ? Cfx.Client.AddBlipForCoord(blip.pos[0], blip.pos[1], blip.pos[2])
38
37
  : (blip.type === 'range'
39
38
  ? 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())));
39
+ : Cfx.Client.AddBlipForEntity(blip.entityId ?? Cfx.Client.PlayerPedId())));
41
40
  if (!blip.type || blip.type !== 'range') {
42
41
  Cfx.Client.SetBlipScale(_blip, blip.scale || 1.0);
43
42
  }
@@ -23,23 +23,22 @@ let ClientMarkersService = class ClientMarkersService {
23
23
  }
24
24
  /** Defines permanent markers. Handles draw-per-tick automatically. */
25
25
  create(...markers) {
26
- const _markers = markers.map((marker) => (Object.assign(Object.assign({}, marker), { instance: null })));
26
+ const _markers = markers.map((marker) => ({ ...marker, instance: null }));
27
27
  this._markers.push(..._markers);
28
28
  this._actionPoints.create(...markers.map((marker) => ({
29
29
  id: `${Cfx.Client.GetCurrentResourceName()}_marker_${marker.pos[0]}_${marker.pos[1]}`,
30
30
  pos: marker.pos,
31
31
  range: marker.renderDistance,
32
32
  action: async () => {
33
- var _a, _b, _c, _d, _e, _f, _g;
34
33
  if (marker.textureDict && !Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
35
34
  Cfx.Client.RequestStreamedTextureDict(marker.textureDict, true);
36
35
  while (!Cfx.Client.HasStreamedTextureDictLoaded(marker.textureDict)) {
37
36
  await Delay(100);
38
37
  }
39
38
  }
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);
39
+ Cfx.Client.DrawMarker(marker.marker, marker.pos[0], marker.pos[1], marker.pos[2], 0.0, 0.0, 0.0, marker.rotation?.[0] || 0.0, marker.rotation?.[1] || 0.0, marker.rotation?.[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
40
  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);
41
+ 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, marker.underlyingCircle.rgba?.[0] || marker.rgba[0], marker.underlyingCircle.rgba?.[1] || marker.rgba[1], marker.underlyingCircle.rgba?.[2] || marker.rgba[2], marker.underlyingCircle.rgba?.[3] || marker.rgba[3], false, true, 2, false, null, null, false);
43
42
  }
44
43
  }
45
44
  })));
@@ -25,8 +25,7 @@ let ClientTranslateService = class ClientTranslateService {
25
25
  this._language = null;
26
26
  }
27
27
  instant(key) {
28
- var _a;
29
- return ((_a = this._translations[this.language]) === null || _a === void 0 ? void 0 : _a[key]) || key;
28
+ return this._translations[this.language]?.[key] || key;
30
29
  }
31
30
  };
32
31
  ClientTranslateService = __decorate([
@@ -34,7 +34,7 @@ let ClientWaypointsService = class ClientWaypointsService {
34
34
  pos,
35
35
  longRange: true
36
36
  });
37
- this._checkpointsService.create(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);
37
+ this._checkpointsService.create(2, pos[0], pos[1], pos[2], null, null, null, diameter, COLOR_MAPPINGS[color ?? 0][0], COLOR_MAPPINGS[color ?? 0][1], COLOR_MAPPINGS[color ?? 0][2], 255, 0);
38
38
  if (routeColor !== -1) {
39
39
  Cfx.Client.SetBlipRoute(_waypoint, true);
40
40
  if (routeColor) {
@@ -0,0 +1,29 @@
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 { EVENT_DIRECTIONS, EventListener } from '@armoury/fivem-framework-common';
11
+ import { Injectable } from 'injection-js';
12
+ import { I18n } from './i18n.service';
13
+ let I18nChanger = class I18nChanger {
14
+ _onLanguageChangedRequestedUnsafe(language) {
15
+ console.log(`Setting language to ${language}.`);
16
+ Cfx.Client.SetResourceKvp('armoury:language', language);
17
+ I18n.setLanguage(language);
18
+ }
19
+ };
20
+ __decorate([
21
+ EventListener({ eventName: 'armoury:unsafe:language:change:request', direction: EVENT_DIRECTIONS.CLIENT_TO_CLIENT }),
22
+ __metadata("design:type", Function),
23
+ __metadata("design:paramtypes", [String]),
24
+ __metadata("design:returntype", void 0)
25
+ ], I18nChanger.prototype, "_onLanguageChangedRequestedUnsafe", null);
26
+ I18nChanger = __decorate([
27
+ Injectable()
28
+ ], I18nChanger);
29
+ export { I18nChanger };
@@ -4,18 +4,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var I18n_1;
11
- import { APP_INITIALIZER, EVENT_DIRECTIONS, EventListener } from '@armoury/fivem-framework-common';
7
+ import { APP_INITIALIZER } from '@armoury/fivem-framework-common';
12
8
  import Polyglot from 'node-polyglot';
13
9
  import { Injectable } from 'injection-js';
14
- let I18n = I18n_1 = class I18n {
10
+ let I18n = class I18n {
15
11
  static withOptions(options = {}) {
16
- var _a;
17
- const language = (_a = (Cfx.Client.GetResourceKvpString('armoury:language')
18
- || options.defaultLanguage)) !== null && _a !== void 0 ? _a : 'en-US';
12
+ const language = (Cfx.Client.GetResourceKvpString('armoury:language')
13
+ || options.defaultLanguage) ?? 'en-US';
19
14
  return {
20
15
  provide: APP_INITIALIZER,
21
16
  useValue: () => this.loadLanguage(language),
@@ -55,20 +50,9 @@ let I18n = I18n_1 = class I18n {
55
50
  static translate(key, params = {}) {
56
51
  return this.polyglot.t(key, params);
57
52
  }
58
- _onLanguageChangedRequestedUnsafe(language) {
59
- console.log(`Setting language to ${language}.`);
60
- Cfx.Client.SetResourceKvp('armoury:language', language);
61
- I18n_1.setLanguage(language);
62
- }
63
53
  };
64
54
  I18n.polyglot = new Polyglot();
65
- __decorate([
66
- EventListener({ eventName: 'armoury:unsafe:language:change:request', direction: EVENT_DIRECTIONS.CLIENT_TO_CLIENT }),
67
- __metadata("design:type", Function),
68
- __metadata("design:paramtypes", [String]),
69
- __metadata("design:returntype", void 0)
70
- ], I18n.prototype, "_onLanguageChangedRequestedUnsafe", null);
71
- I18n = I18n_1 = __decorate([
55
+ I18n = __decorate([
72
56
  Injectable()
73
57
  ], I18n);
74
58
  export { I18n };
@@ -1 +1,2 @@
1
+ export * from './i18n.changer';
1
2
  export * from './i18n.service';
@@ -3,8 +3,9 @@ import 'reflect-metadata';
3
3
  import { Provider } from 'injection-js';
4
4
  import { ClientActionPointsService, ClientBlipsService, ClientCheckpointsService, ClientMarkersService, ClientPedsService, ClientSessionService, ClientTicksService, ClientUIService, ClientVehiclesService, ClientWaypointsService, ClientHudService, UI } from './services';
5
5
  import { BootstrapOptions } from '@armoury/fivem-framework-common';
6
+ import { I18nChanger } from './services/i18n/i18n.changer';
6
7
  export declare const CLIENT_PROVIDERS: (typeof ClientTicksService | typeof ClientActionPointsService | typeof ClientBlipsService | typeof ClientCheckpointsService | typeof ClientHudService | typeof ClientMarkersService | typeof ClientPedsService | typeof ClientSessionService | typeof ClientVehiclesService | typeof ClientUIService | typeof ClientWaypointsService)[];
7
- export declare const CLIENT_EAGER_PROVIDERS: (typeof UI)[];
8
+ export declare const CLIENT_EAGER_PROVIDERS: (typeof UI | typeof I18nChanger)[];
8
9
  export declare function bootstrap<T extends {
9
10
  new (...args: any[]): any;
10
11
  } & Provider>(_class: T, options?: BootstrapOptions): Promise<InstanceType<T>>;
@@ -0,0 +1,3 @@
1
+ export declare class I18nChanger {
2
+ protected _onLanguageChangedRequestedUnsafe(language: string): void;
3
+ }
@@ -5,7 +5,6 @@ export declare class I18n {
5
5
  static setLanguage(language: string): void;
6
6
  private static loadLanguage;
7
7
  static translate(key: string, params?: TranslationParams): string;
8
- protected _onLanguageChangedRequestedUnsafe(language: string): void;
9
8
  }
10
9
  type I18nOptions = {
11
10
  defaultLanguage?: string;
@@ -1 +1,2 @@
1
+ export * from './i18n.changer';
1
2
  export * from './i18n.service';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@armoury/fivem-framework-client",
3
- "version": "1.0.53",
3
+ "version": "1.0.55",
4
4
  "description": "Client APIs for the Armoury FiveM framework",
5
5
  "main": "dist/cjs/client/index.js",
6
6
  "module": "dist/esm/client/index.js",
@@ -27,7 +27,7 @@
27
27
  "rxjs": "^7.8.1"
28
28
  },
29
29
  "peerDependencies": {
30
- "@armoury/fivem-framework-common": "1.0.53",
30
+ "@armoury/fivem-framework-common": "1.0.55",
31
31
  "node-polyglot": "2.6.0"
32
32
  },
33
33
  "publishConfig": {