Skip to content

Conversation

@ThembaMahlangu
Copy link

This PR adds a critical fix to prevent issues when the qb-multicharacter resource is stopped or restarted. The fix implements a proper cleanup mechanism using the onResourceStop event handler to ensure all connected players are safely logged out before the resource stops.

What this PR fixes:

Resource Stop Crashes: Prevents the script from crashing when QBCore.Functions.GetPlayers() fails during resource shutdown

Player State Issues: Ensures all players are properly logged out using QBCore.Player.Logout() when the resource stops

Data Integrity: Prevents potential data corruption by properly cleaning up player states during resource restarts

Error Handling: Implements safe error handling with pcall() to gracefully handle failures

Why this should be included:

This fix addresses a common issue where the multicharacter system can leave players in an inconsistent state when the resource is restarted, which can lead to data corruption and server instability. The implementation follows QBCore's error handling patterns and provides proper debugging information.

Technical Details:

Uses pcall() for safe function calls to prevent crashes

Only triggers for the specific qb-multicharacter resource

Includes debug logging for troubleshooting

Follows existing code style and patterns in the file

Questions (please complete the following information):
Have you personally loaded this code into an updated qbcore project and checked all it's functionality? yes
Does your code fit the style guidelines? yes
Does your PR fit the contribution guidelines? yes

@Qwerty1Verified
Copy link
Member

Interesting, thank you for the PR! I'll check out the reproduction steps for the issue you're addressing here.

@ThembaMahlangu
Copy link
Author

I decided to close this due to new changes added into my main branch

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.

2 participants