Help qb-banking + cash as item [OBSOLETE]

Hi guys,

I’m playing a bit with a cash as an item in my qb-core server. As of right now, everything looks fine, except for the deposit in qb-banking. There’s a server-side check of the amount of cash the players used to have when they were doing /cash, preventing them to deposit a higher amount that they have, even though in the inventory, they have a bigger amount of money.

More clearly:
/cash: 1637
cash in inventory: 15,000

I will be able to deposit 15 times 1,000, but I won’t be able to deposit 10,000 at once, because the /cash amount is below the value.

I’d like to get my qb-banking to check the amount of money items I have in my inventory.

Can anyone help me?

Thanks!

EDIT: With qb-core getting a lot of updates, this method is now obsolete, sorry!

4 Likes

By default, scripts that check money will be calling the qb-core player function;

Player.Functions.GetMoney('cash')

And giving and taking money will be;

Player.Functions.AddMoney('cash', amount, reason)
Player.Functions.RemoveMoney('cash', amount, reason)

In qb-core, edit these functions to check the count of cash items (money in inventory) instead of the invisible cash the player has on them. And for the add/remove, edit them to add/remove the cash items.

Then all the scripts that call these functions to check their cash, add cash or remove cash, will really be checking their inventory and add/removing items instead. This approach avoids needing to edit every single script.

1 Like

Hey Ace! Thank you so much for your help!

So if I’d like to see the server to check the items instead of the virtual cash, it would look like this?

  rTable.GetBalance = function()
       local currentCash = self.Functions.GetItemByName('cash').amount
     end
4 Likes

No, you need to edit the qb-core player functions in the qb-core framework script.
qb-core/server/player.lua on lines 232 to 292.
Add checks in them all that if it involves “cash” and not “bank”, etc. then it uses inventory functions, not PlayerData.money[moneyType].

1 Like

it’s a perfect suggestion.

I tried it, however, I had to also check on a couple other scripts to make sure /cash was accurate for instance. Globally, the code would look like this:

Player.Functions.GetItemByName('cash').amount
(+ the removeitem / additem accordingly)

You’ll just have to add “cash” as an item in your shared.lua (for Qb-core).

Scripts checked up:

  • qb-hud (for the /cash and the OnMoneyChange event)
  • qb-banking (for the deposit/withdraw/ and banking informations, if you want it to be displayed properly)
  • Last but not least, the qb-core/server/main.lua, for every money functions.

Thank you again DrAceMisanthrope, I really appreciate it and now it’s working very well :smiley:

7 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.