qb-spawn
qb-spawn copied to clipboard
Fix: Player spawns properly
This PR resolves a bug where players were incorrectly spawning at the character preview location instead of their actual last known position.
Problem: The original implementation called QBCore:Server:OnPlayerLoaded, QBCore:Client:OnPlayerLoaded, and PostSpawnPlayer() outside the asynchronous QBCore.Functions.GetPlayerData callback. As a result, the spawn sequence would proceed before the player's data (including coordinates) was fully loaded, leading to the player remaining at the default camera or preview location.
Solution: The fix moves all spawn-related logic inside the GetPlayerData callback to ensure:
The player ped is fully created.
The correct position and heading are available before teleporting.
Housing or apartment metadata is handled after coordinate placement.
The spawn function is only triggered once all required data is ready.
Tested: Verified correct spawning in last known position.
Verified teleportation to apartments and houses functions correctly.
No regression observed in normal or new character spawn types.