Skip to content

Saving Inventory Bug #67

@DarkBytesx

Description

@DarkBytesx

Getting a nil value error when syncInventory is called during server restart/shutdown period.
Error Message
@ox_inventory/modules/bridge/esx/server.lua:56: attempt to index a nil value (local 'player')

Steps to Reproduce
Wait until server restart is approaching (1-5 minutes before restart)
Trigger inventory save operation (e.g., /saveinv command)
Error is thrown in console

Framework: ESX

Code Location
File: ox_inventory/modules/bridge/esx/server.lua
Line: 56

    local accounts = Inventory.GetAccountItemCounts(inv)

    if accounts then
        local player = server.GetPlayerFromId(inv.id)
        player.syncInventory(inv.weight, inv.maxWeight, inv.items, accounts)
        -- ^ Error occurs here when player is nil
    end
end```

<img width="1233" height="94" alt="Image" src="https://github.com/user-attachments/assets/e925fe85-df4d-47c7-a260-8a99f6975810" />

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions