Running into an issue with my custom DMV system where test status persists across character switches. When I fail a test on one character, then switch to another character, the new character shows up as having failed the DMV test too.
The statebag isn't getting cleared properly during character unload. I can see in the client state that the dmv:testStatus key still contains the old character's 'failed' status even after loading the new character. MySQL has the correct per-character data, but the client-side statebag cache is stale.
Server console shows the statebag being set to 'failed' for the previous character ID during the new character load process. The event QBCore:Client:OnPlayerLoaded fires before proper cleanup of the previous character's statebags.
Here's what I'm working with:
RegisterNetEvent('dmv:client:failTest', function()
LocalPlayer.state:set('dmv:testStatus', 'failed', true)
-- Missing cleanup during character switch causes this to persist
end)
-- In character management:
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
-- Should clear dmv:* statebag keys here
LocalPlayer.state:set('dmv:testStatus', nil, true) -- Current incomplete cleanup
end)The issue only resolves after a full client reconnect. Anyone run into this with statebag persistence across character switches? Wondering if there's something I'm missing about the order of operations during character transitions.
GhostStrike · 02/09/2026
Sign in to reply.