From 7cd6eae5996c57c93c7b2978510642fbe6eafac1 Mon Sep 17 00:00:00 2001 From: SnakeWiz Date: Thu, 11 Feb 2021 18:50:08 -0300 Subject: [PATCH] feat: prepare for exports usage and minor changes --- typescript/src/client/index.ts | 5 +--- .../src/client/modules/customization/index.ts | 25 +++++++++---------- .../src/client/modules/customization/nui.ts | 5 ++++ 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/typescript/src/client/index.ts b/typescript/src/client/index.ts index 5bd4a1c..5fe2f3e 100644 --- a/typescript/src/client/index.ts +++ b/typescript/src/client/index.ts @@ -178,7 +178,7 @@ async function setPlayerAppearance(appearance: PedAppearance): Promise { emit('cfx-appearance:playerAppearanceChanged'); } -function setPedAppearance(ped: number, appearance: PedAppearance): void { +function setPedAppearance(ped: number, appearance: Omit): void { const { components, props, headBlend, faceFeatures, headOverlays, hair, eyeColor } = appearance; setPedComponents(ped, components); @@ -211,9 +211,6 @@ function init(): void { Customization.loadModule(); - SetNuiFocus(true, true); - SetNuiFocusKeepInput(false); - exports('setPlayerAppearance', setPlayerAppearance); exports('setPedAppearance', setPedAppearance); } diff --git a/typescript/src/client/modules/customization/index.ts b/typescript/src/client/modules/customization/index.ts index 11cf4d3..c06eb46 100644 --- a/typescript/src/client/modules/customization/index.ts +++ b/typescript/src/client/modules/customization/index.ts @@ -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 }, @@ -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 }, }; @@ -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; @@ -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', @@ -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); } diff --git a/typescript/src/client/modules/customization/nui.ts b/typescript/src/client/modules/customization/nui.ts index 19e705e..2bf9e5a 100644 --- a/typescript/src/client/modules/customization/nui.ts +++ b/typescript/src/client/modules/customization/nui.ts @@ -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);