# QBCore

### Money Accounts

This is **NOT a laptop problem**, for some reason in the latest qb-core exists a bug where existing players can't have new money accounts: <https://github.com/qbcore-framework/qb-core/issues/1110>\
\
If you are using the latest qb-core and you get the following message on console:

```
Account cosmo doesn't exist in your Framework
```

And you are **200% sure** the account is registered correctly in your qb-core, is because of the qb-core bug, to fix it go to `qb-core/server/player.lua` and **replace the function applyDefaults** with the following:

{% code title="qb-core/server/player.lua" %}

```lua
local function applyDefaults(playerData, defaults)
    for key, value in pairs(defaults) do
        if type(value) == 'function' then
            if key == "money" then
                local moneyTypes = value()
                if not playerData[key] then
                    playerData[key] = moneyTypes
                else
                    for account, balance in pairs(moneyTypes) do
                        playerData[key][account] = playerData[key][account] or balance
                    end
                end
            else
                playerData[key] = playerData[key] or value()
            end
        elseif type(value) == 'table' then
            playerData[key] = playerData[key] or {}
            applyDefaults(playerData[key], value)
        else
            playerData[key] = playerData[key] or value
        end
    end
end
```

{% endcode %}

### Items

{% hint style="warning" %}
If using **qb-inventory** 2.0.0 (or higher) or **jaksam\_inventory** you can ignore this item section.
{% endhint %}

The **UsableItems** function in qb-core is also broken when not using qb-inventory :man\_facepalming:, implement the following fix:

* Go to `qb-core/server/functions.lua` > search for function **QBCore.Functions.CreateUseableItem** and replace it with this:<br>

  ```lua
  function QBCore.Functions.CreateUseableItem(item, data)
      QBCore.UsableItems[item] = data
  end
  ```
* To avoid any error prints when you restart a resource go to `qb-core/server/events.lua` delete the event **onResourceStop**

```lua
--[[
AddEventHandler("onResourceStop", function(resName)
    for i,v in pairs(QBCore.UsableItems) do
        if v.resource == resName then
            QBCore.UsableItems[i] = nil
        end
    end
end)
]]--
```

{% hint style="danger" %}
**This errors are caused by qb-core and not my scripts.**
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.av-scripts.com/laptop-pack-v3/laptop-v3/installation/qbcore.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
