114 lines
2.6 KiB
Lua
114 lines
2.6 KiB
Lua
--- Desencrypted By PrejuicioX
|
|
|
|
-- NUI Callback Handlers
|
|
|
|
RegisterNUICallback("UILoaded", function(data, callback)
|
|
SendNUIMessage({
|
|
event = "config",
|
|
maxAmount = Config.maxOutfits,
|
|
previewEnabled = Config.preview.enabled,
|
|
allowSharing = Config.allowBagSharing,
|
|
colors = Config.theme.colors,
|
|
locale = {
|
|
preview = L("PREVIEW"),
|
|
save = L("SAVE CURRENT OUTFIT")
|
|
}
|
|
})
|
|
callback(true)
|
|
end)
|
|
|
|
RegisterNUICallback("SaveOutfit", function(data, callback)
|
|
SaveOutfit()
|
|
callback(true)
|
|
end)
|
|
|
|
RegisterNUICallback("CloseBag", function(data, callback)
|
|
if not CHANGING_OUTFIT then
|
|
CloseBag()
|
|
end
|
|
callback(true)
|
|
end)
|
|
|
|
RegisterNUICallback("DeleteOutfit", function(data, callback)
|
|
DeleteOutfit(data.id)
|
|
callback(true)
|
|
end)
|
|
|
|
RegisterNUICallback("PreviewOutfit", function(data, callback)
|
|
local outfit = FindBagOutfit(data.id)
|
|
local playerModel = GetEntityModel(PlayerPedId())
|
|
|
|
if outfit.model ~= playerModel then
|
|
DrawMissionText(L("~r~This outfit isn't suitable for you"), 5000)
|
|
callback(false)
|
|
return
|
|
end
|
|
|
|
PreviewOutfit(outfit.data)
|
|
callback(true)
|
|
end)
|
|
|
|
RegisterNUICallback("TogglePublicState", function(data, callback)
|
|
TogglePublicState(data.newState)
|
|
callback(true)
|
|
end)
|
|
|
|
RegisterNUICallback("ApplyOutfit", function(data, callback)
|
|
local outfit = FindBagOutfit(data.id)
|
|
|
|
if not outfit then
|
|
Debug("User outfit not found")
|
|
callback(false)
|
|
return
|
|
end
|
|
|
|
local playerModel = GetEntityModel(PlayerPedId())
|
|
|
|
if outfit.model == playerModel then
|
|
if not CHANGING_OUTFIT then
|
|
ApplyOutfit(outfit.data, data.type, outfit.name)
|
|
else
|
|
DrawMissionText(L("~r~Wait a bit before you switch outfits again"), 5000)
|
|
end
|
|
else
|
|
DrawMissionText(L("~r~This outfit isn't suitable for you"), 5000)
|
|
end
|
|
|
|
callback(true)
|
|
end)
|
|
|
|
-- Public Functions
|
|
|
|
function OpenNuiBag(bagId)
|
|
SendNUIMessage({
|
|
event = "show",
|
|
state = true,
|
|
owned = OwnsBag(bagId),
|
|
isPublic = IsPublic(bagId),
|
|
outfits = GetBagOutfits(bagId),
|
|
currentModel = GetEntityModel(PlayerPedId())
|
|
})
|
|
SetNuiFocus(true, true)
|
|
end
|
|
|
|
function UpdatePublicState()
|
|
SendNUIMessage({
|
|
event = "update-public",
|
|
isPublic = IsPublic(CURRENT_BAG)
|
|
})
|
|
end
|
|
|
|
function RefreshNuiBagOutfits(bagId)
|
|
SendNUIMessage({
|
|
event = "set",
|
|
outfits = GetBagOutfits(bagId)
|
|
})
|
|
end
|
|
|
|
function ClearUI()
|
|
SendNUIMessage({
|
|
event = "clear"
|
|
})
|
|
end
|
|
|
|
--- Desencrypted By PrejuicioX |