Skip to content

Commit

Permalink
Addition of a cloth permission list and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamXZE committed Apr 7, 2023
1 parent 0a2393e commit 5b6ca16
Show file tree
Hide file tree
Showing 10 changed files with 41,164 additions and 147 deletions.
1 change: 1 addition & 0 deletions resources/[soz]/soz-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"chokidar": "^3.5.3",
"concurrently": "^7.2.2",
"css-loader": "^6.7.1",
"csvtojson": "^2.0.10",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
Expand Down
20 changes: 13 additions & 7 deletions resources/[soz]/soz-core/src/client/clothing/clothing.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Inject, Injectable } from '../../core/decorators/injectable';
import { Component, ComponentEnum, FfsComponent, KeepHairWithMask, Outfit, OutfitItem, Prop } from '../../shared/cloth';
import { ffsClothConfig } from '../../shared/showRoom/ffsClothConfig';
import { PlayerService } from '../player/player.service';

@Injectable()
Expand Down Expand Up @@ -64,11 +65,16 @@ export class ClothingService {
}

public getFfsClothSet(pedId: number): Outfit {
return this.getClothSetForComponentAndProp(FfsComponent, Prop, pedId);
const ffsClothSet = this.getClothSetForComponentAndProp(FfsComponent, Prop, pedId);
for (const propIndex in ffsClothSet.Props) {
ffsClothSet.Props[propIndex].Drawable = Math.max(ffsClothSet.Props[propIndex].Drawable, 0);
}

return ffsClothSet;
}

