Skip to content

Commit

Permalink
Update character.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
Scullyy committed Apr 19, 2024
1 parent 486b7df commit 01f7862
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions client/character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,26 @@ local function destroyPreviewCam()
FreezeEntityPosition(cache.ped, false)
end

local function randomPed()
local ped = randomPeds[math.random(1, #randomPeds)]
lib.requestModel(ped.model, config.loadingModelsTimeout)
SetPlayerModel(cache.playerId, ped.model)
pcall(function() exports['illenium-appearance']:setPedAppearance(PlayerPedId(), ped) end)
SetModelAsNoLongerNeeded(ped.model)
end

---@param citizenId? string
local function previewPed(citizenId)
if not citizenId then
local ped = randomPeds[math.random(1, #randomPeds)]
lib.requestModel(ped.model, config.loadingModelsTimeout)
SetPlayerModel(cache.playerId, ped.model)
pcall(function() exports['illenium-appearance']:setPedAppearance(PlayerPedId(), ped) end)
return
end
if not citizenId then randomPed() return end

local clothing, model = lib.callback.await('qbx_core:server:getPreviewPedData', false, citizenId)
if model and clothing then
lib.requestModel(model, config.loadingModelsTimeout)
SetPlayerModel(cache.playerId, model)
pcall(function() exports['illenium-appearance']:setPedAppearance(PlayerPedId(), json.decode(clothing)) end)
SetModelAsNoLongerNeeded(ped.model)
else
local ped = randomPeds[math.random(1, #randomPeds)]
lib.requestModel(ped.model, config.loadingModelsTimeout)
SetPlayerModel(cache.playerId, ped.model)
pcall(function() exports['illenium-appearance']:setPedAppearance(PlayerPedId(), ped) end)
randomPed()
end
end

Expand Down Expand Up @@ -473,16 +473,12 @@ RegisterNetEvent('qbx_core:client:playerLoggedOut', function()
end)

CreateThread(function()
local ped = randomPeds[math.random(1, #randomPeds)]
while true do
Wait(0)
if NetworkIsSessionStarted() then
pcall(function() exports.spawnmanager:setAutoSpawn(false) end)
Wait(250)
lib.requestModel(ped.model, config.loadingModelsTimeout)
SetPlayerModel(cache.playerId, ped.model)
pcall(function() exports['illenium-appearance']:setPedAppearance(PlayerPedId(), ped) end)
SetModelAsNoLongerNeeded(ped.model)
randomPed()
chooseCharacter()
break
end
Expand Down

0 comments on commit 01f7862

Please sign in to comment.