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

[BUG] When Skip Spawn Is True #231

Closed ezyhabz closed 6 months ago

ezyhabz commented 1 year ago

Describe the bug Happens when clean install qb then used skip spawn true. I can register and spawn, but after relogin the account it goes black screen. But if i set SkipSelection = false, it spawn me as usual with the spawn menu. Update : it's when i turn off apartment when starting it happens.

There was no error at all from console neither the server.

Questions (please complete the following information):

Nophobia09 commented 1 year ago

Describe the bug Happens when clean install qb then used skip spawn true. I can register and spawn, but after relogin the account it goes black screen. But if i set SkipSelection = false, it spawn me as usual with the spawn menu. Update : it's when i turn off apartment when starting it happens.

There was no error at all from console neither the server.

Questions (please complete the following information):

  • When you last updated: Today
  • Are you using custom resource : None, fresh install
  • Have you renamed qb- to something custom? = Defineatly no. @ezyhabz

I have located the issue. The problem is there is only one spawn last location 'qb-multicharacter:client:spawnLastLocation' which does not take into account if you do not own a property, I modified the function so that if it returns without a result from the callback (Which there shouldnt be if you turn off automatically spawning to an apartment), the player is loaded at their last location. Here is a modified version of that function in qb-multicharacter Client Line 139

RegisterNetEvent('qb-multicharacter:client:spawnLastLocation', function(coords, cData)
    QBCore.Functions.TriggerCallback('apartments:GetOwnedApartment', function(result)
        if result then
            TriggerEvent("apartments:client:SetHomeBlip", result.type)
        end

        local ped = PlayerPedId()
        SetEntityCoords(ped, coords.x, coords.y, coords.z)
        SetEntityHeading(ped, coords.w)
        FreezeEntityPosition(ped, false)
        SetEntityVisible(ped, true)
        local PlayerData = QBCore.Functions.GetPlayerData()
        local insideMeta = PlayerData.metadata["inside"]
        DoScreenFadeOut(500)

        if insideMeta.house then
            TriggerEvent('qb-houses:client:LastLocationHouse', insideMeta.house)
        elseif insideMeta.apartment.apartmentType and insideMeta.apartment.apartmentId then
            TriggerEvent('qb-apartments:client:LastLocationHouse', insideMeta.apartment.apartmentType, insideMeta.apartment.apartmentId)
        end

        TriggerServerEvent('QBCore:Server:OnPlayerLoaded')
        TriggerEvent('QBCore:Client:OnPlayerLoaded')
        Wait(2000)
        DoScreenFadeIn(250)
    end, cData.citizenid)  
end)

Let me know if this resolves your issues!

github-actions[bot] commented 9 months ago

This issue has had 60 days of inactivity & will close within 7 days

djthemask commented 8 months ago

I also am having issues with this.

When i add SkipSelection to my config and set it to True ( I don't have it by default ). It indeed does skip the spawn menu but it also skips character selection and spawns at the character initial configuration location without being able to move instead of spawning at the last location which is what we would like to achieve. So basically we want the multi character to have the same functionality but just skip the spawn menu. We already removed all the aditional spawn options that where configured and now when we join we get the menu with only one option which is last location. It would be great if someone could tell me how we could go about skipping this menu and load the last spawn location by default.

EDIT: Nevermind, i was using an outdated version. If you have the same issue as described above make sure to download the latest version.

Thanks in advance

github-actions[bot] commented 6 months ago

This issue has had 60 days of inactivity & will close within 7 days