public getFfsMaxOptions(pedId: number) {
return this.getMaxOptionsForComponentAndProp(FfsComponent, Prop, pedId);
public getFfsOptions(model: string) {
return ffsClothConfig[model];
}

private getClothSetForComponentAndProp(component: ComponentEnum, prop: ComponentEnum, pedId: number): Outfit {
Expand Down Expand Up @@ -112,11 +118,11 @@ export class ClothingService {
const maxOptionObject = {
componentIndex: componentIndex,
maxDrawables: maxDrawable,
maxTextures: [],
maxTextures: 0,
};
for (let drawableIndex = 0; drawableIndex < maxDrawable; drawableIndex++) {
const maxTextureForDrawable = GetNumberOfPedTextureVariations(pedId, componentId, drawableIndex);
maxOptionObject.maxTextures.push(maxTextureForDrawable);
maxOptionObject.maxTextures = Math.max(maxTextureForDrawable, maxOptionObject.maxTextures);
}

maxOptions.push(maxOptionObject);
Expand All @@ -128,12 +134,12 @@ export class ClothingService {
const maxOptionObject = {
propIndex: propIndex,
maxDrawables: maxDrawable,
maxTextures: [],
maxTextures: 0,
};

for (let drawableIndex = 0; drawableIndex < maxDrawable; drawableIndex++) {
const maxTextureForDrawable = GetNumberOfPedPropTextureVariations(pedId, propId, drawableIndex);
maxOptionObject.maxTextures.push(maxTextureForDrawable);
maxOptionObject.maxTextures = Math.max(maxTextureForDrawable, maxOptionObject.maxTextures);
}
maxOptions.push(maxOptionObject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import {
Outfit,
OutfitItem,
Prop,
ShowRoomFreeElement,
ShowRoomPricePerSelection,
} from '../../../shared/cloth';
import { ffsClothConfig } from '../../../shared/showRoom/ffsClothConfig';
import { ClientEvent, NuiEvent, ServerEvent } from '../../../shared/event';
import { JobPermission } from '../../../shared/job';
import { MenuType } from '../../../shared/nui/menu';
Expand Down Expand Up @@ -67,22 +66,26 @@ export class FightForStylShowRoomProvider {
private readonly defaultComponentAndProd = {
Components: {
3: { Drawable: 0, Texture: 0, Palette: 0 },
8: { Drawable: 0, Texture: 25, Palette: 0 },
8: { Drawable: 57, Texture: 0, Palette: 0 },
},
Props: {},
};

private pedId = null;

public async onShowRoomOpenMenu(outfitType: string) {
public async onShowRoomOpenMenu(outfitType: string, pedModel: string) {
const player = this.playerService.getPlayer();
const canCraft = (
this.playerService.isOnDuty() && this.jobPermissionService.hasPermission(player.job.id, JobPermission.FfsCraftShowRoom)
);
this.nuiMenu.openMenu(MenuType.FightForStyleShowRoomMenu, {
state: {
clothConfig: this.clothingService.getFfsClothSet(this.pedId),
maxOptions: this.clothingService.getFfsMaxOptions(this.pedId),
options: this.clothingService.getFfsOptions(pedModel),
},
canCraft: this.jobPermissionService.hasPermission(player.job.id, JobPermission.FfsCraftShowRoom),
canCraft: canCraft,
defaultComponentAndProd: this.defaultComponentAndProd,
pedModel: pedModel,
outfitType: outfitType,
});
FreezeEntityPosition(PlayerPedId(), true);
Expand Down Expand Up @@ -124,11 +127,13 @@ export class FightForStylShowRoomProvider {
shouldCraft,
description,
outfitType,
pedModel,
}: {
currentCraft: Partial<Outfit>;
shouldCraft: { Components: Partial<Record<FfsComponent, boolean>>; Props: Partial<Record<Prop, boolean>> };
description: string;
outfitType: string;
pedModel: string
}) {
const outfit = {
...currentCraft,
Expand All @@ -140,7 +145,7 @@ export class FightForStylShowRoomProvider {
Object.keys(outfit.Props).map(propIndex => {
if (!shouldCraft.Props?.[propIndex]) delete outfit.Props[propIndex];
});
TriggerServerEvent(ServerEvent.FFS_SHOW_ROOM_CRAFTING, outfit, outfitType);
TriggerServerEvent(ServerEvent.FFS_SHOW_ROOM_CRAFTING, outfit, outfitType, pedModel);
}

@OnEvent(ClientEvent.ChangeOutfitFromItem)
Expand Down Expand Up @@ -169,17 +174,16 @@ export class FightForStylShowRoomProvider {
icon: 'fas fa-shopping-cart',
color: 'ffs',
job: 'ffs',
canInteract: () => {
return this.playerService.isOnDuty();
},
action: async () => {
if (this.pedId) return;
const pedModel = 'mp_m_freemode_01';
this.pedId = await this.pedFactory.createPed({
model: 'mp_m_freemode_01',
model: pedModel,
modelCustomization: { SkinMix: 0.5, ShapeMix: 0.15, Father: 20, Mother: 32 },
components: {
3: [0, 0, 0],
8: [0, 25, 0],
6: [0, 10, 0],
8: [57, 0, 0],
11: [0, 0, 0],
},
face: {
Expand Down Expand Up @@ -236,25 +240,24 @@ export class FightForStylShowRoomProvider {
blockevents: true,
});
this.cameraService.setupCamera(this.CAMERA_POSITION, this.CAMERA_TARGET);
await this.onShowRoomOpenMenu('ffs_crafted_outfit_m');
await this.onShowRoomOpenMenu('ffs_crafted_outfit_m', pedModel);
},
},
{
label: 'Accéder au Show Room Femme',
icon: 'fas fa-shopping-cart',
color: 'ffs',
job: 'ffs',
canInteract: () => {
return this.playerService.isOnDuty();
},
action: async () => {
if (this.pedId) return;
const pedModel = 'mp_f_freemode_01';
this.pedId = await this.pedFactory.createPed({
model: 'mp_f_freemode_01',
model: pedModel,
modelCustomization: { SkinMix: 0.5, ShapeMix: 0.15, Father: 25, Mother: 26 },
components: {
3: [0, 0, 0],
8: [0, 25, 0],
6: [0, 10, 0],
8: [57, 0, 0],
11: [0, 0, 0],
},
face: {
Expand Down Expand Up @@ -311,7 +314,7 @@ export class FightForStylShowRoomProvider {
blockevents: true,
});
this.cameraService.setupCamera(this.CAMERA_POSITION, this.CAMERA_TARGET);
await this.onShowRoomOpenMenu('ffs_crafted_outfit_f');
await this.onShowRoomOpenMenu('ffs_crafted_outfit_f', pedModel);
},
},
],
Expand All @@ -324,9 +327,11 @@ export class FightForStylShowRoomProvider {
public async onSkinLookAtComponentDrawable({
index,
isComponent,
pedModel,
}: {
index: FfsComponent | Prop;
isComponent: boolean;
pedModel: string;
}) {
const formattedIndex = Number(index);

Expand All @@ -347,7 +352,11 @@ export class FightForStylShowRoomProvider {
return Err('Le drawable id doit être un nombre.');
}
if (Number(value) < 0 || Number(value) > maxDrawable) {
return Err(`Le drawable id doit être compris entre 0 et ${maxDrawable}.`);
return Err(`Le numéro de vêtement doit être compris entre 0 et ${maxDrawable-1}.`);
}
const type = isComponent ? "Components": "Props"
if (!ffsClothConfig[pedModel][type][formattedIndex][value]) {
return Err(`Le vêtement ${value} n'est pas disponible au Show Room.`);
}
return Ok(true);
}
Expand Down
Loading

0 comments on commit 5b6ca16

Please sign in to comment.