Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(client/qb): removing items from metatable #64

Merged
merged 2 commits into from
Feb 9, 2023

Conversation

Manason
Copy link
Contributor

@Manason Manason commented Feb 8, 2023

No description provided.

Comment on lines 20 to 23
playerItems = {}
for k, _ in pairs(playerItems) do
playerItems[k] = nil
end

Copy link
Member

@thelindat thelindat Feb 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

table.wipe(playerItems)?

Looking at the file, should just wipe it when triggering QBCore:Client:OnPlayerLoaded.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use table.wipe.

I assume you meant QBCore:Player:SetPlayerData
However would we want to do this table wipe if the player is using ox_inventory?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does qb not support logout at all? That's when I'd assume you want to wipe the table.
No need to wipe for ox_inventory unless logout is a thing (which is why I suggested OnPlayerLoaded).

Forgot there's no events for individual data changes (like just items, or a single item) so it's kinda gross in that file.. setting up item count everytime something changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing how this is related to login/logout. The bug we're trying to solve is that when item data changes, say from the user dropping an item, the corresponding entry within playerItems needs to be cleared so that the target code has an updated understanding of the player's items. QBCore:Player:SetPlayerData currently is triggered every time a player's items changes; and since the table is rebuilt within setPlayerItems, the missing step is wiping the table beforehand so that ghost items don't linger around.

@thelindat thelindat merged commit fcbfac7 into overextended:main Feb 9, 2023
@Manason Manason deleted the patch-1 branch February 9, 2023 20:30
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