Fix health metadata not saving on reconnect#1214
Open
AndyBodnar wants to merge 1 commit intoqbcore-framework:mainfrom
Open
Fix health metadata not saving on reconnect#1214AndyBodnar wants to merge 1 commit intoqbcore-framework:mainfrom
AndyBodnar wants to merge 1 commit intoqbcore-framework:mainfrom
Conversation
- Add `health` field to default player metadata (config.lua) - Send health/armor from client to server in UpdatePlayer event (loops.lua) - Save health/armor to metadata in QBCore:UpdatePlayer handler (events.lua) - Capture health/armor on disconnect before save (events.lua) - Restore saved health/armor on player load (client/events.lua) This ensures player health persists across reconnects instead of resetting to full. Fixes qbcore-framework#1213
|
Does this also fix the issue of hunger and thirst metadata not saving on reconnect? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes player health resetting to full on reconnect by properly saving and restoring health metadata.
Problem
When players disconnect and reconnect, their health resets to full instead of being preserved. This happens because:
healthfield existed in the default metadataSolution
config.lua
health = 200to default player metadataclient/loops.lua
QBCore:UpdatePlayerto send current health and armor to serverserver/events.lua
QBCore:UpdatePlayerhandler to save received health/armor to metadataplayerDroppedhandler to capture health/armor before saving on disconnectclient/events.lua
OnPlayerLoadedeventTesting
Tested using LuaGround - all metadata persistence tests pass.
Related Issue
Fixes #1213