QB.Core cash as item

Hi,

i want to implement cash as item im new in the coding sczene and dont know how to do it maybe somone here can help me tanks for everyone who helps me out

2 Likes

Did you ever figure this out?

2 Likes

no i did not haha

where?

ye where wtf …

yeah please answer @AussieDropBear

1 Like

I am not sure that is right re: QB-Core having it as a default item but you could go through each resource and change “Player.Functions.AddMoney” to “Player.Functions.AddItem” and simply make your own cash item.

Like anything it’s simply a server sided output when a particular trigger occurs.

3 Likes

There is the ability to make it as an item, it’s quietly complicated, and just making it an item is exploitable. However, there is a guy who made it just for 3€ and you don’t have to mess with it. Just have it instantly. Check it out at https://studio-players.tebex.io

3 Likes

how does his script prevent exploitation any differently

2 Likes

player.lua.txt (2.3 KB)

3 Likes

The bank still doesn’t recognize the cash in your inventory, how do I fix that?

1 Like

would be under the bank script

did you sort this out? please help a brother out

Need to check the banking script and check

“Player.Functions.AddMoney” to “Player.Functions.AddItem”

and check Player.Functions.RemoveMoney and change it to an export from your inventory script and find the Functions.Removeitem.

Something like that.

1 Like

i cant withdraw the money

Did you ever figure this out?

Yeah, use the money as item script lol unfortunately it’s a subscription but it’s under 10 bucks for 3 months and it works flawlessly.

So is it work like i will search for all Player.Functions.AddMoney in VS Code and replace all of them with Player.Functions.AddItem and the same with Player.Functions.RemoveMoney?

2 Likes

This is how you use cash as item.
Add in qb-core/config.lua

QBConfig.UseMoneyAsItem = true
QBConfig.MoneyItem = "cash"

Add in qb-core/server/player.lua and find self.Functions.AddMoney
Add above this line if not self.Offline then

if QBCore.Config.UseMoneyAsItem then
    if self.Functions.GetItemByName(QBCore.Config.MoneyItem) ~= nil then
        self.Functions.RemoveItem(QBCore.Config.MoneyItem, self.PlayerData.money[moneytype] - amount, nil)
        self.Functions.AddItem(QBCore.Config.MoneyItem, self.PlayerData.money[moneytype], nil)
    end
end

Add in qb-core/server/player.lua and find self.Functions.RemoveMoney
Add above this line if not self.Offline then

if QBCore.Config.UseMoneyAsItem then
    if self.Functions.GetItemByName(QBCore.Config.MoneyItem) ~= nil then
        self.Functions.RemoveItem(QBCore.Config.MoneyItem, self.PlayerData.money[moneytype] + amount, nil)
        self.Functions.AddItem(QBCore.Config.MoneyItem, self.PlayerData.money[moneytype], nil)
    end
end

Add in qb-core/server/player.lua and find self.Functions.SetMoney
Add above this line if not self.Offline then

if QBCore.Config.UseMoneyAsItem then
    if self.Functions.GetItemByName(QBCore.Config.MoneyItem) ~= nil then
        self.Functions.RemoveItem(QBCore.Config.MoneyItem, self.PlayerData.money[moneytype], nil)
        self.Functions.AddItem(QBCore.Config.MoneyItem, amount, nil)
    end
end

To add in qb-core/shared/items.lua
don’t forget to add the image in your inventoryimages folder

['cash']                        = {['name'] = 'cash',                          ['label'] = 'Cash',                 ['weight'] = 0,            ['type'] = 'item',         ['image'] = 'cash.png',                ['unique'] = false,          ['useable'] = true,      ['shouldClose'] = true,      ['combinable'] = nil,   ['description'] = 'Cash'},
10 Likes

We tried and it dosent work. Item is loaded and all, but it wont be used as a currency