Skip to content

Fix: Player spawns properly#85

Open
DispersiaRoleplay wants to merge 3 commits intoqbcore-framework:mainfrom
DispersiaRoleplay:DispersiaRoleplay-patch-2
Open

Fix: Player spawns properly#85
DispersiaRoleplay wants to merge 3 commits intoqbcore-framework:mainfrom
DispersiaRoleplay:DispersiaRoleplay-patch-2

Conversation

@DispersiaRoleplay
Copy link

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.

using main en.lua was translated to Ukrainian language.

I have you personally loaded this code into an updated qbcore project and checked all it's functionality
This code fit the style guidelines
This PR fit the contribution guidelines
using main en.lua was translated to Ukrainian language.

I have you personally loaded this code into an updated qbcore project and checked all it's functionality
This code fit the style guidelines
This PR fit the contribution guidelines
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant