qbcore-framework / qb-multicharacter

Multi-Character System Used With QB-Core :man: :woman:
GNU General Public License v3.0
32 stars 237 forks source link

Add native support for iLLeniumStudios's fivem-appearance #161

Closed Z3rio closed 1 year ago

Z3rio commented 2 years ago

Describe Pull request This pull request adds native support for ILLeniumStudio's clothing script (fivem-appearance) which is quite nice to have since alot of people use it instead of qb-clothing.

If your PR is to fix an issue mention that issue here

155

Questions (please complete the following information):

Z3rio commented 2 years ago

This isn't really needed as his script has backwards compatibility with qb-clothing and works fine with multicharacter.

Nope, it lacks the events and such to spawn the character preview shown whilst clicking a character button. I wouldn't have added it if it wasn't needed. Search it up yourself if you want to ;)

It doesn't work fine with qb-multicharacter in the sense that the character previews don't spawn without editing the files noted in fivem-appearance which wouldnt be needed if this gets pushed out.

ghost commented 2 years ago

This is all you need to do to replicate the same effect of what you're doing.

local fivemAppearanceStarted = GetResourceState('fivem-appearance') == 'started'
RegisterNUICallback('cDataPed', function(nData, cb)
    local cData = nData.cData
    SetEntityAsMissionEntity(charPed, true, true)
    DeleteEntity(charPed)
    if cData ~= nil then
        QBCore.Functions.TriggerCallback('qb-multicharacter:server:getSkin', function(model, data)
            model = model ~= nil and tonumber(model) or false
            if model ~= nil then
                CreateThread(function()
                    RequestModel(model)
                    while not HasModelLoaded(model) do
                        Wait(0)
                    end
                    charPed = CreatePed(2, model, Config.PedCoords.x, Config.PedCoords.y, Config.PedCoords.z - 0.98, Config.PedCoords.w, false, true)
                    SetPedComponentVariation(charPed, 0, 0, 0, 2)
                    FreezeEntityPosition(charPed, false)
                    SetEntityInvincible(charPed, true)
                    PlaceObjectOnGroundProperly(charPed)
                    SetBlockingOfNonTemporaryEvents(charPed, true)
                    data = json.decode(data)

                    if fivemAppearanceStarted then
                        exports['fivem-appearance']:setPedAppearance(charPed, data)
                    else
                        TriggerEvent('qb-clothing:client:loadPlayerClothing', data, charPed)
                    end
                end)
            else
                CreateThread(function()
                    local randommodels = {
                        "mp_m_freemode_01",
                        "mp_f_freemode_01",
                    }
                    model = joaat(randommodels[math.random(1, #randommodels)])
                    RequestModel(model)
                    while not HasModelLoaded(model) do
                        Wait(0)
                    end
                    charPed = CreatePed(2, model, Config.PedCoords.x, Config.PedCoords.y, Config.PedCoords.z - 0.98, Config.PedCoords.w, false, true)
                    SetPedComponentVariation(charPed, 0, 0, 0, 2)
                    FreezeEntityPosition(charPed, false)
                    SetEntityInvincible(charPed, true)
                    PlaceObjectOnGroundProperly(charPed)
                    SetBlockingOfNonTemporaryEvents(charPed, true)
                end)
            end
            cb("ok")
        end, cData.citizenid)
    else
        CreateThread(function()
            local randommodels = {
                "mp_m_freemode_01",
                "mp_f_freemode_01",
            }
            local model = joaat(randommodels[math.random(1, #randommodels)])
            RequestModel(model)
            while not HasModelLoaded(model) do
                Wait(0)
            end
            charPed = CreatePed(2, model, Config.PedCoords.x, Config.PedCoords.y, Config.PedCoords.z - 0.98, Config.PedCoords.w, false, true)
            SetPedComponentVariation(charPed, 0, 0, 0, 2)
            FreezeEntityPosition(charPed, false)
            SetEntityInvincible(charPed, true)
            PlaceObjectOnGroundProperly(charPed)
            SetBlockingOfNonTemporaryEvents(charPed, true)
        end)
        cb("ok")
    end
end)
Bama94 commented 1 year ago

Or could you not make a config.clothingoption where config.clothing = 'fivem-appearance' or 'qb-clothing'

Z3rio commented 1 year ago

Or could you not make a config.clothingoption where config.clothing = 'fivem-appearance' or 'qb-clothing'

Why do that when it can be done automatically through this instead?