Auto-sync 2026-04-14 23:50
This commit is contained in:
parent
fe15dd2659
commit
fcd7f26797
@ -685,3 +685,107 @@ function ClothingData()
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- ══════════════════════════════════════════════════════════════
|
||||
-- Gespeicherte Outfits: Client-seitige Handler
|
||||
-- ══════════════════════════════════════════════════════════════
|
||||
|
||||
-- Kategorien vom Server empfangen → ans NUI schicken
|
||||
RegisterNetEvent('codem-appearance:ReceiveClothingCategories')
|
||||
AddEventHandler('codem-appearance:ReceiveClothingCategories', function(data)
|
||||
SendNUIMessage({ action = "SET_CLOTHING_CATEGORIES", payload = data })
|
||||
end)
|
||||
|
||||
-- Gespeicherte Outfits vom Server empfangen → ans NUI schicken
|
||||
RegisterNetEvent('codem-appearance:ReceiveSavedClothings')
|
||||
AddEventHandler('codem-appearance:ReceiveSavedClothings', function(data)
|
||||
SendNUIMessage({ action = "SET_SAVED_CLOTHINGS", payload = data })
|
||||
end)
|
||||
|
||||
-- NUI: Outfit anziehen (JETZT ANZIEHEN Button)
|
||||
RegisterNUICallback('wearClothing', function(data, cb)
|
||||
if not data or not data.skin then cb({}); return end
|
||||
local skin = type(data.skin) == 'string' and json.decode(data.skin) or data.skin
|
||||
if skin then
|
||||
-- Skin auf den Charakter anwenden
|
||||
TriggerEvent('codem-appearance:setPlayerSkin', skin)
|
||||
-- Auch per Export falls verfügbar
|
||||
if GetResourceState('codem-appearance') == 'started' then
|
||||
exports['codem-appearance']:SetPlayerSkin(skin)
|
||||
end
|
||||
end
|
||||
cb({})
|
||||
end)
|
||||
|
||||
-- NUI: Gespeichertes Outfit löschen
|
||||
RegisterNUICallback('DeleteSavedClothing', function(data, cb)
|
||||
if not data or not data.id then cb({}); return end
|
||||
TriggerServerEvent('codem-appearance:DeleteSavedClothing', data.id)
|
||||
cb({})
|
||||
end)
|
||||
|
||||
-- NUI: Kategorie löschen
|
||||
RegisterNUICallback('DeleteClothingCategory', function(data, cb)
|
||||
if not data or not data.id then cb({}); return end
|
||||
TriggerServerEvent('codem-appearance:DeleteClothingCategory', data.id)
|
||||
cb({})
|
||||
end)
|
||||
|
||||
-- NUI: Neue Kategorie erstellen
|
||||
RegisterNUICallback('CreateClothingCategory', function(data, cb)
|
||||
if not data or not data.name then cb({}); return end
|
||||
TriggerServerEvent('codem-appearance:CreateClothingCategory', data.name)
|
||||
cb({})
|
||||
end)
|
||||
|
||||
-- Skin anwenden (von wearClothing aufgerufen)
|
||||
RegisterNetEvent('codem-appearance:setPlayerSkin')
|
||||
AddEventHandler('codem-appearance:setPlayerSkin', function(skin)
|
||||
local ped = PlayerPedId()
|
||||
if not skin then return end
|
||||
|
||||
-- Kleidung anwenden
|
||||
local components = {
|
||||
{ id = 1, key = 'mask_1', tex = 'mask_2' },
|
||||
{ id = 3, key = 'arms', tex = 'arms_2' },
|
||||
{ id = 4, key = 'pants_1', tex = 'pants_2' },
|
||||
{ id = 5, key = 'parachute_1', tex = 'parachute_2' },
|
||||
{ id = 6, key = 'shoes_1', tex = 'shoes_2' },
|
||||
{ id = 7, key = 'accessory_1', tex = 'accessory_2' },
|
||||
{ id = 8, key = 'undershirt_1', tex = 'undershirt_2' },
|
||||
{ id = 9, key = 'bproof_1', tex = 'bproof_2' },
|
||||
{ id = 10, key = 'torso_1', tex = 'torso_2' },
|
||||
{ id = 11, key = 'tshirt_1', tex = 'tshirt_2' },
|
||||
}
|
||||
|
||||
for _, comp in ipairs(components) do
|
||||
if skin[comp.key] ~= nil then
|
||||
SetPedComponentVariation(ped, comp.id,
|
||||
tonumber(skin[comp.key]) or 0,
|
||||
tonumber(skin[comp.tex] or 0) or 0,
|
||||
2)
|
||||
end
|
||||
end
|
||||
|
||||
-- Props anwenden
|
||||
local props = {
|
||||
{ id = 0, key = 'glasses_1', tex = 'glasses_2' },
|
||||
{ id = 1, key = 'helmet_1', tex = 'helmet_2' },
|
||||
{ id = 2, key = 'ears_1', tex = 'ears_2' },
|
||||
{ id = 6, key = 'watches_1', tex = 'watches_2' },
|
||||
{ id = 7, key = 'bracelets_1', tex = 'bracelets_2' },
|
||||
}
|
||||
|
||||
for _, prop in ipairs(props) do
|
||||
if skin[prop.key] ~= nil then
|
||||
local val = tonumber(skin[prop.key])
|
||||
if val and val >= 0 then
|
||||
SetPedPropIndex(ped, prop.id, val,
|
||||
tonumber(skin[prop.tex] or 0) or 0, true)
|
||||
else
|
||||
ClearPedProp(ped, prop.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
@ -339,3 +339,109 @@ CreateThread(function()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
-- ══════════════════════════════════════════════════════════════
|
||||
-- Gespeicherte Outfits: Laden, Speichern, Löschen
|
||||
-- Diese Handlers fehlten und verursachten den "JETZT ANZIEHEN" Bug
|
||||
-- ══════════════════════════════════════════════════════════════
|
||||
|
||||
-- Kleidungskategorien laden
|
||||
RegisterServerEvent('codem-appearance:LoadClothingCategories')
|
||||
AddEventHandler('codem-appearance:LoadClothingCategories', function()
|
||||
local src = source
|
||||
local identifier = GetIdentifier(src)
|
||||
local result = MySQL.query.await(
|
||||
'SELECT * FROM codem_clothing_categories WHERE identifier = ?',
|
||||
{ identifier }
|
||||
)
|
||||
TriggerClientEvent('codem-appearance:ReceiveClothingCategories', src, result or {})
|
||||
end)
|
||||
|
||||
-- Gespeicherte Outfits laden
|
||||
RegisterServerEvent('codem-appearance:LoadSavedClothings')
|
||||
AddEventHandler('codem-appearance:LoadSavedClothings', function()
|
||||
local src = source
|
||||
local identifier = GetIdentifier(src)
|
||||
local result = MySQL.query.await(
|
||||
'SELECT * FROM codem_saved_clothings WHERE identifier = ?',
|
||||
{ identifier }
|
||||
)
|
||||
if result then
|
||||
for k, v in pairs(result) do
|
||||
if type(v.skin) == 'string' then
|
||||
result[k].skin = json.decode(v.skin) or {}
|
||||
end
|
||||
end
|
||||
end
|
||||
TriggerClientEvent('codem-appearance:ReceiveSavedClothings', src, result or {})
|
||||
end)
|
||||
|
||||
-- Outfit speichern
|
||||
RegisterServerEvent('codem-appearance:SaveClothing')
|
||||
AddEventHandler('codem-appearance:SaveClothing', function(name, skin, categoryId)
|
||||
local src = source
|
||||
local identifier = GetIdentifier(src)
|
||||
MySQL.insert(
|
||||
'INSERT INTO codem_saved_clothings (identifier, name, skin, categoryId) VALUES (?, ?, ?, ?)',
|
||||
{ identifier, name, json.encode(skin), categoryId or nil }
|
||||
)
|
||||
-- Sofort aktualisierte Liste zurückschicken
|
||||
local result = MySQL.query.await('SELECT * FROM codem_saved_clothings WHERE identifier = ?', { identifier })
|
||||
if result then
|
||||
for k, v in pairs(result) do
|
||||
if type(v.skin) == 'string' then result[k].skin = json.decode(v.skin) or {} end
|
||||
end
|
||||
end
|
||||
TriggerClientEvent('codem-appearance:ReceiveSavedClothings', src, result or {})
|
||||
end)
|
||||
|
||||
-- Einzelnes Outfit löschen
|
||||
RegisterServerEvent('codem-appearance:DeleteSavedClothing')
|
||||
AddEventHandler('codem-appearance:DeleteSavedClothing', function(id)
|
||||
local src = source
|
||||
local identifier = GetIdentifier(src)
|
||||
MySQL.update(
|
||||
'DELETE FROM codem_saved_clothings WHERE id = ? AND identifier = ?',
|
||||
{ id, identifier }
|
||||
)
|
||||
local result = MySQL.query.await('SELECT * FROM codem_saved_clothings WHERE identifier = ?', { identifier })
|
||||
if result then
|
||||
for k, v in pairs(result) do
|
||||
if type(v.skin) == 'string' then result[k].skin = json.decode(v.skin) or {} end
|
||||
end
|
||||
end
|
||||
TriggerClientEvent('codem-appearance:ReceiveSavedClothings', src, result or {})
|
||||
end)
|
||||
|
||||
-- Kategorie löschen (inkl. alle Outfits darin)
|
||||
RegisterServerEvent('codem-appearance:DeleteClothingCategory')
|
||||
AddEventHandler('codem-appearance:DeleteClothingCategory', function(id)
|
||||
local src = source
|
||||
local identifier = GetIdentifier(src)
|
||||
MySQL.update('DELETE FROM codem_clothing_categories WHERE id = ? AND identifier = ?', { id, identifier })
|
||||
MySQL.update('DELETE FROM codem_saved_clothings WHERE categoryId = ? AND identifier = ?', { id, identifier })
|
||||
-- Aktualisierte Listen zurückschicken
|
||||
local cats = MySQL.query.await('SELECT * FROM codem_clothing_categories WHERE identifier = ?', { identifier })
|
||||
local clothings = MySQL.query.await('SELECT * FROM codem_saved_clothings WHERE identifier = ?', { identifier })
|
||||
if clothings then
|
||||
for k, v in pairs(clothings) do
|
||||
if type(v.skin) == 'string' then clothings[k].skin = json.decode(v.skin) or {} end
|
||||
end
|
||||
end
|
||||
TriggerClientEvent('codem-appearance:ReceiveClothingCategories', src, cats or {})
|
||||
TriggerClientEvent('codem-appearance:ReceiveSavedClothings', src, clothings or {})
|
||||
end)
|
||||
|
||||
-- Neue Kategorie erstellen
|
||||
RegisterServerEvent('codem-appearance:CreateClothingCategory')
|
||||
AddEventHandler('codem-appearance:CreateClothingCategory', function(name)
|
||||
local src = source
|
||||
local identifier = GetIdentifier(src)
|
||||
MySQL.insert(
|
||||
'INSERT INTO codem_clothing_categories (identifier, name) VALUES (?, ?)',
|
||||
{ identifier, name }
|
||||
)
|
||||
local result = MySQL.query.await('SELECT * FROM codem_clothing_categories WHERE identifier = ?', { identifier })
|
||||
TriggerClientEvent('codem-appearance:ReceiveClothingCategories', src, result or {})
|
||||
end)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user