-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
402 lines (370 loc) · 11.6 KB
/
client.lua
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
ESX = nil
Character = {}
ClotheList = {}
local enable = true
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
GenerateClotheList()
end)
-- Apparence modification
local pedModel = 'mp_m_freemode_01'
function changeGender(sex)
if sex == 1 then
Character['sex'] = 0
pedModel = 'mp_m_freemode_01'
changeModel(pedModel)
else
Character['sex'] = 1
pedModel = 'mp_f_freemode_01'
changeModel(pedModel)
end
end
function changeModel(skin)
local model = GetHashKey(skin)
if IsModelInCdimage(model) and IsModelValid(model) then
RequestModel(model)
while not HasModelLoaded(model) do
Citizen.Wait(0)
end
SetPlayerModel(PlayerId(), model)
SetPedDefaultComponentVariation(PlayerPedId())
if skin == 'mp_m_freemode_01' then
SetPedComponentVariation(GetPlayerPed(-1), 3, 15, 0, 2) -- arms
SetPedComponentVariation(GetPlayerPed(-1), 11, 15, 0, 2) -- torso
SetPedComponentVariation(GetPlayerPed(-1), 8, 15, 0, 2) -- tshirt
SetPedComponentVariation(GetPlayerPed(-1), 4, 61, 4, 2) -- pants
SetPedComponentVariation(GetPlayerPed(-1), 6, 34, 0, 2) -- shoes
Character['arms'] = 15
Character['torso_1'] = 15
Character['tshirt_1'] = 15
Character['pants_1'] = 61
Character['pants_2'] = 4
Character['shoes_1'] = 34
Character['glasses_1'] = 0
elseif skin == 'mp_f_freemode_01' then
SetPedComponentVariation(GetPlayerPed(-1), 3, 15, 0, 2) -- arms
SetPedComponentVariation(GetPlayerPed(-1), 11, 5, 0, 2) -- torso
SetPedComponentVariation(GetPlayerPed(-1), 8, 15, 0, 2) -- tshirt
SetPedComponentVariation(GetPlayerPed(-1), 4, 57, 0, 2) -- pants
SetPedComponentVariation(GetPlayerPed(-1), 6, 35, 0, 2) -- shoes
Character['arms'] = 15
Character['torso_1'] = 5
Character['tshirt_1'] = 15
Character['pants_1'] = 57
Character['pants_2'] = 0
Character['shoes_1'] = 35
Character['glasses_1'] = -1
end
SetModelAsNoLongerNeeded(model)
end
end
Apperance = {
{
item = 'hair',
List = {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},
index = 1,
indextwo = 1,
cam = 'face',
itemType = 'component',
itemID = 2,
PercentagePanel = false,
ColourPanel = true,
},
{
item = 'eyebrows',
List = {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},
index = 1,
indextwo = 1,
cam = 'face',
itemType = 'headoverlay',
itemID = 2,
PercentagePanel = true,
ColourPanel = true,
},
{
item = 'beard',
List = {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},
index = 1,
indextwo = 1,
cam = 'face',
itemType = 'headoverlay',
itemID = 1,
PercentagePanel = true,
ColourPanel = true,
},
{
item = 'bodyb',
List = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
index = 1,
indextwo = 1,
cam = 'body',
itemType = 'headoverlay',
itemID = 11,
PercentagePanel = true,
},
{
item = 'age',
List = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14},
index = 1,
indextwo = 1,
cam = 'face',
itemType = 'headoverlay',
itemID = 3,
PercentagePanel = true,
},
{
item = 'blemishes',
List = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16, 17, 18, 19, 20, 21, 22, 23},
index = 1,
indextwo = 1,
cam = 'face',
itemType = 'headoverlay',
itemID = 0,
PercentagePanel = true,
},
{
item = 'moles',
List = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16, 17},
index = 1,
indextwo = 1,
cam = 'face',
itemType = 'headoverlay',
itemID = 9,
PercentagePanel = true,
},
{
item = 'sun',
List = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
index = 1,
indextwo = 1,
cam = 'face',
itemType = 'headoverlay',
itemID = 7,
PercentagePanel = true,
},
{
item = 'eyes_color',
List = {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},
index = 1,
indextwo = 1,
cam = 'face',
itemType = 'eye'
},
{
item = 'makeup',
List = {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},
index = 1,
indextwo = 1,
cam = 'face',
itemType = 'headoverlay',
itemID = 4,
PercentagePanel = true,
ColourPanel = true,
},
{
item = 'lipstick',
List = {1, 2, 3, 4, 5, 6, 7, 8, 9},
index = 1,
indextwo = 1,
cam = 'face',
itemType = 'headoverlay',
itemID = 8,
PercentagePanel = true,
ColourPanel = true,
},
{
item = 'chest',
List = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16},
index = 1,
indextwo = 1,
cam = 'body',
itemType = 'headoverlay',
itemID = 10,
PercentagePanel = true,
ColourPanel = true,
},
{
item = 'blush',
List = {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},
index = 1,
indextwo = 1,
cam = 'face',
itemType = 'headoverlay',
itemID = 5,
PercentagePanel = true,
ColourPanel = true,
},
}
function updateApperance(id, color)
local app = Apperance[id]
local playerPed = PlayerPedId()
if not color then
if app.itemType == 'component' then
SetPedComponentVariation(playerPed, app.itemID, app.index, 0, 2)
Character[app.item..'_1'] = app.index
elseif app.itemType == 'headoverlay' then
SetPedHeadOverlay(playerPed, app.itemID, app.index, math.floor(app.indextwo)/10+0.0)
Character[app.item..'_1'] = app.index
Character[app.item..'_2'] = math.floor(app.indextwo)
elseif app.itemType == 'eye' then
SetPedEyeColor(playerPed, app.index, 0, 1)
Character['eye_color'] = app.index
end
end
if color then
if app.itemType == 'component' then
SetPedHairColor(playerPed, app.indextwo, 0)
Character['hair_color_1'] = app.indextwo
elseif app.itemType == 'headoverlay' then
SetPedHeadOverlayColor(playerPed, app.itemID, 1, app.indextwo, 0)
Character[app.item..'_3'] = app.indextwo
end
end
end
-- Clothe modification
function GenerateClotheList()
for i=1, #Config.Outfit, 1 do
table.insert(ClotheList, Config.Outfit[i].label)
end
end
local ComponentClothe = {tshirt = 8, torso = 11, decals = 10, arms = 3, pants = 4, shoes = 6, chain = 7}
local PropIndexClothe = {helmet = 0, glasses = 1}
function updateClothe(index)
local clothe = Config.Outfit[index]
local gender
if Character['sex'] == 0 then
gender = 'male'
else
gender = 'female'
end
local playerPed = PlayerPedId()
for k,v in pairs(clothe.id[gender]) do
if k == 'helmet' or k == 'glasses' then
SetPedPropIndex(playerPed, PropIndexClothe[k], v[1], v[2])
else
if k == 'arms' then
Character[k] = v[1]
else
Character[k..'_1'] = v[1]
end
Character[k..'_2'] = v[2]
SetPedComponentVariation(playerPed, ComponentClothe[k], v[1], v[2])
end
end
end
-- CAM + Spawn
local Camera = {
face = {x = 402.92, y = -1000.72, z = -98.45, fov = 10.00},
body = {x = 402.92, y = -1000.72, z = -99.01, fov = 30.00},
}
cam, cam2, cam3, camSkin, isCameraActive = nil, nil, nil, nil, nil
lastCam = 'body'
function CharCreatorAnimation()
enable = true
-- Hide HUD
ESX.UI.HUD.SetDisplay(0.0)
DisplayRadar(false)
AnimCam()
Visible()
end
function AnimCam()
local playerPed = PlayerPedId()
DoScreenFadeOut(1000)
Citizen.Wait(4000)
DestroyAllCams(true)
cam2 = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", Camera['body'].x, Camera['body'].y, Camera['body'].z, 0.00, 0.00, 0.00, Camera['body'].fov, false, 0)
SetCamActive(cam2, true)
RenderScriptCams(true, false, 2000, true, true)
Citizen.Wait(500)
DoScreenFadeIn(2000)
SetEntityCoords(GetPlayerPed(-1), 405.59, -997.18, -99.00, 0.0, 0.0, 0.0, true)
SetEntityHeading(GetPlayerPed(-1), 90.00)
-- TriggerEvent('skinchanger:loadSkin', {sex = 0})
changeGender(1)
Citizen.Wait(500)
cam3 = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", 402.99, -998.02, -99.00, 0.00, 0.00, 0.00, 50.00, false, 0)
PointCamAtCoord(cam3, 402.99, -998.02, -99.00)
SetCamActiveWithInterp(cam2, cam3, 5000, true, true)
LoadAnim("mp_character_creation@customise@male_a")
TaskPlayAnim(GetPlayerPed(-1), "mp_character_creation@customise@male_a", "intro", 1.0, 1.0, 4000, 0, 1, 0, 0, 0)
Citizen.Wait(5000)
local coords = GetEntityCoords(GetPlayerPed(-1))
if GetDistanceBetweenCoords(coords, 402.89, -996.87, -99.0, true) > 0.5 then
SetEntityCoords(GetPlayerPed(-1), 402.89, -996.87, -99.0, 0.0, 0.0, 0.0, true)
SetEntityHeading(GetPlayerPed(-1), 173.97)
end
Citizen.Wait(100)
RageUI.Visible(mainMenu, true)
Citizen.Wait(1000)
FreezeEntityPosition(GetPlayerPed(-1), true)
end
function EndCharCreator()
local playerPed = GetPlayerPed(-1)
DoScreenFadeOut(1000)
Wait(1000)
SetCamActive(camSkin, false)
RenderScriptCams(false, false, 0, true, true)
enable = false
EnableAllControlActions(0)
FreezeEntityPosition(GetPlayerPed(-1), false)
SetEntityCoords(playerPed, Config.PlayerSpawn.x, Config.PlayerSpawn.y, Config.PlayerSpawn.z)
SetEntityHeading(playerPed, Config.PlayerSpawn.h)
Wait(1000)
ESX.UI.HUD.SetDisplay(1.0)
DisplayRadar(true)
DoScreenFadeIn(1000)
Wait(1000)
TriggerServerEvent('esx_skin:save', Character)
TriggerEvent('skinchanger:loadSkin', Character)
end
function LoadAnim(dict)
while not HasAnimDictLoaded(dict) do
RequestAnimDict(dict)
Wait(10)
end
end
function CreateSkinCam(camera)
if camSkin then
local newCam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", Camera[camera].x, Camera[camera].y, Camera[camera].z, 0.00, 0.00, 0.00, Camera[camera].fov, false, 0)
PointCamAtCoord(newCam, Camera[camera].x, Camera[camera].y, Camera[camera].z)
SetCamActiveWithInterp(newCam, camSkin, 2000, true, true)
camSkin = newCam
else
camSkin = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", Camera[camera].x, Camera[camera].y, Camera[camera].z, 0.00, 0.00, 0.00, Camera[camera].fov, false, 0)
SetCamActive(cam2, true)
RenderScriptCams(true, false, 2000, true, true)
end
end
-- Hide Player
function Collision()
for i=1,256 do
if NetworkIsPlayerActive(i) then
SetEntityVisible(GetPlayerPed(i), false, false)
SetEntityVisible(PlayerPedId(), true, true)
SetEntityNoCollisionEntity(GetPlayerPed(i), GetPlayerPed(-1), false)
end
end
end
function Visible()
while enable == true do
Citizen.Wait(0)
Collision()
DisableControlAction(0, 0, true)
DisableControlAction(0, 22, true)
DisableControlAction(0, 24, true)
DisableControlAction(0, 32, true)
DisableControlAction(0, 33, true)
DisableControlAction(0, 34, true)
DisableControlAction(0, 35, true)
DisableControlAction(0, 36, true)
DisableControlAction(0, 253, true)
end
end
-- Open Menu
RegisterNetEvent('nicoo_charcreator:CharCreator')
AddEventHandler('nicoo_charcreator:CharCreator', function()
CharCreatorAnimation()
end)