@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.
- package/dist/cjs/client/client-action-points.js +179 -0
- package/dist/cjs/client/client-entities.js +287 -0
- package/dist/cjs/client/client-hud.controller.js +17 -0
- package/dist/cjs/client/client-ui.controller.js +91 -0
- package/dist/cjs/client/client.base.js +72 -0
- package/dist/cjs/client/client.controller.js +28 -0
- package/dist/cjs/client/constants/color.mappings.js +91 -0
- package/dist/cjs/client/index.js +45 -0
- package/dist/cjs/client/interfaces/client-ui.interface.js +2 -0
- package/dist/cjs/client/models/action-point.model.js +2 -0
- package/dist/cjs/client/models/blip.model.js +2 -0
- package/dist/cjs/client/models/index.js +21 -0
- package/dist/cjs/client/models/marker.model.js +2 -0
- package/dist/cjs/client/models/ui-button.model.js +2 -0
- package/dist/cjs/client/models/ui-dialog.model.js +2 -0
- package/dist/cjs/client/services/client-action-points.service.js +158 -0
- package/dist/cjs/client/services/client-blips.service.js +80 -0
- package/dist/cjs/client/services/client-checkpoints.service.js +41 -0
- package/dist/cjs/client/services/client-hud.service.js +25 -0
- package/dist/cjs/client/services/client-markers.service.js +62 -0
- package/dist/cjs/client/services/client-peds.service.js +104 -0
- package/dist/cjs/client/services/client-session.service.js +24 -0
- package/dist/cjs/client/services/client-ticks.service.js +77 -0
- package/dist/cjs/client/services/client-translate.service.js +41 -0
- package/dist/cjs/client/services/client-ui.service.js +112 -0
- package/dist/cjs/client/services/client-vehicles.service.js +66 -0
- package/dist/cjs/client/services/client-waypoints.service.js +72 -0
- package/dist/cjs/client/services/index.js +28 -0
- package/dist/esm/client/client-action-points.js +176 -0
- package/dist/esm/client/client-entities.js +284 -0
- package/dist/esm/client/client-hud.controller.js +13 -0
- package/dist/esm/client/client-ui.controller.js +84 -0
- package/dist/esm/client/client.base.js +68 -0
- package/dist/esm/client/client.controller.js +24 -0
- package/dist/esm/client/constants/color.mappings.js +88 -0
- package/dist/esm/client/index.js +27 -0
- package/dist/esm/client/interfaces/client-ui.interface.js +1 -0
- package/dist/esm/client/models/action-point.model.js +1 -0
- package/dist/esm/client/models/blip.model.js +1 -0
- package/dist/esm/client/models/index.js +5 -0
- package/dist/esm/client/models/marker.model.js +1 -0
- package/dist/esm/client/models/ui-button.model.js +1 -0
- package/dist/esm/client/models/ui-dialog.model.js +1 -0
- package/dist/esm/client/services/client-action-points.service.js +155 -0
- package/dist/esm/client/services/client-blips.service.js +77 -0
- package/dist/esm/client/services/client-checkpoints.service.js +38 -0
- package/dist/esm/client/services/client-hud.service.js +22 -0
- package/dist/esm/client/services/client-markers.service.js +59 -0
- package/dist/esm/client/services/client-peds.service.js +101 -0
- package/dist/esm/client/services/client-session.service.js +21 -0
- package/dist/esm/client/services/client-ticks.service.js +74 -0
- package/dist/esm/client/services/client-translate.service.js +38 -0
- package/dist/esm/client/services/client-ui.service.js +109 -0
- package/dist/esm/client/services/client-vehicles.service.js +63 -0
- package/dist/esm/client/services/client-waypoints.service.js +69 -0
- package/dist/esm/client/services/index.js +12 -0
- package/dist/types/ambient.declarations.d.ts +62840 -0
- package/dist/types/client/client-action-points.d.ts +30 -0
- package/dist/types/client/client-entities.d.ts +43 -0
- package/dist/types/client/client-hud.controller.d.ts +4 -0
- package/dist/types/client/client-ui.controller.d.ts +19 -0
- package/dist/types/client/client.base.d.ts +22 -0
- package/dist/types/client/client.controller.d.ts +12 -0
- package/dist/types/client/constants/color.mappings.d.ts +3 -0
- package/dist/types/client/index.d.ts +10 -0
- package/dist/types/client/interfaces/client-ui.interface.d.ts +4 -0
- package/dist/types/client/models/action-point.model.d.ts +10 -0
- package/dist/types/client/models/blip.model.d.ts +14 -0
- package/dist/types/client/models/index.d.ts +5 -0
- package/dist/types/client/models/marker.model.d.ts +22 -0
- package/dist/types/client/models/ui-button.model.d.ts +8 -0
- package/dist/types/client/models/ui-dialog.model.d.ts +9 -0
- package/dist/types/client/services/client-action-points.service.d.ts +29 -0
- package/dist/types/client/services/client-blips.service.d.ts +10 -0
- package/dist/types/client/services/client-checkpoints.service.d.ts +7 -0
- package/dist/types/client/services/client-hud.service.d.ts +3 -0
- package/dist/types/client/services/client-markers.service.d.ts +11 -0
- package/dist/types/client/services/client-peds.service.d.ts +10 -0
- package/dist/types/client/services/client-session.service.d.ts +3 -0
- package/dist/types/client/services/client-ticks.service.d.ts +21 -0
- package/dist/types/client/services/client-translate.service.d.ts +13 -0
- package/dist/types/client/services/client-ui.service.d.ts +19 -0
- package/dist/types/client/services/client-vehicles.service.d.ts +8 -0
- package/dist/types/client/services/client-waypoints.service.d.ts +13 -0
- package/dist/types/client/services/index.d.ts +12 -0
- package/package.json +30 -5
- package/README.md +0 -3
|
@@ -0,0 +1,109 @@
|
|
|
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 { Subject } from "rxjs";
|
|
16
|
+
import { EventListener, UIListener } from '@armoury/fivem-framework-common';
|
|
17
|
+
let ClientUIService = class ClientUIService {
|
|
18
|
+
get onShow$() {
|
|
19
|
+
return this._onShow$.asObservable();
|
|
20
|
+
}
|
|
21
|
+
get onHide$() {
|
|
22
|
+
return this._onHide$.asObservable();
|
|
23
|
+
}
|
|
24
|
+
get visible() {
|
|
25
|
+
return this._visible;
|
|
26
|
+
}
|
|
27
|
+
constructor(_ticksService) {
|
|
28
|
+
this._ticksService = _ticksService;
|
|
29
|
+
this._onShow$ = new Subject();
|
|
30
|
+
this._onHide$ = new Subject();
|
|
31
|
+
this._visible = false;
|
|
32
|
+
this.cooldownTimestamp = 0;
|
|
33
|
+
}
|
|
34
|
+
show(ignoreCursorMode = false, ignoreFocus = false) {
|
|
35
|
+
if (!this._visible) {
|
|
36
|
+
if (!ignoreCursorMode) {
|
|
37
|
+
Cfx.Client.EnterCursorMode();
|
|
38
|
+
}
|
|
39
|
+
if (!ignoreFocus) {
|
|
40
|
+
Cfx.Client.SetNuiFocus(true, true);
|
|
41
|
+
Cfx.Client.SetNuiFocusKeepInput(false);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
this._visible = true;
|
|
45
|
+
this._ticksService.addUnique({
|
|
46
|
+
id: `${Cfx.Client.GetCurrentResourceName()}_UI`,
|
|
47
|
+
function: () => {
|
|
48
|
+
Cfx.Client.DisableControlAction(0, 1, this._visible);
|
|
49
|
+
Cfx.Client.DisableControlAction(0, 2, this._visible);
|
|
50
|
+
Cfx.Client.DisableControlAction(0, 142, this._visible);
|
|
51
|
+
Cfx.Client.DisableControlAction(0, 18, this._visible);
|
|
52
|
+
Cfx.Client.DisableControlAction(0, 322, this._visible);
|
|
53
|
+
Cfx.Client.DisableControlAction(0, 106, this._visible);
|
|
54
|
+
if (!this._visible) {
|
|
55
|
+
this._ticksService.remove(`${Cfx.Client.GetCurrentResourceName()}_UI`);
|
|
56
|
+
Cfx.Client.SetNuiFocus(false, false);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
hide() {
|
|
62
|
+
this.cooldownTimestamp = Date.now() + (1000 * 3);
|
|
63
|
+
Cfx.Client.LeaveCursorMode();
|
|
64
|
+
this._visible = false;
|
|
65
|
+
Cfx.Client.SendNuiMessage(JSON.stringify({
|
|
66
|
+
type: 'dismiss'
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
onForceShowUI(data) {
|
|
70
|
+
this.show(false, false);
|
|
71
|
+
this._onShow$.next(data);
|
|
72
|
+
}
|
|
73
|
+
onForceHideUI(data) {
|
|
74
|
+
this.hide();
|
|
75
|
+
this._onHide$.next(data);
|
|
76
|
+
}
|
|
77
|
+
dismiss() {
|
|
78
|
+
this.hide();
|
|
79
|
+
Cfx.TriggerServerEvent(`${Cfx.Client.GetCurrentResourceName()}:on-force-hidden`);
|
|
80
|
+
Cfx.emit(`${Cfx.Client.GetCurrentResourceName()}:on-force-hidden`);
|
|
81
|
+
}
|
|
82
|
+
isOnCooldown() {
|
|
83
|
+
return Date.now() < this.cooldownTimestamp;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
__decorate([
|
|
87
|
+
EventListener({ eventName: `${Cfx.Client.GetCurrentResourceName()}:force-showui` }),
|
|
88
|
+
__metadata("design:type", Function),
|
|
89
|
+
__metadata("design:paramtypes", [Object]),
|
|
90
|
+
__metadata("design:returntype", void 0)
|
|
91
|
+
], ClientUIService.prototype, "onForceShowUI", null);
|
|
92
|
+
__decorate([
|
|
93
|
+
EventListener({ eventName: `${Cfx.Client.GetCurrentResourceName()}:force-hideui` }),
|
|
94
|
+
__metadata("design:type", Function),
|
|
95
|
+
__metadata("design:paramtypes", [Object]),
|
|
96
|
+
__metadata("design:returntype", void 0)
|
|
97
|
+
], ClientUIService.prototype, "onForceHideUI", null);
|
|
98
|
+
__decorate([
|
|
99
|
+
UIListener({ eventName: 'dismiss' }),
|
|
100
|
+
__metadata("design:type", Function),
|
|
101
|
+
__metadata("design:paramtypes", []),
|
|
102
|
+
__metadata("design:returntype", void 0)
|
|
103
|
+
], ClientUIService.prototype, "dismiss", null);
|
|
104
|
+
ClientUIService = __decorate([
|
|
105
|
+
Injectable(),
|
|
106
|
+
__param(0, Inject(ClientTicksService)),
|
|
107
|
+
__metadata("design:paramtypes", [ClientTicksService])
|
|
108
|
+
], ClientUIService);
|
|
109
|
+
export { ClientUIService };
|
|
@@ -0,0 +1,63 @@
|
|
|
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 ClientVehiclesService = class ClientVehiclesService {
|
|
13
|
+
get vehicles() {
|
|
14
|
+
return this._vehicles;
|
|
15
|
+
}
|
|
16
|
+
// TODO: Use $onInit
|
|
17
|
+
constructor() {
|
|
18
|
+
this._vehicles = [];
|
|
19
|
+
Cfx.Client.onNet('onResourceStop', (resourceName) => {
|
|
20
|
+
if (resourceName === Cfx.Client.GetCurrentResourceName()) {
|
|
21
|
+
this._vehicles.forEach((vehicle) => {
|
|
22
|
+
this.remove(vehicle);
|
|
23
|
+
});
|
|
24
|
+
this._vehicles = [];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** Wrapper of FiveM's native CreateVehicle - includes requesting the model */
|
|
29
|
+
async createAsync(modelHash, x, y, z, heading, isNetwork, netMissionEntity, putPlayerInVehicle = false) {
|
|
30
|
+
let attempts = 0;
|
|
31
|
+
Cfx.Client.RequestModel(modelHash);
|
|
32
|
+
while (!Cfx.Client.HasModelLoaded(modelHash)) {
|
|
33
|
+
if (attempts > 10) {
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
await Delay(100);
|
|
37
|
+
attempts++;
|
|
38
|
+
}
|
|
39
|
+
const createdVehicle = Cfx.Client.CreateVehicle(modelHash, x, y, z, heading, isNetwork, netMissionEntity);
|
|
40
|
+
if (createdVehicle) {
|
|
41
|
+
if (netMissionEntity) {
|
|
42
|
+
this._vehicles.push(createdVehicle);
|
|
43
|
+
}
|
|
44
|
+
if (putPlayerInVehicle) {
|
|
45
|
+
Cfx.Client.TaskWarpPedIntoVehicle(Cfx.Client.GetPlayerPed(-1), createdVehicle, -1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return createdVehicle;
|
|
49
|
+
}
|
|
50
|
+
remove(vehicle) {
|
|
51
|
+
if (Cfx.Client.DoesEntityExist(vehicle)) {
|
|
52
|
+
Cfx.Client.DeleteEntity(vehicle);
|
|
53
|
+
}
|
|
54
|
+
if (this._vehicles.indexOf(vehicle) > -1) {
|
|
55
|
+
this._vehicles.splice(this._vehicles.indexOf(vehicle), 1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
ClientVehiclesService = __decorate([
|
|
60
|
+
Injectable(),
|
|
61
|
+
__metadata("design:paramtypes", [])
|
|
62
|
+
], ClientVehiclesService);
|
|
63
|
+
export { ClientVehiclesService };
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { ClientBlipsService } from "./client-blips.service";
|
|
15
|
+
import { COLOR_MAPPINGS } from "../constants/color.mappings";
|
|
16
|
+
import { ClientCheckpointsService } from "./client-checkpoints.service";
|
|
17
|
+
let ClientWaypointsService = class ClientWaypointsService {
|
|
18
|
+
get waypoints() {
|
|
19
|
+
return this._waypoints;
|
|
20
|
+
}
|
|
21
|
+
constructor(_blipsService, _checkpointsService) {
|
|
22
|
+
this._blipsService = _blipsService;
|
|
23
|
+
this._checkpointsService = _checkpointsService;
|
|
24
|
+
this._waypoints = [];
|
|
25
|
+
}
|
|
26
|
+
/** Defines a custom, irreplaceable waypoint */
|
|
27
|
+
createWaypoint(pos, title, color, id, routeColor, diameter = 3.0) {
|
|
28
|
+
const currentResource = Cfx.Client.GetCurrentResourceName().replace('-', ' ');
|
|
29
|
+
const defaultTitle = `${currentResource.slice(0, 1).toUpperCase()}${currentResource.slice(1)}`;
|
|
30
|
+
const _waypoint = this._blipsService.create({
|
|
31
|
+
id: id || 1,
|
|
32
|
+
color: color || 69,
|
|
33
|
+
title: title || defaultTitle,
|
|
34
|
+
pos,
|
|
35
|
+
longRange: true
|
|
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);
|
|
38
|
+
if (routeColor !== -1) {
|
|
39
|
+
Cfx.Client.SetBlipRoute(_waypoint, true);
|
|
40
|
+
if (routeColor) {
|
|
41
|
+
Cfx.Client.SetBlipRouteColour(_waypoint, routeColor);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
this._waypoints.push(_waypoint);
|
|
45
|
+
return _waypoint;
|
|
46
|
+
}
|
|
47
|
+
clearWaypoints() {
|
|
48
|
+
this._waypoints.forEach((waypoint) => {
|
|
49
|
+
this.clearWaypoint(waypoint, true);
|
|
50
|
+
});
|
|
51
|
+
this._waypoints = [];
|
|
52
|
+
}
|
|
53
|
+
clearWaypoint(waypoint, ignoreSplice = false) {
|
|
54
|
+
this._checkpointsService.clearByPosition(Cfx.Client.GetBlipCoords(waypoint));
|
|
55
|
+
Cfx.Client.SetBlipRoute(waypoint, false);
|
|
56
|
+
Cfx.Client.RemoveBlip(waypoint);
|
|
57
|
+
if (!ignoreSplice) {
|
|
58
|
+
this._waypoints.splice(this._waypoints.indexOf(waypoint), 1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
ClientWaypointsService = __decorate([
|
|
63
|
+
Injectable(),
|
|
64
|
+
__param(0, Inject(ClientBlipsService)),
|
|
65
|
+
__param(1, Inject(ClientCheckpointsService)),
|
|
66
|
+
__metadata("design:paramtypes", [ClientBlipsService,
|
|
67
|
+
ClientCheckpointsService])
|
|
68
|
+
], ClientWaypointsService);
|
|
69
|
+
export { ClientWaypointsService };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './client-action-points.service';
|
|
2
|
+
export * from './client-blips.service';
|
|
3
|
+
export * from './client-checkpoints.service';
|
|
4
|
+
export * from './client-hud.service';
|
|
5
|
+
export * from './client-markers.service';
|
|
6
|
+
export * from './client-peds.service';
|
|
7
|
+
export * from './client-session.service';
|
|
8
|
+
export * from './client-ticks.service';
|
|
9
|
+
export * from './client-translate.service';
|
|
10
|
+
export * from './client-vehicles.service';
|
|
11
|
+
export * from './client-ui.service';
|
|
12
|
+
export * from './client-waypoints.service';
|