forked from FRDamianDev/np_skinshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
79 lines (70 loc) · 2.39 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
RegisterCommand("open", function()
TriggerEvent("skinshop:toggleMenu")
end)
-----------------------------------------------------------------------------------------------------------------------------------------
-- Menu toggle
-----------------------------------------------------------------------------------------------------------------------------------------
local m, f = GetHashKey("mp_m_freemode_01"), GetHashKey("mp_f_freemode_01")
local cor = 0
local menuactive = false
RegisterNetEvent("skinshop:toggleMenu")
AddEventHandler("skinshop:toggleMenu", function()
menuactive = not menuactive
if menuactive then
SetNuiFocus(true,true)
local ped = PlayerPedId()
if IsPedModel(ped, m) then
SendNUIMessage({ showMenu = true, masc = true })
elseif IsPedModel(ped, f) then
SendNUIMessage({ showMenu = true, masc = false })
end
else
cor = 0
dados, tipo = nil
SetNuiFocus(false)
SendNUIMessage({ showMenu = false, masc = true })
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(1000)
if menuactive then InvalidateIdleCam() end
end
end)
-----------------------------------------------------------------------------------------------------------------------------------------
-- Retornos
-----------------------------------------------------------------------------------------------------------------------------------------
RegisterNUICallback("exit", function()
TriggerEvent("skinshop:toggleMenu")
end)
RegisterNUICallback("rotate", function(data, cb)
local ped = PlayerPedId()
local heading = GetEntityHeading(ped)
if data == "left" then
SetEntityHeading(ped, heading + 15)
elseif data == "right" then
SetEntityHeading(ped, heading - 15)
end
end)
RegisterNUICallback("update", function(data, cb)
dados = tonumber(json.encode(data[1]))
tipo = tonumber(json.encode(data[2]))
cor = 0
setRoupa(dados, tipo, cor)
end)
RegisterNUICallback("color", function(data, cb)
if data == "left" then
if cor ~= 0 then cor = cor - 1 else cor = 20 end
elseif data == "right" then
if cor ~= 21 then cor = cor + 1 else cor = 0 end
end
if dados and tipo then setRoupa(dados, tipo, cor) end
end)
function setRoupa(dados, tipo, cor)
local ped = PlayerPedId()
if dados < 100 then
SetPedComponentVariation(ped, dados, tipo, cor, 1)
else
SetPedPropIndex(ped, dados-100, tipo, cor, 1)
end
end