-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheup_ui.lua
More file actions
200 lines (181 loc) · 6.88 KB
/
eup_ui.lua
File metadata and controls
200 lines (181 loc) · 6.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
Outfits = {}
local function loadOutfitData()
Outfits = LoadResourceFile(GetCurrentResourceName(), GetResourceMetadata(GetCurrentResourceName(), 'uniform_file'))
if Outfits ~= nil then
Outfits = json.decode(Outfits)
else
Outfits = {}
end
print('Loaded data!')
end
loadOutfitData()
function string.split(inputstr, sep)
if sep == nil then sep = "%s" end
local t = {};
i = 1
for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
t[i] = str
i = i + 1
end
return t
end
local function convertInput(input)
local t1 = tonumber(string.split(input, ":")[1]) - 1
local t2 = tonumber(string.split(input, ":")[2]) - 1
return ({t1, t2})
end
local function ShowInfo(text)
SetTextComponentFormat("STRING")
AddTextComponentString(text)
DisplayHelpTextFromStringLabel(0, 0, 0, -1)
end
local function SetPlayerOutfit(outfit)
local ped = PlayerPedId()
if (outfit.Gender == "Male" and GetEntityModel(ped) ==
GetHashKey("mp_m_freemode_01")) or
(outfit.Gender == "Female" and GetEntityModel(ped) ==
GetHashKey("mp_f_freemode_01")) then
SetPedComponentVariation(ped, 1, convertInput(outfit.Mask)[1],
convertInput(outfit.Mask)[2], 0)
SetPedComponentVariation(ped, 3, convertInput(outfit.UpperSkin)[1],
convertInput(outfit.UpperSkin)[2], 0)
SetPedComponentVariation(ped, 4, convertInput(outfit.Pants)[1],
convertInput(outfit.Pants)[2], 0)
SetPedComponentVariation(ped, 5, convertInput(outfit.Parachute)[1],
convertInput(outfit.Parachute)[2], 0)
SetPedComponentVariation(ped, 6, convertInput(outfit.Shoes)[1],
convertInput(outfit.Shoes)[2], 0)
SetPedComponentVariation(ped, 7, convertInput(outfit.Accessories)[1],
convertInput(outfit.Accessories)[2], 0)
SetPedComponentVariation(ped, 8, convertInput(outfit.UnderCoat)[1],
convertInput(outfit.UnderCoat)[2], 0)
SetPedComponentVariation(ped, 9, convertInput(outfit.Armor)[1],
convertInput(outfit.Armor)[2], 0)
SetPedComponentVariation(ped, 10, convertInput(outfit.Decal)[1],
convertInput(outfit.Decal)[2], 0)
SetPedComponentVariation(ped, 11, convertInput(outfit.Top)[1],
convertInput(outfit.Top)[2], 0)
if convertInput(outfit.Hat)[1] == -1 then
ClearPedProp(ped, 0)
else
SetPedPropIndex(ped, 0, convertInput(outfit.Hat)[1],
convertInput(outfit.Hat)[2], true)
end
if convertInput(outfit.Glasses)[1] == -1 then
ClearPedProp(ped, 1)
else
SetPedPropIndex(ped, 1, convertInput(outfit.Glasses)[1],
convertInput(outfit.Glasses)[2], true)
end
if convertInput(outfit.Watch)[1] == -1 then
ClearPedProp(ped, 6)
else
SetPedPropIndex(ped, 6, convertInput(outfit.Watch)[1],
convertInput(outfit.Watch)[2], true)
end
end
end
local categoryOutfitsM = {}
local categoryOutfitsF = {}
for _, outfit in ipairs(Outfits) do
found = false
if outfit.Gender == "Male" then
for i, j in ipairs(categoryOutfitsM) do
if categoryOutfitsM[i][1] == outfit.Category2 then
table.insert(categoryOutfitsM[i], outfit)
found = true
end
end
if found == false then
table.insert(categoryOutfitsM, {outfit.Category2, outfit})
end
else
for i, j in ipairs(categoryOutfitsF) do
if categoryOutfitsF[i][1] == outfit.Category2 then
table.insert(categoryOutfitsF[i], outfit)
found = true
end
end
if found == false then
table.insert(categoryOutfitsF, {outfit.Category2, outfit})
end
end
end
OpenMaleOutfitMenu = function()
local Man = RageUI.CreateMenu('EUP', 'Catégorie :')
local Category = RageUI.CreateSubMenu(Man, "Catégorie", "Liste : ")
local itemList = {}
RageUI.Visible(Man, not RageUI.Visible(Man))
while Man do
Wait(1)
RageUI.IsVisible(Man, function()
for i, list in pairs(categoryOutfitsM) do
RageUI.Item.Button(list[1], nil, {RightLabel = '→'}, true, {
onSelected = function()
itemList = {}
itemList = list
end
}, Category)
end
end)
RageUI.IsVisible(Category, function()
for id, outfit in ipairs(itemList) do
if id ~= 1 then
RageUI.Item.Button(outfit.Name, nil, {RightLabel = '→'},
true, {
onSelected = function()
SetPlayerOutfit(outfit)
end
})
end
end
end)
if not RageUI.Visible(Man) and not RageUI.Visible(Category) then
Man = RMenu:DeleteType('Man', true)
end
end
end
OpenFemaleOutfitMenu = function()
local Female = RageUI.CreateMenu('EUP', 'Catégories : ')
local Category = RageUI.CreateSubMenu(Female, "Catégorie", "Liste : ")
local itemList = {}
RageUI.Visible(Female, not RageUI.Visible(Female))
while Female do
Wait(1)
RageUI.IsVisible(Female, function()
for i, list in pairs(categoryOutfitsF) do
RageUI.Item.Button(list[1], nil, {RightLabel = '→'}, true, {
onSelected = function()
itemList = {}
itemList = list
end
}, Category)
end
end)
RageUI.IsVisible(Category, function()
for id, outfit in ipairs(itemList) do
if id ~= 1 then
RageUI.Item.Button(outfit.Name, nil, {RightLabel = '→'},
true, {
onSelected = function()
SetPlayerOutfit(outfit)
end
})
end
end
end)
if not RageUI.Visible(Female) and not RageUI.Visible(Category) then
Female = RMenu:DeleteType('Female', true)
end
end
end
RegisterCommand('eup', function()
local ped = PlayerPedId()
if GetEntityModel(ped) == GetHashKey("mp_m_freemode_01") then
OpenMaleOutfitMenu()
elseif GetEntityModel(ped) == GetHashKey("mp_f_freemode_01") then
OpenFemaleOutfitMenu()
else
ShowInfo("You need to use an MP ped with EUP")
end
end, false)