Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.

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
@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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants