fix(bridge/qb): improved handcuff status syncing #1711
Merged
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.
The current bridge code toggles handcuff status when receiving a handcuff event from QB. However without the context on whether the player is currently handcuffed this leads to the inventory setting cuffed status when they are actually being uncuffed or vise versa. This can be seen when relogging while cuffed for example, as the inventory doesn't persist the cuffed status, but QB would.
This PR sets cuffed status based on the player's QB metadata (source of truth) fixing the above sync issue, and aligning it with the same way the bridge handles other aspects of player data.
I'm still concerned there may be a race condition, where when the player loads in while cuffed, the inventory won't have loaded before the initial metadata is set, but metadata is likely updated every few seconds due to hunger/thirst, so the cuff status should quickly sync regardless. Also, if this was an issue it would be an issue for group status as well.