From eec3423d0aff0d1a94a56af9a1a3a9b3ccd1e15e Mon Sep 17 00:00:00 2001 From: Kedrihan Date: Tue, 30 Jul 2024 17:44:11 +0200 Subject: [PATCH 1/2] ajout confirmation --- .../housing/housing.property.zone.provider.ts | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/resources/[soz]/soz-core/src/client/housing/housing.property.zone.provider.ts b/resources/[soz]/soz-core/src/client/housing/housing.property.zone.provider.ts index 2ad97fbe79..12d2f2ae81 100644 --- a/resources/[soz]/soz-core/src/client/housing/housing.property.zone.provider.ts +++ b/resources/[soz]/soz-core/src/client/housing/housing.property.zone.provider.ts @@ -35,6 +35,7 @@ import { HousingRepository } from '../repository/housing.repository'; import { TargetFactory } from '../target/target.factory'; import { VehicleGarageProvider } from '../vehicle/vehicle.garage.provider'; import { HousingMenuProvider } from './housing.menu.provider'; +import { InputService } from '../nui/input.service'; const BlipSprite = { house: { @@ -73,6 +74,9 @@ export class HousingPropertyZoneProvider { @Inject(BlipFactory) private blipFactory: BlipFactory; + @Inject(InputService) + private inputService: InputService; + private temporaryAccess = new Set(); @Exportable('GetPlayerApartmentAccess') @@ -588,8 +592,14 @@ export class HousingPropertyZoneProvider { return; } + const value = await this.inputService.askInput({ + title: 'Voulez-vous vraiment expulser votre colocataire ? (Tapez "oui" pour confirmer)', + maxCharacters: 3, + }); - await this.housingMenuProvider.removeRoommate({ apartmentId: apartments[0].id, propertyId: property.id }); + if (value && value.toLowerCase() === 'oui') { + await this.housingMenuProvider.removeRoommate({ apartmentId: apartments[0].id, propertyId: property.id }); + } } private getUniqueApartment(property: Property): Apartment | null { @@ -618,7 +628,7 @@ export class HousingPropertyZoneProvider { await this.vehicleGarageProvider.openHouseGarageMenu(property.identifier, apartments); } - public leavePropertyAsRoommate(property: Property) { + public async leavePropertyAsRoommate(property: Property) { const player = this.playerService.getPlayer(); if (!player) { @@ -630,7 +640,13 @@ export class HousingPropertyZoneProvider { if (!apartment) { return; } + const value = await this.inputService.askInput({ + title: 'Voulez-vous vraiment partir de la colocation ? (Tapez "oui" pour confirmer)', + maxCharacters: 3, + }); - TriggerServerEvent(ServerEvent.HOUSING_REMOVE_ROOMMATE, property.id, apartment.id); + if (value && value.toLowerCase() === 'oui') { + TriggerServerEvent(ServerEvent.HOUSING_REMOVE_ROOMMATE, property.id, apartment.id); + } } } From 6f1d032c06a2770af677db4d59b1134abb37b034 Mon Sep 17 00:00:00 2001 From: Kedrihan Date: Tue, 30 Jul 2024 17:48:11 +0200 Subject: [PATCH 2/2] utilisation askConfirm --- .../housing/housing.property.zone.provider.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/resources/[soz]/soz-core/src/client/housing/housing.property.zone.provider.ts b/resources/[soz]/soz-core/src/client/housing/housing.property.zone.provider.ts index 12d2f2ae81..3dcd305882 100644 --- a/resources/[soz]/soz-core/src/client/housing/housing.property.zone.provider.ts +++ b/resources/[soz]/soz-core/src/client/housing/housing.property.zone.provider.ts @@ -592,12 +592,11 @@ export class HousingPropertyZoneProvider { return; } - const value = await this.inputService.askInput({ - title: 'Voulez-vous vraiment expulser votre colocataire ? (Tapez "oui" pour confirmer)', - maxCharacters: 3, - }); + const confirm = await this.inputService.askConfirm( + 'Voulez-vous vraiment expulser votre colocataire ? Entrez OUI pour confirmer.' + ); - if (value && value.toLowerCase() === 'oui') { + if (confirm) { await this.housingMenuProvider.removeRoommate({ apartmentId: apartments[0].id, propertyId: property.id }); } } @@ -640,12 +639,11 @@ export class HousingPropertyZoneProvider { if (!apartment) { return; } - const value = await this.inputService.askInput({ - title: 'Voulez-vous vraiment partir de la colocation ? (Tapez "oui" pour confirmer)', - maxCharacters: 3, - }); + const confirm = await this.inputService.askConfirm( + 'Voulez-vous vraiment quitter la colocation ? Entrez OUI pour confirmer.' + ); - if (value && value.toLowerCase() === 'oui') { + if (confirm) { TriggerServerEvent(ServerEvent.HOUSING_REMOVE_ROOMMATE, property.id, apartment.id); } }