Skip to content

Commit

Permalink
refactor(client): Move LoadPlayerUniform above
Browse files Browse the repository at this point in the history
  • Loading branch information
TheiLLeniumStudios committed Jun 20, 2022
1 parent 53625be commit 26bb94b
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,32 @@ local function RemoveTargets()
end
end

local function LoadPlayerUniform()
QBCore.Functions.TriggerCallback("fivem-appearance:server:getUniform", function(uniformData)
if not uniformData then
return
end
local outfits = Config.Outfits[uniformData.jobName][uniformData.gender]
local uniform = nil
for i = 1, #outfits, 1 do
if outfits[i].outfitLabel == uniformData.label then
uniform = outfits[i]
break
end
end

if not uniform then
TriggerServerEvent("fivem-appearance:server:syncUniform", nil) -- Uniform doesn't exist anymore
return
end

uniform.jobName = uniformData.jobName
uniform.gender = uniformData.gender

TriggerEvent("qb-clothing:client:loadOutfit", uniform)
end)
end

local function InitAppearance()
PlayerData = QBCore.Functions.GetPlayerData()
PlayerJob = PlayerData.job
Expand Down Expand Up @@ -105,32 +131,6 @@ RegisterNetEvent('QBCore:Client:SetDuty', function(duty)
PlayerJob.onduty = duty
end)

local function LoadPlayerUniform()
QBCore.Functions.TriggerCallback("fivem-appearance:server:getUniform", function(uniformData)
if not uniformData then
return
end
local outfits = Config.Outfits[uniformData.jobName][uniformData.gender]
local uniform = nil
for i = 1, #outfits, 1 do
if outfits[i].outfitLabel == uniformData.label then
uniform = outfits[i]
break
end
end

if not uniform then
TriggerServerEvent("fivem-appearance:server:syncUniform", nil) -- Uniform doesn't exist anymore
return
end

uniform.jobName = uniformData.jobName
uniform.gender = uniformData.gender

TriggerEvent("qb-clothing:client:loadOutfit", uniform)
end)
end

RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
InitAppearance()
end)
Expand Down

0 comments on commit 26bb94b

Please sign in to comment.