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

refactor and improve performance of table functions #647

Merged
merged 7 commits into from
Oct 1, 2024

Conversation

BigSmoKe07
Copy link
Contributor

Function Refactor:

  • contains
  • table_matches
  • table_merge

@BigSmoKe07 BigSmoKe07 changed the title refactor and improve performance of table function refactor and improve performance of table functions Oct 1, 2024
imports/table/shared.lua Outdated Show resolved Hide resolved
imports/table/shared.lua Outdated Show resolved Hide resolved
@thelindat thelindat merged commit 4c460e0 into overextended:master Oct 1, 2024
@rhykosqc
Copy link

With this update, we have encountered an inventory problem. We are no longer able to reload weapons.

--> I think its come from table.contains

function Inventory.GetSlotWithItem(itemName, metadata, strict)
    local inventory = PlayerData.inventory
    local item = Items(itemName) --[[@as OxClientItem?]]
    
    if not inventory or not item then return end
    
    metadata = assertMetadata(metadata)
    local tablematch = strict and table.matches or table.contains
    
    for _, slotData in pairs(inventory) do
        if slotData and slotData.name == item.name and (not metadata or tablematch(slotData.metadata, metadata)) then
	   return slotData
        end
    end
end

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.

3 participants