From f611e8d6ac00976d5970eb9fb458d687d0ef0dca Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Wed, 27 Sep 2023 04:53:42 +0200 Subject: [PATCH 1/7] refactor: core v2 stuff --- config.lua | 223 +++++++++++++++++++++++++++++++++------------- fxmanifest.lua | 5 +- source/client.lua | 119 +++++++++++-------------- source/server.lua | 30 +++++-- 4 files changed, 242 insertions(+), 135 deletions(-) diff --git a/config.lua b/config.lua index db4e866..ce13055 100644 --- a/config.lua +++ b/config.lua @@ -1,80 +1,183 @@ -config = { +Config = { { - notification = "Change clothes", - price = 200, - locations = { - vector3(428.52, -800.21, 29.49), - vector3(11.17, 6514.71, 31.88), - vector3(1696.09, 4829.34, 42.06), - vector3(-1107.77, 2708.58, 19.11), - vector3(617.49, 2765.64, 42.09), - vector3(1190.60, 2713.07, 38.22), - vector3(-3174.76, 1043.28, 20.86), - vector3(121.86, -224.50, 54.56), - vector3(-704.03, -151.89, 37.42), - vector3(-167.82, -299.17, 39.73), - vector3(-1189.72, -769.51, 17.32), - vector3(-828.93, -1074.71, 11.33), - vector3(72.98, -1399.06, 29.38) + price = 150, + text = "Change clothes", + blip = { + label = "Clothing store", + sprite = 73, + scale = 0.65, + color = 3 }, - options = { - ped = false, - headBlend = false, - faceFeatures = false, - headOverlays = false, + appearance = { components = true, props = true, - tattoos = false }, - blip = { - name = "Clothing store", - sprite = 73, + locations = { + { + model = `s_f_y_shop_low`, + worker = vec4(5.28, 6510.96, 31.88, 47.74), + change = vec4(11.10, 6513.75, 31.88, 44.84) + }, + { + model = `s_f_y_shop_low`, + worker = vec4(1695.41, 4822.61, 42.06, 99.90), + change = vec4(1696.50, 4828.62, 42.06, 96.94) + }, + { + model = `s_f_y_shop_low`, + worker = vec4(-1102.10, 2711.88, 19.11, 225.41), + change = vec4(-1107.79, 2709.55, 19.11, 224.57) + }, + { + model = `s_f_y_shop_mid`, + worker = vec4(613.02, 2762.18, 42.09, 275.86), + change = vec4(617.47, 2765.67, 42.09, 184.34) + }, + { + model = `s_f_y_shop_low`, + worker = vec4(1196.89, 2711.62, 38.22, 182.17), + change = vec4(1191.30, 2713.67, 38.22, 184.49) + }, + { + model = `s_f_y_shop_mid`, + worker = vec4(-3169.21, 1043.64, 20.86, 71.35), + change = vec4(-3175.01, 1042.75, 20.86, 334.28) + }, + { + model = `s_f_m_shop_high`, + worker = vec4(-708.97, -151.78, 37.42, 119.53), + change = vec4(-704.33, -151.64, 37.42, 190.64) + }, + { + model = `s_f_m_shop_high`, + worker = vec4(-164.97, -302.96, 39.73, 247.76), + change = vec4(-168.40, -299.32, 39.73, 293.06) + }, + { + model = `s_f_y_shop_mid`, + worker = vec4(127.09, -223.76, 54.56, 70.48), + change = vec4(121.85, -224.58, 54.56, 336.21) + }, + { + model = `s_f_y_shop_mid`, + worker = vec4(-1193.59, -766.76, 17.32, 218.92), + change = vec4(-1189.36, -769.34, 17.32, 128.69) + }, + { + model = `s_f_y_shop_low`, + worker = vec4(426.98, -806.47, 29.49, 90.35), + change = vec4(428.58, -800.78, 29.49, 91.14) + }, + { + model = `s_f_y_shop_low`, + worker = vec4(-822.87, -1072.20, 11.33, 209.86), + change = vec4(-828.94, -1073.56, 11.33, 212.48) + }, + { + model = `s_f_y_shop_low`, + worker = vec4(73.94, -1392.50, 29.38, 266.97), + change = vec4(72.54, -1398.72, 29.38, 272.27) + }, + { + model = `s_f_m_shop_high`, + worker = vec4(-1448.99, -238.10, 49.81, 49.79), + change = vec4(-1447.16, -242.78, 49.82, 100.09) + } } }, { - notification = "Get a tattoo", - price = 500, - locations = { - vector3(322.40, 180.36, 103.59), - vector3(1864.38, 3747.77, 33.03), - vector3(-3169.15, 1076.92, 20.83), - vector3(-1155.31, -1426.51, 4.95) + price = 300, + text = "Get a tattoo", + blip = { + label = "Tattoo parlour", + sprite = 75, + scale = 0.65, + color = 3 }, - options = { - ped = false, - headBlend = false, - faceFeatures = false, - headOverlays = false, - components = false, - props = false, + appearance = { tattoos = true }, - blip = { - name = "Tattoo parlour", - sprite = 75, + locations = { + { + model = `u_m_y_tattoo_01`, + worker = vec4(319.86, 180.97, 103.59, 250.84), + change = vec4(323.56, 179.92, 103.59, 73.69) + }, + { + model = `u_m_y_tattoo_01`, + worker = vec4(1862.49, 3748.46, 33.03, 33.74), + change = vec4(1864.79, 3747.05, 33.03, 30.42) + }, + { + model = `u_m_y_tattoo_01`, + worker = vec4(-3170.51, 1073.09, 20.83, 339.55), + change = vec4(-3168.97, 1077.23, 20.83, 161.56) + }, + { + model = `u_m_y_tattoo_01`, + worker = vec4(-1152.35, -1423.65, 4.95, 128.28), + change = vec4(-1155.59, -1426.40, 4.95, 307.28) + }, + { + model = `u_m_y_tattoo_01`, + worker = vec4(1324.36, -1650.08, 52.28, 129.97), + change = vec4(1320.97, -1653.27, 52.28, 313.14) + }, + { + model = `u_m_y_tattoo_01`, + worker = vec4(-292.12, 6199.61, 31.49, 222.04), + change = vec4(-294.41, 6200.52, 31.49, 221.79) + } } }, { - notification = "Get a haircut", price = 30, - locations = { - vector3(-33.49, -153.01, 57.08), - vector3(1930.95, 3730.91, 32.84), - vector3(1212.57, -472.71, 66.21), - vector3(136.92, -1707.87, 29.29) - }, - options = { - ped = false, - headBlend = false, - faceFeatures = false, - headOverlays = true, - components = false, - props = false, - tattoos = false - }, + text = "Get a haircut", blip = { - name = "Barber shop", + label = "Barber shop", sprite = 71, + scale = 0.65, + color = 3 + }, + appearance = { + headOverlays = true + }, + locations = { + { + model = `s_f_m_fembarber`, + worker = vec4(-277.96, 6230.53, 31.70, 76.00), + change = vec4(-277.82, 6226.55, 31.70, 314.70) + }, + { + model = `s_f_m_fembarber`, + worker = vec4(1930.73, 3728.03, 32.84, 233.51), + change = vec4(1931.89, 3732.03, 32.85, 120.92) + }, + { + model = `s_m_m_hairdress_01`, + worker = vec4(-821.90, -183.30, 37.57, 205.83), + change = vec4(-814.23, -182.45, 37.57, 211.02) + }, + { + model = `s_f_m_fembarber`, + worker = vec4(-30.67, -151.69, 57.08, 3.10), + change = vec4(-34.45, -153.40, 57.09, 251.27) + }, + { + model = `s_f_m_fembarber`, + worker = vec4(1211.45, -470.60, 66.21, 97.45), + change = vec4(1213.55, -474.17, 66.22, 348.66) + }, + { + model = `s_f_m_fembarber`, + worker = vec4(-1284.27, -1115.34, 6.99, 128.04), + change = vec4(-1281.34, -1118.29, 7.00, 358.13) + }, + { + model = `s_f_m_fembarber`, + worker = vec4(134.58, -1708.00, 29.29, 166.99), + change = vec4(138.70, -1707.60, 29.30, 48.86) + } } } } \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua index 0ad58fd..39a591e 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -2,13 +2,14 @@ author "Andyyy#7666" description "Clothing store for ND framework" -version "1.0.0" +version "2.0.0" fx_version "cerulean" game "gta5" lua54 "yes" shared_scripts { + "@ND_Core/init.lua", "@ox_lib/init.lua", "config.lua" } @@ -19,4 +20,4 @@ dependencies { "ND_Core", "fivem-appearance", "ox_lib" -} \ No newline at end of file +} diff --git a/source/client.lua b/source/client.lua index 0d5bc4a..48bc82c 100644 --- a/source/client.lua +++ b/source/client.lua @@ -1,73 +1,56 @@ -local ped -local pedCoords -local notified = false -local found = false +local function startChange(coords, options, i) + local ped = cache.ped + local oldAppearance = { + model = GetEntityModel(ped), + tattoos = exports["fivem-appearance"]:getPedTattoos(ped), + appearance = exports["fivem-appearance"]:getPedAppearance(ped) + } + SetEntityCoords(ped, coords.x, coords.y, coords.z-1.0) + SetEntityHeading(ped, coords.w) + Wait(250) + exports["fivem-appearance"]:startPlayerCustomization(function(appearance) + if not appearance then return end -CreateThread(function() - for _, store in pairs(config) do - if store.blip then - for _, location in pairs(store.locations) do - local blip = AddBlipForCoord(location) - SetBlipSprite(blip, store.blip.sprite) - SetBlipColour(blip, 3) - SetBlipScale(blip, 0.65) - SetBlipAsShortRange(blip, true) - BeginTextCommandSetBlipName("STRING") - AddTextComponentString(store.blip.name) - EndTextCommandSetBlipName(blip) - end - end - end - while true do - Wait(500) ped = PlayerPedId() - pedCoords = GetEntityCoords(ped) - end -end) + local clothing = { + model = GetEntityModel(ped), + tattoos = exports["fivem-appearance"]:getPedTattoos(ped), + appearance = exports["fivem-appearance"]:getPedAppearance(ped) + } -CreateThread(function() - local wait = 500 - while true do - Wait(wait) - for id, store in pairs(config) do - for _, location in pairs(store.locations) do - local dist = #(location - pedCoords) - if dist < 12.0 then - found = true - DrawMarker(1, location.x, location.y, location.z - 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.5, 2.5, 0.5, 40, 140, 255, 150, false, false, 2, false, nil, nil, false) - if dist < 1.2 then - if not notified then - notified = true - lib.showTextUI("[E] - " .. store.notification) - end - if IsControlJustPressed(0, 51) then - exports["fivem-appearance"]:startPlayerCustomization(function(appearance) - if appearance then - local clothing = { - model = GetEntityModel(ped), - tattoos = exports["fivem-appearance"]:getPedTattoos(ped), - appearance = exports["fivem-appearance"]:getPedAppearance(ped) - } - Wait(1000) - TriggerServerEvent("ND:updateClothes", clothing) - TriggerServerEvent("ND_ClothingStore:clothingPurchase", id) - end - end, store.options) - end - elseif notified then - notified = false - lib.hideTextUI() - end - break - end - end - if found then - found = false - wait = 0 - break - else - wait = 500 - end + if not lib.callback.await("ND_AppearanceShops:clothingPurchase", false, i, clothing) then + exports["fivem-appearance"]:setPlayerModel(oldAppearance.model) + ped = PlayerPedId() + exports["fivem-appearance"]:setPedTattoos(ped, oldAppearance.tattoos) + exports["fivem-appearance"]:setPedAppearance(ped, oldAppearance.appearance) end + end, options) +end + +for i=1, #Config do + local info = Config[i] + for j=1, #info.locations do + local location = info.locations[j] + NDCore.createAiPed({ + model = location.model, + coords = location.worker, + distance = 25.0, + blip = info.blip, + anim = { + dict = "anim@amb@casino@valet_scenario@pose_d@", + clip = "base_a_m_y_vinewood_01" + }, + options = { + { + name = "nd_core:appearanceShops", + icon = "fa-solid fa-bag-shopping", + label = info.text, + distance = 2.0, + onSelect = function(data) + startChange(location.change, info.appearance, i) + end + } + }, + }) end -end) \ No newline at end of file +end diff --git a/source/server.lua b/source/server.lua index 0d3a1b1..1b86267 100644 --- a/source/server.lua +++ b/source/server.lua @@ -1,8 +1,28 @@ -NDCore = exports["ND_Core"]:GetCoreObject() +lib.callback.register("ND_AppearanceShops:clothingPurchase", function(src, store, clothing) + local store = Config[store] + local player = NDCore.getPlayer(src) + if not store or not player then return end -NDCore.Functions.VersionChecker("ND_AppearanceShops", GetCurrentResourceName(), "https://github.com/ND-Framework/ND_AppearanceShops", "https://raw.githubusercontent.com/ND-Framework/ND_AppearanceShops/main/fxmanifest.lua") + local price = store.price + if not price then return true end + if not player.deductMoney("bank", price, store.blip.label) then + player.notify({ + title = store.blip.label, + description = ("Payment of $%d failed!"):format(price), + position = "bottom", + type = "error" + }) + return + end -RegisterNetEvent("ND_ClothingStore:clothingPurchase", function(id) - local player = source - NDCore.Functions.DeductMoney(config[id].price, player, "cash") + if clothing and type(clothing) ~= "table" then + player.setMetadata("clothing", clothing) + end + player.notify({ + title = store.blip.label, + description = ("Payment of $%d confirmed!"):format(price), + position = "bottom", + type = "success" + }) + return true end) From a26f5a04b96914718c94d7bbd5530e947627fa7b Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Thu, 28 Sep 2023 03:07:41 +0200 Subject: [PATCH 2/7] feat: player wardrobe --- source/client.lua | 145 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 133 insertions(+), 12 deletions(-) diff --git a/source/client.lua b/source/client.lua index 48bc82c..d717413 100644 --- a/source/client.lua +++ b/source/client.lua @@ -1,3 +1,64 @@ +local wardrobeId = "ND_AppearanceShops:wardrobe" +local wardrobeSelectedId = ("%s_selected"):format(wardrobeId) +local wardrobe = json.decode(GetResourceKvpString(wardrobeId)) or {} +local currentOpenWardrobe + +local function inputOutfitName() + local input = lib.inputDialog("Save current outfit", {"Outfit name:"}) + local name = input?[1] + if name and name ~= "" then + return name + end +end + +local function saveWardrobe(name) + if not name then return end + local appearance = exports["fivem-appearance"]:getPedAppearance(cache.ped) + appearance.hair = nil + appearance.headOverlays = nil + appearance.tattoos = nil + appearance.faceFeatures = nil + appearance.headBlend = nil + wardrobe[#wardrobe+1] = { + name = name, + appearance = appearance + } + return true +end + +local function getWardrobe() + local options = { + { + title = "Save current outfit", + icon = "fa-solid fa-floppy-disk", + onSelect = function() + saveWardrobe(inputOutfitName()) + end + } + } + for i=1, #wardrobe do + local info = wardrobe[i] + options[#options+1] = { + title = info.name, + arrow = true, + onSelect = function() + currentOpenWardrobe = i + lib.showContext(wardrobeSelectedId) + end + } + end + return options +end + +local function openWardrobe() + lib.registerContext({ + id = wardrobeId, + title = "Outfits", + options = getWardrobe() + }) + lib.showContext(wardrobeId) +end + local function startChange(coords, options, i) local ped = cache.ped local oldAppearance = { @@ -27,30 +88,90 @@ local function startChange(coords, options, i) end, options) end +lib.registerContext({ + id = wardrobeSelectedId, + title = "Outfits", + menu = wardrobeId, + options = { + { + title = "Wear", + icon = "fa-solid fa-shirt", + onSelect = function() + local selected = wardrobe[currentOpenWardrobe] + if not selected then return end + exports["fivem-appearance"]:setPedAppearance(cache.ped, selected.appearance) + end + }, + { + title = "Edit name", + icon = "fa-solid fa-pen-to-square", + onSelect = function() + local selected = wardrobe[currentOpenWardrobe] + if not selected then return end + selected.name = inputOutfitName() + end + }, + { + title = "Remove", + icon = "fa-solid fa-trash-can", + onSelect = function() + local selected = wardrobe[currentOpenWardrobe] + if not selected then return end + local alert = lib.alertDialog({ + header = "Remove outfit?", + content = ("Are you sure you'd like to remove %s?"):format(selected.name), + centered = true, + cancel = true + }) + print(alert) + if alert ~= "confirm" then return end + table.remove(wardrobe, currentOpenWardrobe) + end + } + } +}) + for i=1, #Config do local info = Config[i] for j=1, #info.locations do local location = info.locations[j] + local options = { + { + name = "nd_core:appearanceShops", + icon = "fa-solid fa-bag-shopping", + label = info.text, + distance = 2.0, + onSelect = function(data) + startChange(location.change, info.appearance, i) + end + } + } + if info.appearance?.components then + options[#options+1] = { + name = "nd_core:appearanceOutfit", + icon = "fa-solid fa-shirt", + label = "View outfits", + distance = 2.0, + onSelect = function(data) + openWardrobe() + end + } + end NDCore.createAiPed({ model = location.model, coords = location.worker, distance = 25.0, blip = info.blip, + options = options, anim = { dict = "anim@amb@casino@valet_scenario@pose_d@", clip = "base_a_m_y_vinewood_01" - }, - options = { - { - name = "nd_core:appearanceShops", - icon = "fa-solid fa-bag-shopping", - label = info.text, - distance = 2.0, - onSelect = function(data) - startChange(location.change, info.appearance, i) - end - } - }, + } }) end end + +AddEventHandler("onResourceStop", function(resource) + if resource ~= cache.resource then return end + SetResourceKvp(wardrobeId, json.encode(wardrobe)) +end) From b0604f5a7437e217092d7e2f214e949f7f0ab0da Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Sat, 14 Oct 2023 20:47:59 +0200 Subject: [PATCH 3/7] fix: nil name --- source/client.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/client.lua b/source/client.lua index d717413..e355dd9 100644 --- a/source/client.lua +++ b/source/client.lua @@ -108,7 +108,9 @@ lib.registerContext({ onSelect = function() local selected = wardrobe[currentOpenWardrobe] if not selected then return end - selected.name = inputOutfitName() + local name = inputOutfitName() + if not name then return end + selected.name = name end }, { @@ -123,7 +125,6 @@ lib.registerContext({ centered = true, cancel = true }) - print(alert) if alert ~= "confirm" then return end table.remove(wardrobe, currentOpenWardrobe) end From 592f3af95165996e2cbb28cd8aae1cc15acb7a67 Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Sat, 21 Oct 2023 21:41:01 +0200 Subject: [PATCH 4/7] perf: fivem-appearance exports --- source/client.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/source/client.lua b/source/client.lua index e355dd9..34434c8 100644 --- a/source/client.lua +++ b/source/client.lua @@ -2,6 +2,7 @@ local wardrobeId = "ND_AppearanceShops:wardrobe" local wardrobeSelectedId = ("%s_selected"):format(wardrobeId) local wardrobe = json.decode(GetResourceKvpString(wardrobeId)) or {} local currentOpenWardrobe +local fivemAppearance = exports["fivem-appearance"] local function inputOutfitName() local input = lib.inputDialog("Save current outfit", {"Outfit name:"}) @@ -13,7 +14,7 @@ end local function saveWardrobe(name) if not name then return end - local appearance = exports["fivem-appearance"]:getPedAppearance(cache.ped) + local appearance = fivemAppearance:getPedAppearance(cache.ped) appearance.hair = nil appearance.headOverlays = nil appearance.tattoos = nil @@ -63,27 +64,27 @@ local function startChange(coords, options, i) local ped = cache.ped local oldAppearance = { model = GetEntityModel(ped), - tattoos = exports["fivem-appearance"]:getPedTattoos(ped), - appearance = exports["fivem-appearance"]:getPedAppearance(ped) + tattoos = fivemAppearance:getPedTattoos(ped), + appearance = fivemAppearance:getPedAppearance(ped) } SetEntityCoords(ped, coords.x, coords.y, coords.z-1.0) SetEntityHeading(ped, coords.w) Wait(250) - exports["fivem-appearance"]:startPlayerCustomization(function(appearance) + fivemAppearance:startPlayerCustomization(function(appearance) if not appearance then return end ped = PlayerPedId() local clothing = { model = GetEntityModel(ped), - tattoos = exports["fivem-appearance"]:getPedTattoos(ped), - appearance = exports["fivem-appearance"]:getPedAppearance(ped) + tattoos = fivemAppearance:getPedTattoos(ped), + appearance = fivemAppearance:getPedAppearance(ped) } if not lib.callback.await("ND_AppearanceShops:clothingPurchase", false, i, clothing) then - exports["fivem-appearance"]:setPlayerModel(oldAppearance.model) + fivemAppearance:setPlayerModel(oldAppearance.model) ped = PlayerPedId() - exports["fivem-appearance"]:setPedTattoos(ped, oldAppearance.tattoos) - exports["fivem-appearance"]:setPedAppearance(ped, oldAppearance.appearance) + fivemAppearance:setPedTattoos(ped, oldAppearance.tattoos) + fivemAppearance:setPedAppearance(ped, oldAppearance.appearance) end end, options) end @@ -99,7 +100,7 @@ lib.registerContext({ onSelect = function() local selected = wardrobe[currentOpenWardrobe] if not selected then return end - exports["fivem-appearance"]:setPedAppearance(cache.ped, selected.appearance) + fivemAppearance:setPedAppearance(cache.ped, selected.appearance) end }, { From 5a5109fb11061972ef21cee0e596c47a585cb59c Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Sat, 21 Oct 2023 21:41:23 +0200 Subject: [PATCH 5/7] feat: check for player model --- source/client.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/client.lua b/source/client.lua index 34434c8..1746e70 100644 --- a/source/client.lua +++ b/source/client.lua @@ -100,6 +100,13 @@ lib.registerContext({ onSelect = function() local selected = wardrobe[currentOpenWardrobe] if not selected then return end + if selected.appearance.model ~= GetEntityModel(cache.ped) then + return lib.notify({ + title = "Incorrect player model", + description = "This saved outfit is not for the current player model", + type = "error" + }) + end fivemAppearance:setPedAppearance(cache.ped, selected.appearance) end }, From 49499c8eee7bbe1558daa64c117e9005974b0784 Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Fri, 1 Dec 2023 15:55:31 +0100 Subject: [PATCH 6/7] feat: create clothing store & open wardrobe exports --- source/client.lua | 94 ++++++++++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 37 deletions(-) diff --git a/source/client.lua b/source/client.lua index 1746e70..2c90e6c 100644 --- a/source/client.lua +++ b/source/client.lua @@ -89,6 +89,59 @@ local function startChange(coords, options, i) end, options) end +local function getStoreNumber(store) + for i=1, #Config do + if store == Config[i] then + return i + end + end + + local number = #Config+1 + Config[number] = store + return number +end + +local function createClothingStore(info) + local storeNumber = getStoreNumber(info) + for i=1, #info.locations do + local location = info.locations[i] + local options = { + { + name = "nd_core:appearanceShops", + icon = "fa-solid fa-bag-shopping", + label = info.text, + distance = 2.0, + onSelect = function(data) + startChange(location.change, info.appearance, storeNumber) + end + } + } + if info.appearance?.components then + options[#options+1] = { + name = "nd_core:appearanceOutfit", + icon = "fa-solid fa-shirt", + label = "View outfits", + distance = 2.0, + onSelect = function(data) + openWardrobe() + end + } + end + NDCore.createAiPed({ + resource = GetInvokingResource(), + model = location.model, + coords = location.worker, + distance = 25.0, + blip = info.blip, + options = options, + anim = { + dict = "anim@amb@casino@valet_scenario@pose_d@", + clip = "base_a_m_y_vinewood_01" + } + }) + end +end + lib.registerContext({ id = wardrobeSelectedId, title = "Outfits", @@ -141,46 +194,13 @@ lib.registerContext({ }) for i=1, #Config do - local info = Config[i] - for j=1, #info.locations do - local location = info.locations[j] - local options = { - { - name = "nd_core:appearanceShops", - icon = "fa-solid fa-bag-shopping", - label = info.text, - distance = 2.0, - onSelect = function(data) - startChange(location.change, info.appearance, i) - end - } - } - if info.appearance?.components then - options[#options+1] = { - name = "nd_core:appearanceOutfit", - icon = "fa-solid fa-shirt", - label = "View outfits", - distance = 2.0, - onSelect = function(data) - openWardrobe() - end - } - end - NDCore.createAiPed({ - model = location.model, - coords = location.worker, - distance = 25.0, - blip = info.blip, - options = options, - anim = { - dict = "anim@amb@casino@valet_scenario@pose_d@", - clip = "base_a_m_y_vinewood_01" - } - }) - end + createClothingStore(Config[i]) end AddEventHandler("onResourceStop", function(resource) if resource ~= cache.resource then return end SetResourceKvp(wardrobeId, json.encode(wardrobe)) end) + +exports("openWardrobe", openWardrobe) +exports("createClothingStore", createClothingStore) From 537cd94a5be41c5e74d9d82fd807bfb87bbf840b Mon Sep 17 00:00:00 2001 From: Andyyy7666 <86536434+Andyyy7666@users.noreply.github.com> Date: Fri, 1 Dec 2023 16:03:38 +0100 Subject: [PATCH 7/7] fix: player model check --- source/client.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/client.lua b/source/client.lua index 2c90e6c..2754969 100644 --- a/source/client.lua +++ b/source/client.lua @@ -153,7 +153,7 @@ lib.registerContext({ onSelect = function() local selected = wardrobe[currentOpenWardrobe] if not selected then return end - if selected.appearance.model ~= GetEntityModel(cache.ped) then + if GetHashKey(selected.appearance.model) ~= GetEntityModel(cache.ped) then return lib.notify({ title = "Incorrect player model", description = "This saved outfit is not for the current player model",