Skip to content

Commit

Permalink
feat: prepare for exports usage and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
snakewiz committed Feb 11, 2021
1 parent 36d4525 commit 7cd6eae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
5 changes: 1 addition & 4 deletions typescript/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ async function setPlayerAppearance(appearance: PedAppearance): Promise<void> {
emit('cfx-appearance:playerAppearanceChanged');
}

function setPedAppearance(ped: number, appearance: PedAppearance): void {
function setPedAppearance(ped: number, appearance: Omit<PedAppearance, 'model'>): void {
const { components, props, headBlend, faceFeatures, headOverlays, hair, eyeColor } = appearance;

setPedComponents(ped, components);
Expand Down Expand Up @@ -211,9 +211,6 @@ function init(): void {

Customization.loadModule();

SetNuiFocus(true, true);
SetNuiFocusKeepInput(false);

exports('setPlayerAppearance', setPlayerAppearance);
exports('setPedAppearance', setPedAppearance);
}
Expand Down
25 changes: 12 additions & 13 deletions typescript/src/client/modules/customization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const CAMERAS = {
point: { x: 0, y: 0, z: 0.6 },
},
body: {
coords: { x: 0, y: 2.2, z: 0.2 },
point: { x: 0, y: 0, z: 0 },
coords: { x: 0, y: 1.2, z: 0.2 },
point: { x: 0, y: 0, z: 0.2 },
},
bottom: {
coords: { x: 0, y: 0.98, z: -0.7 },
Expand All @@ -29,7 +29,7 @@ const CAMERAS = {
const OFFSETS = {
default: { x: 1.5, y: -1 },
head: { x: 0.7, y: -0.45 },
body: { x: 2.2, y: -1 },
body: { x: 1.2, y: -0.45 },
bottom: { x: 0.7, y: -0.45 },
};

Expand Down Expand Up @@ -377,8 +377,8 @@ function startPlayerCustomization(
): void;

function startPlayerCustomization(
paramOne: PedAppearance | (() => void),
paramTwo?: () => void,
paramOne: PedAppearance | ((appearance?: PedAppearance) => void),
paramTwo?: (appearance?: PedAppearance) => void,
): void {
let appearance;
let cb;
Expand All @@ -402,10 +402,15 @@ function startPlayerCustomization(

setCamera('default');

SetNuiFocus(true, true);
SetNuiFocusKeepInput(false);
RenderScriptCams(true, false, 0, true, true);
DisplayRadar(false);

TaskStandStill(PlayerPedId(), -1);
const playerPed = PlayerPedId();

ClearPedTasksImmediately(playerPed);
TaskStandStill(playerPed, -1);

const nuiMessage = {
type: 'appearance_display',
Expand Down Expand Up @@ -449,11 +454,5 @@ export function exitPlayerCustomization(appearance?: PedAppearance): void {
export function loadModule(): void {
registerNuiCallbacks();

startPlayerCustomization(appearance => {
if (appearance) {
console.log(appearance);
} else {
console.log('haha');
}
});
exports('startPlayerCustomization', startPlayerCustomization);
}
5 changes: 5 additions & 0 deletions typescript/src/client/modules/customization/nui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ export function registerNuiCallbacks(): void {
on('__cfx_nui:appearance_change_model', (model: string, cb: (arg: any) => void): void => {
setPlayerModel(model);

const playerPed = PlayerPedId();

ClearPedTasksImmediately(playerPed);
TaskStandStill(playerPed, -1);

const appearanceData = getPlayerPedAppearance(model);
const appearanceSettings = getAppearanceSettings(appearanceData);

Expand Down

0 comments on commit 7cd6eae

Please sign in to comment.