@@ -29,7 +29,8 @@ RegisterNetEvent("skinchanger:getSkin", function(cb)
29
29
end )
30
30
end )
31
31
32
- RegisterNetEvent (" skinchanger:loadSkin" , function (skin , cb )
32
+
33
+ local function LoadSkin (skin , cb )
33
34
if skin .model then
34
35
client .setPlayerAppearance (skin )
35
36
else -- add validation invisible when failed registration (maybe server restarted when apply skin)
@@ -42,16 +43,47 @@ RegisterNetEvent("skinchanger:loadSkin", function(skin, cb)
42
43
if cb ~= nil then
43
44
cb ()
44
45
end
46
+ end
47
+
48
+ RegisterNetEvent (" skinchanger:loadSkin" , function (skin , cb )
49
+ LoadSkin (skin , cb )
45
50
end )
46
51
47
- RegisterNetEvent ( " skinchanger:loadClothes " , function (_ , clothes )
52
+ local function loadClothes (_ , clothes )
48
53
local components = Framework .ConvertComponents (clothes , client .getPedComponents (cache .ped ))
49
54
local props = Framework .ConvertProps (clothes , client .getPedProps (cache .ped ))
50
55
51
56
client .setPedComponents (cache .ped , components )
52
57
client .setPedProps (cache .ped , props )
58
+ end
59
+
60
+ RegisterNetEvent (" skinchanger:loadClothes" , function (_ , clothes )
61
+ loadClothes (_ , clothes )
53
62
end )
54
63
55
64
RegisterNetEvent (" esx_skin:openSaveableMenu" , function (onSubmit , onCancel )
56
65
InitializeCharacter (Framework .GetGender (true ), onSubmit , onCancel )
57
66
end )
67
+
68
+ local function exportHandler (exportName , func )
69
+ AddEventHandler ((' __cfx_export_skinchanger_%s' ):format (exportName ), function (setCB )
70
+ setCB (func )
71
+ end )
72
+ end
73
+
74
+ exportHandler (" GetSkin" , function ()
75
+ while not Framework .PlayerData do
76
+ Wait (1000 )
77
+ end
78
+
79
+ local appearance = lib .callback .await (" illenium-appearance:server:getAppearance" , false )
80
+ return appearance
81
+ end )
82
+
83
+ exportHandler (" LoadSkin" , function (skin )
84
+ return LoadSkin (skin )
85
+ end )
86
+
87
+ exportHandler (" LoadClothes" , function (playerSkin , clothesSkin )
88
+ return loadClothes (playerSkin , clothesSkin )
89
+ end )
0 commit comments