Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Character invisible to user upon registration #47

Merged
merged 1 commit into from
Dec 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,43 @@ AddEventHandler('skinchanger:loadSkin', function(skin, cb)
end
end)

AddEventHandler('skinchanger:loadDefaultModel', function(loadMale, cb)
LoadDefaultModel(loadMale, cb)
end)

function LoadDefaultModel(malePed, cb)
local playerPed = PlayerPedId()
local characterModel

if malePed then
characterModel = `mp_m_freemode_01`
else
characterModel = `mp_f_freemode_01`
end

RequestModel(characterModel)

CreateThread(function()
while not HasModelLoaded(characterModel) do
RequestModel(characterModel)
Wait(0)
end

if IsModelInCdimage(characterModel) and IsModelValid(characterModel) then
SetPlayerModel(PlayerId(), characterModel)
SetPedDefaultComponentVariation(playerPed)
end

SetModelAsNoLongerNeeded(characterModel)

if cb ~= nil then
cb()
end

TriggerEvent('skinchanger:modelLoaded')
end)
end


RegisterNetEvent('skinchanger:loadClothes')
AddEventHandler('skinchanger:loadClothes', function(skin, clothes)
Expand Down