Skip to content

Commit

Permalink
feat(item): add animation and save clothes when applied
Browse files Browse the repository at this point in the history
  • Loading branch information
ImXirvin committed Aug 21, 2024
1 parent b9c9cca commit cfbe41e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
21 changes: 19 additions & 2 deletions src/client/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from './appearance/setters';
import { closeMenu } from './menu';
import { TAppearance, TToggleData, TValue } from '@typings/appearance';
import { delay, getFrameworkID, triggerServerCallback, ped, updatePed } from '@utils';
import { delay, getFrameworkID, triggerServerCallback, ped, updatePed, Delay } from '@utils';
import { getAppearance, getTattooData } from './appearance/getters';
import TOGGLE_INDEXES from '@data/toggles';
import { TOutfitData } from '@typings/outfits';
Expand Down Expand Up @@ -186,6 +186,23 @@ RegisterNuiCallback(Receive.itemOutfit, async (data: {outfit: TOutfitData, label
cb(result);
});

onNet('bl_appearance:client:useOutfitItem', (outfit: TOutfitData) => {
const animDict = 'missmic4'
const anim = 'michael_tux_fidget'

async function playOutfitEmote() {
// while not HasAnimDictLoaded(e.Dict) do RequestAnimDict(e.Dict) Wait(100) end

while (!HasAnimDictLoaded(animDict)) {
RequestAnimDict(animDict);
await Delay(100);
}

TaskPlayAnim(ped, animDict, anim, 3.0, 3.0, 1200, 51, 0.0, false, false, false);
}


onNet('bl_appearance:client:useOutfitItem', async (outfit: TOutfitData) => {
await playOutfitEmote()
setPedClothes(ped, outfit);
triggerServerCallback('bl_appearance:server:saveClothes', getFrameworkID(), outfit)
})
3 changes: 0 additions & 3 deletions src/server/appearance/outfits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ if (!outfitItem) {
console.warn('bl_appearance: No outfit item configured, please set it in config.lua')
}

console.log("bl_appearance: Outfit item configured as " ,outfitItem)

onClientCallback('bl_appearance:server:itemOutfit', async (src, data) => {
const player = core.GetPlayer(src)
player.addItem(outfitItem, 1, data)
Expand All @@ -118,6 +116,5 @@ onClientCallback('bl_appearance:server:itemOutfit', async (src, data) => {
core.RegisterUsableItem(outfitItem, async (source: number, slot: number, metadata: {outfit: Outfit, label: string}) => {
const player = getPlayerData(source)
if (player?.removeItem(outfitItem, 1, slot))
console.log("bl_appearance: Outfit item used by " ,source)
emitNet('bl_appearance:client:useOutfitItem', source, metadata.outfit)
})

0 comments on commit cfbe41e

Please sign in to comment.