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

feat: added the option to change the fade hair manually. #50

Merged
merged 10 commits into from
Jun 6, 2022
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ This is a development resource, if you don't use the exports the resource itself
Since this is a client script, you will need to use **setr** to set these convars.

- **fivem-appearance:locale**: the name of one file inside `locales/`, default **en**, choose the locale file for the customization interface.

- **fivem-appearance:automaticFade**: If set to 0, hair fade could be selected by the player, otherwise it will be automatic. default **1**.
config.cfg example:

```cfg
setr fivem-appearance:locale "en"
setr fivem-appearance:automaticFade 1
ensure fivem-appearance
```

Expand Down Expand Up @@ -99,6 +100,7 @@ RegisterCommand('customization', function()
headOverlays = true,
components = true,
props = true,
tattoos = true
}

exports['fivem-appearance']:startPlayerCustomization(function (appearance)
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ game { "gta5" }
author 'snakewiz'
description 'A flexible player customization script for FiveM.'
repository 'https://github.com/pedr0fontoura/fivem-appearance'
version '1.2.2'
version '1.3.0'

client_script 'game/dist/index.js'

Expand Down
19 changes: 10 additions & 9 deletions game/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Customization, { getPedTattoos, setPedTattoos } from './modules/customiza
const exp = (global as any).exports;

const GET_PED_HEAD_BLEND_DATA = '0x2746bd9d88c5c5d0';
const AUTOMATIC_FADE = Boolean(Number(GetConvar('fivem-appearance:automaticFade', '1')));

export const totalTattoos: TattooList = JSON.parse(
LoadResourceFile(GetCurrentResourceName(), 'tattoos.json'),
Expand Down Expand Up @@ -264,14 +265,16 @@ export function setPedHair(ped: number, hair: PedHair): void {

SetPedHairColor(ped, color, highlight);

const hairDecoration = getPedHairDecoration(ped, style);
if (AUTOMATIC_FADE) {
const hairDecoration = getPedHairDecoration(ped, style);

ClearPedDecorations(ped);
ClearPedDecorations(ped);

if (hairDecoration) {
const { collection, overlay } = hairDecoration;
if (hairDecoration) {
const { collection, overlay } = hairDecoration;

AddPedDecorationFromHashes(ped, GetHashKey(collection), GetHashKey(overlay));
AddPedDecorationFromHashes(ped, GetHashKey(collection), GetHashKey(overlay));
}
}
}

Expand Down Expand Up @@ -405,7 +408,7 @@ function setPedAppearance(ped: number, appearance: Omit<PedAppearance, 'model'>)
}
}

function init(): void {
(() => {
Customization.loadModule();

exp('getPedModel', getPedModel);
Expand All @@ -431,6 +434,4 @@ function init(): void {
exp('setPedTattoos', setPedTattoos);
exp('setPlayerAppearance', setPlayerAppearance);
exp('setPedAppearance', setPedAppearance);
}

init();
})();
1 change: 1 addition & 0 deletions game/src/client/modules/customization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ function startPlayerCustomization(
playerAppearance = getPedAppearance(playerPed);

callback = cb;
_config.automaticFade = Boolean(Number(GetConvar('fivem-appearance:automaticFade', '1')));
config = _config;

playerCoords = arrayToVector3(GetEntityCoords(playerPed, true));
Expand Down
1 change: 1 addition & 0 deletions game/src/client/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ interface CustomizationConfig {
components: boolean;
props: boolean;
tattoos: boolean;
automaticFade: boolean;
}

interface CameraState {
Expand Down
3 changes: 2 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
"title": "Hair",
"style": "Style",
"color": "Color",
"highlight": "Highlight"
"highlight": "Highlight",
"fade": "Fade"
},
"opacity": "Opacity",
"style": "Style",
Expand Down
3 changes: 2 additions & 1 deletion locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
"title": "Cabelo",
"style": "Estilo",
"color": "Cor",
"highlight": "Reflexo"
"highlight": "Reflexo",
"fade": "Desvaneça"
},
"opacity": "Opacidade",
"style": "Estilo",
Expand Down
Loading