Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several additions/improvements #65

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions game/src/client/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,68 @@ export const DATA_CLOTHES: DataClothes = {
props: {
male: [[1, 0]],
female: [[1, 0]],
maleProps: [[0, -1]],
femaleProps: [[0, -1]],
},
},
glasses: {
animations: {
on: {
dict: 'clothingspecs',
anim: 'take_off',
move: 51,
duration: 800,
},
off: {
dict: 'clothingspecs',
anim: 'take_off',
move: 51,
duration: 1400,
},
},
props: {
maleProps: [[1, 0]],
femaleProps: [[1, 0]],
},
},
earaccs: {
animations: {
on: {
dict: 'mp_cp_stolen_tut',
anim: 'b_think',
move: 51,
duration: 900,
},
off: {
dict: 'mp_cp_stolen_tut',
anim: 'b_think',
move: 51,
duration: 900,
},
},
props: {
maleProps: [[2, -1]],
femaleProps: [[2, -1]],
},
},
chain: {
animations: {
on: {
dict: 'clothingtie',
anim: 'try_tie_negative_a',
move: 51,
duration: 2100,
},
off: {
dict: 'clothingtie',
anim: 'try_tie_negative_a',
move: 51,
duration: 2100,
},
},
props: {
male: [[7, 0]],
female: [[7, 0]],
},
},
body: {
Expand Down
13 changes: 11 additions & 2 deletions game/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ export const totalTattoos: TattooList = JSON.parse(
LoadResourceFile(GetCurrentResourceName(), 'tattoos.json'),
);

export const femaleOnlyTattoos: TattooList = totalTattoos;
export const maleOnlyTattoos: TattooList = totalTattoos;

for (let [bodypart, content] of Object.entries(totalTattoos)) {
femaleOnlyTattoos[bodypart] = content.filter(tattoo => ((tattoo.hashFemale !== "")));
maleOnlyTattoos[bodypart] = content.filter(tattoo => ((tattoo.hashMale !== "")));
}

export const pedModels: string[] = JSON.parse(
LoadResourceFile(GetCurrentResourceName(), 'peds.json'),
);
Expand Down Expand Up @@ -106,7 +114,7 @@ function getPedFaceFeatures(ped: number): PedFaceFeatures {
function getPedHeadOverlays(ped: number): PedHeadOverlays {
const headOverlays = HEAD_OVERLAYS.reduce((object, overlay, index) => {
// success, value, colorType, firstColor, secondColor, opacity
const [, value, , firstColor, , opacity] = GetPedHeadOverlayData(ped, index);
const [, value, , firstColor, secondColor, opacity] = GetPedHeadOverlayData(ped, index);

const hasOverlay = value !== 255;

Expand All @@ -115,7 +123,7 @@ function getPedHeadOverlays(ped: number): PedHeadOverlays {

return {
...object,
[overlay]: { style: safeValue, opacity: normalizedOpacity, color: firstColor },
[overlay]: { style: safeValue, opacity: normalizedOpacity, color: firstColor, secondColor: secondColor },
};
}, {} as PedHeadOverlays);

Expand Down Expand Up @@ -252,6 +260,7 @@ export function setPedHeadOverlays(ped: number, headOverlays: PedHeadOverlays):
}

SetPedHeadOverlayColor(ped, index, colorType, headOverlay.color, headOverlay.secondColor);

}
});
}
Expand Down
99 changes: 76 additions & 23 deletions game/src/client/modules/customization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
DATA_CLOTHES,
} from '../../constants';

import { pedModels, getPedAppearance, setPlayerAppearance, totalTattoos } from '../../index';
import { pedModels, getPedAppearance, setPlayerAppearance, totalTattoos, maleOnlyTattoos, femaleOnlyTattoos } from '../../index';

import { arrayToVector3, isPedMale, Delay } from '../../utils';

Expand Down Expand Up @@ -131,7 +131,7 @@ export function getAppearanceSettings(): AppearanceSettings {
};

const tattoos: TattoosSettings = {
items: totalTattoos,
items: (isPedMale(playerPed)) ? maleOnlyTattoos : femaleOnlyTattoos,
};

