Integrations
-- Supported systems:
-- - illenium-appearance
-- - qb-clothing
-- - esx_skin / skinchanger
-- - custom (external clothing systems)
--
-- Usage:
-- ReloadPlayerSkin()
--
-- Config:
-- Config.ReloadSkinType = 'illenium' | 'qb' | 'esx_skin' | 'custom'
-- =====================================================
local function ApplySkinWithModel(skin)
local model = (skin.sex == 0) and 'mp_m_freemode_01' or 'mp_f_freemode_01'
local modelHash = joaat(model)
RequestModel(modelHash)
while not HasModelLoaded(modelHash) do Wait(50) end
SetPlayerModel(PlayerId(), modelHash)
SetModelAsNoLongerNeeded(modelHash)
Wait(250)
TriggerEvent('skinchanger:loadSkin', skin)
end
local function ReloadESXSkin()
if lastSkinBackup then
ApplySkinWithModel(lastSkinBackup)
return
end
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
if skin and skin.sex ~= nil then
ApplySkinWithModel(skin)
else
TriggerEvent('skinchanger:loadDefaultModel', true)
end
end)
end
RegisterNetEvent('izaap_punishment:client:restoreQBSkin', function(data)
if Config.ReloadSkinType ~= 'qb' then return end
if not data or not data.skin then return end
CreateThread(function()
local modelName = data.model or 'mp_m_freemode_01'
local modelHash = joaat(modelName)
RequestModel(modelHash)
while not HasModelLoaded(modelHash) do Wait(50) end
SetPlayerModel(PlayerId(), modelHash)
SetModelAsNoLongerNeeded(modelHash)
Wait(500)
local ped = PlayerPedId()
SetPedDefaultComponentVariation(ped)
TriggerEvent('qb-clothing:client:loadPlayerClothing', data.skin, ped)
end)
end)
-- =====================================================
function ReloadPlayerSkin()
if Config.ReloadSkinType == 'illenium' then
TriggerEvent('illenium-appearance:client:reloadSkin')
elseif Config.ReloadSkinType == 'qb' then
TriggerServerEvent('izaap_punishment:server:restoreQBSkin')
elseif Config.ReloadSkinType == 'esx_skin' then
ReloadESXSkin()
elseif Config.ReloadSkinType == 'custom' then
TriggerEvent('izaap_punishment:customReloadSkin')
else
print('[izaap_punishment] Invalid ReloadSkinType in config.lua')
end
end
-- External trigger (usable by other resources)
RegisterNetEvent('izaap_punishment:reloadSkin', ReloadPlayerSkin)
Last updated