const components: ComponentSettings[] = PED_COMPONENTS_IDS.map(componentId =>
Expand Down Expand Up @@ -410,8 +410,8 @@ export function pedTurnAround(ped: number): void {
export async function wearClothes(data: PedAppearance, typeClothes: string): Promise<void> {
const { animations, props } = DATA_CLOTHES[typeClothes];
const { dict, anim, move, duration } = animations.on;
const { male, female } = props;
const { components } = data;
const { male, female, maleProps, femaleProps } = props;
const { components, props: pedProps } = data;
const playerPed = PlayerPedId();
const isMale = isPedMale(playerPed);

Expand All @@ -421,21 +421,47 @@ export async function wearClothes(data: PedAppearance, typeClothes: string): Pro
}

if (isMale) {
for (let i = 0; i < male.length; i++) {
const [componentId] = male[i];
for (let j = 0; j < components.length; j++) {
const { component_id, drawable, texture } = components[j];
// eslint-disable-next-line prettier/prettier
if (component_id === componentId) SetPedComponentVariation(playerPed, componentId, drawable, texture, 2);
if (male != undefined) {
for (let i = 0; i < male.length; i++) {
const [componentId] = male[i];
for (let j = 0; j < components.length; j++) {
const { component_id, drawable, texture } = components[j];
// eslint-disable-next-line prettier/prettier
if (component_id === componentId) SetPedComponentVariation(playerPed, componentId, drawable, texture, 2);
}
}
}
if (maleProps != undefined) {
// console.log("PUTTING PED PROPS BACK IN");
for (let i = 0; i < maleProps.length; i++) {
const [propId] = maleProps[i];
for (let j = 0; j < pedProps.length; j++) {
const { prop_id, drawable, texture } = pedProps[j];
// eslint-disable-next-line prettier/prettier
if (prop_id === propId) SetPedPropIndex(playerPed, propId, drawable, texture, false);
// console.log("SetPedPropIndex("+"playerPed"+", "+"propId:"+propId+", "+"drawable:"+drawable+", "+"texture:"+texture+", "+"false);");
}
}
}
} else {
for (let i = 0; i < female.length; i++) {
const [componentId] = female[i];
for (let j = 0; j < components.length; j++) {
const { component_id, drawable, texture } = components[j];
// eslint-disable-next-line prettier/prettier
if (component_id === componentId) SetPedComponentVariation(playerPed, componentId, drawable, texture, 2);
if (female != undefined) {
for (let i = 0; i < female.length; i++) {
const [componentId] = female[i];
for (let j = 0; j < components.length; j++) {
const { component_id, drawable, texture } = components[j];
// eslint-disable-next-line prettier/prettier
if (component_id === componentId) SetPedComponentVariation(playerPed, componentId, drawable, texture, 2);
}
}
}
if (femaleProps != undefined) {
for (let i = 0; i < femaleProps.length; i++) {
const [propId] = femaleProps[i];
for (let j = 0; j < pedProps.length; j++) {
const { prop_id, drawable, texture } = pedProps[j];
// eslint-disable-next-line prettier/prettier
if (prop_id === propId) SetPedPropIndex(playerPed, propId, drawable, texture, false);
}
}
}
}
Expand All @@ -446,7 +472,7 @@ export async function wearClothes(data: PedAppearance, typeClothes: string): Pro
export async function removeClothes(typeClothes: string): Promise<void> {
const { animations, props } = DATA_CLOTHES[typeClothes];
const { dict, anim, move, duration } = animations.off;
const { male, female } = props;
const { male, female, maleProps, femaleProps } = props;
const playerPed = PlayerPedId();
const isMale = isPedMale(playerPed);

Expand All @@ -456,14 +482,41 @@ export async function removeClothes(typeClothes: string): Promise<void> {
}

if (isMale) {
for (let i = 0; i < male.length; i++) {
const [componentId, drawableId] = male[i];
SetPedComponentVariation(playerPed, componentId, drawableId, 0, 2);
if (male != undefined) {
for (let i = 0; i < male.length; i++) {
const [componentId, drawableId] = male[i];
SetPedComponentVariation(playerPed, componentId, drawableId, 0, 2);
}
}
if (maleProps != undefined) {
// console.log("REMOVING PED PROPS");
for (let i = 0; i < maleProps.length; i++) {
const [propId, drawableId] = maleProps[i];
if (drawableId == -1) {
ClearPedProp(playerPed, propId)
} else {
SetPedPropIndex(playerPed, propId, drawableId, 0, false);
// console.log("SetPedPropIndex("+"playerPed"+", "+"propId:"+propId+", "+"drawableId:"+drawableId+", "+"texture:0"+", "+"false);");
};
}
}
} else {
for (let i = 0; i < female.length; i++) {
const [componentId, drawableId] = female[i];
SetPedComponentVariation(playerPed, componentId, drawableId, 0, 2);
if (female != undefined) {
for (let i = 0; i < female.length; i++) {
const [componentId, drawableId] = female[i];
SetPedComponentVariation(playerPed, componentId, drawableId, 0, 2);
}
}
if (femaleProps != undefined) {
for (let i = 0; i < femaleProps.length; i++) {
const [componentId, drawableId] = femaleProps[i];
if (drawableId == -1) {
ClearPedProp(playerPed, propId)
} else {
SetPedPropIndex(playerPed, propId, drawableId, 0, false);
// console.log("SetPedPropIndex("+"playerPed"+", "+"propId:"+propId+", "+"drawableId:"+drawableId+", "+"texture:0"+", "+"false);");
};
}
}
}
TaskPlayAnim(playerPed, dict, anim, 3.0, 3.0, duration, move, 0, false, false, false);
Expand Down
142 changes: 142 additions & 0 deletions locales/es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"modal": {
"save": {
"title": "Guardar personalización",
"description": "La belleza no lo es todo"
},
"exit": {
"title": "Salir sin guardar",
"description": "No se guardará ningún cambio"
},
"accept": "Sí",
"decline": "No"
},
"ped": {
"title": "Modelo de ped (sexo)",
"model": "Modelo"
},
"headBlend": {
"title": "Herencia",
"shape": {
"title": "Modelos de cara",
"firstOption": "Padre",
"secondOption": "Madre",
"mix": "Mezcla"
},
"skin": {
"title": "Tono de piel",
"firstOption": "Padre",
"secondOption": "Madre",
"mix": "Mezcla"
}
},
"faceFeatures": {
"title": "Rasgos faciales (cara)",
"nose": {
"title": "Nariz",
"width": "Anchura",
"height": "Altura",
"size": "Tamaño",
"boneHeight": "Altura ósea",
"boneTwist": "Torcedura ósea",
"peakHeight": "Altura de la punta"
},
"eyebrows": {
"title": "Cejas",
"height": "Altura",
"depth": "Profundidad"
},
"cheeks": {
"title": "Mejillas",
"boneHeight": "Altura ósea",
"boneWidth": "Anchura ósea",
"width": "Anchura"
},
"eyesAndMouth": {
"title": "Ojos y boca",
"eyesOpening": "Apertura de ojos",
"lipsThickness": "Grosor labial"
},
"jaw": {
"title": "Mandíbula",
"width": "Anchura",
"size": "Tamaño"
},
"chin": {
"title": "Barbilla",
"lowering": "Mentón",
"length": "Largo",
"size": "Tamaño",
"hole": "Hueco"
},
"neck": {
"title": "Cuello",
"thickness": "Anchura"
}
},
"headOverlays": {
"title": "Apariencia",
"hair": {
"title": "Cabello",
"style": "Estilo",
"color": "Color",
"highlight": "Resalte",
"fade": "Degradado"
},
"opacity": "Opacidad",
"style": "Estilo",
"color": "Color",
"secondColor": "Color de base",
"blemishes": "Imperfecciones",
"beard": "Barba",
"eyebrows": "Cejas",
"ageing": "Envejecimiento",
"makeUp": "Maquillaje",
"blush": "Rubor",
"complexion": "Cutis",
"sunDamage": "Quemaduras solares",
"lipstick": "Color labial",
"moleAndFreckles": "Lunares y pecas",
"chestHair": "Vello pectoral",
"bodyBlemishes": "Manchas corporales",
"eyeColor": "Color de ojos"
},
"components": {
"title": "Prendas",
"drawable": "Modelos",
"texture": "Variantes",
"mask": "Máscaras",
"upperBody": "Manos/brazos",
"lowerBody": "Piernas",
"bags": "Mochilas y paracaídas",
"shoes": "Zapatos",
"scarfAndChains": "Bufandas y cadenas",
"shirt": "Camisetas",
"bodyArmor": "Armadura corporal",
"decals": "Calcomanías",
"jackets": "Torsos"
},
"props": {
"title": "Accesorios",
"drawable": "Modelos",
"texture": "Variantes",
"hats": "Gorros, sombreros y cascos",
"glasses": "Gafas",
"ear": "Accesorios de oreja",
"watches": "Relojes",
"bracelets": "Brazaletes"
},
"tattoos": {
"title": "Tatuajes",
"items": {
"ZONE_TORSO": "Torso",
"ZONE_HEAD": "Cabeza",
"ZONE_LEFT_ARM": "Brazo izquierdo",
"ZONE_RIGHT_ARM": "Brazo derecho",
"ZONE_LEFT_LEG": "Pierna izquierdo",
"ZONE_RIGHT_LEG": "Pierna izquierda"
},
"apply": "Aplicar",
"delete": "Eliminar"
}
}
Loading