Qbcore inventory

Is there a way to put the balance in cash in qb-inventory?

!!I have this doubt.

3 Likes

What do you mean?
Having cash as an item?

3 Likes

yes bro

3 Likes

Hey man, I’ve just found the way to do this if you need it thanks to PuFGGs/cash-item-for-qb-core: Cash item for qb-core (github.com)

2 steps - go to qb-core/server/player.lua - line 254 Replace money functions with below

self.Functions.AddMoney = function(moneytype, amount, reason)
	reason = reason ~= nil and reason or "unkown"
	local moneytype = moneytype:lower()
	local amount = tonumber(amount)
	if amount < 0 then return end

	if moneytype == 'cash' then
		self.Functions.AddItem('cash', amount)
		self.Functions.UpdatePlayerData()
	else
		if self.PlayerData.money[moneytype] ~= nil then
			self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype]+amount
			self.Functions.UpdatePlayerData()
			return true
		end
	end
	return false
end

self.Functions.RemoveMoney = function(moneytype, amount, reason)
	reason = reason ~= nil and reason or "unkown"
	local moneytype = moneytype:lower()
	local amount = tonumber(amount)
	if amount < 0 then return end
			if moneytype == 'cash' then
				if self.Functions.GetItemByName('cash') ~= nil then
					if self.Functions.GetItemByName('cash').amount >= amount then
						self.Functions.RemoveItem('cash', amount)
						self.Functions.UpdatePlayerData()
						return true
					else
						return false
					end
				else
					return false
				end
			else
				if self.PlayerData.money[moneytype] ~= nil then
					for _, mtype in pairs(QBCore.Config.Money.DontAllowMinus) do
						if mtype == moneytype then
							if self.PlayerData.money[moneytype] - amount < 0 then return false end
						end
					end
					self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] - amount
					self.Functions.UpdatePlayerData()
					return true
				else
					return false
				end
			end
end

self.Functions.SetMoney = function(moneytype, amount, reason)
	reason = reason ~= nil and reason or "unkown"
	local moneytype = moneytype:lower()
	local amount = tonumber(amount)
	if amount < 0 then return end
	if moneytype == 'cash' then
		if self.Functions.GetItemByName('cash') ~= nil then
			local pgggagamtestte = self.Functions.GetItemByName('cash').amount
			self.Functions.RemoveItem('cash', pgggagamtestte)
			self.Functions.AddItem('cash', amount)
			self.Functions.UpdatePlayerData()
			return true
		else
			self.Functions.AddItem('cash', amount)
			self.Functions.UpdatePlayerData()
			return true
		end
	elseif self.PlayerData.money[moneytype] ~= nil then
		self.PlayerData.money[moneytype] = amount
		self.Functions.UpdatePlayerData()
		return true
	end
	return false
end

Add item to qb-core/shared/items.lua
Remember to add the cash.png to inventory/html/images

[‘cash’] = {[‘name’] = ‘cash’, [‘label’] = ‘Cash’, [‘weight’] = 0, [‘type’] = ‘item’, [‘image’] = ‘cash.png’, [‘unique’] = true, [‘useable’] = false, [‘shouldClose’] = false, [‘combinable’] = nil, [‘description’] = ‘Clean £££’},

5 Likes

I’m sorry, but its been a while and i forgot how to create a post, so hopefully you can help me here. I just started playing with qbcore and kinda getting the hang of most things. I have 2 issues that i can’t seem to figure out!

1.) when i make my daughters and admin, in php and in game they keep their status through TX but when they login, every time and do /admin it doesn’t have the permissions. I have to give it to them everytime in game. Also when they have admin they can’t check their personal items such as /job /bank /cash etc. but if i make them a user they can … any thoughts?

2.) I have the police job all set and even the boss menu. everything works except the armory. It will open but I can’t put any guns in my inventory, but can put ammo and such. Same with hardward stores… it will transfer over to the inventory but dissapear immediately after i leave. I 'm assuming it something with sql or something but it doesn’t have an sql with files and no errors. I just need pointed in the right direction … please?

1 Like

By PHP, I assume you mean in phpMyAdmin that came with XAMPP? If so, just to make sure, did you add their details in the permissions table?

yes I did. Their TX admin works but you can’t do everything with that one vs /admin. I think i did it right. i have their ID / Name / License and permission as admin. grabbed their license from player. Yes it is by PHP. I also just put in a whole new inventory system so i have that working right now. the admin thing is the most frustrating right now. especially that i have to do it everytime and when i do give it to them they can’t see their /job /bank etc… says they do not have access to that command

Does your permissions table look like so?

You can get the players license on txAdmin when they’re connected.

1 Like

yes It does look like that. Would there be a possibility that the key is different than the one in the players section of myphpadmin? because that is where i got the license from to transfer to the permissions section.

Get your daughters to connect to the server and then grab their license details from txAdmin.

1 Like

So they have the TX menu it’s the qbcore menu like /admin that doesn’t work as well as certain commands. also does this have anything to do with it in my server.cfg?

Add system admins

add_ace resource.qb-core command allow
add_ace group.admin command allow # allow all commands
add_ace group.admin command.quit deny # but don’t allow quit
add_principal identifier.fivem: ******* group.admin #myname < < blanked out just in case for security

1 Like

No, get your daughters to connect to the server and then grab their usernames and license details from txAdmin. From there, insert those details into the permissions table in the MySQL database using phpMyAdmin (as shown in the above screenshot).

1 Like

it is the exact same that was already in there?

  1. add money call function on the function of AddItem(name, amount, slot, info)
  2. remove money call function on the function of RemoveItem(name, amount, slot)
    If you do those 2 on your edit, your core will loop the give-remove item coz you put them on addmoney or remove money and that’s a wrong method, because if ppl will trade/drop/store item into stash/etc will decut only item and not actual balance.
1 Like

Just to make sure, you’ve restarted the server since?

Multiple times … someone said something about /setgroup but now i can’t even do that within the game

I finally got it working… thank you so much… i had to add a bunch of different permissions in the server.cfg for qb-core and also i think the main thing is the players were scuffed. I removed the players in the database and had them re-create them and everything is working as intended!

1 Like

No worries. If any replies helped, don’t forget to like/heart the post :slight_smile:

2 Likes

I’m still having the same issue trying to avoid another wipe. It was a wipe that got me in this predicament in the first place lol. May I ask what you had to do with your cfg? I’ve done ace permissions but unsure if done correctly

1 Like

Are u using qbcore ? If so I will send u the code I changed and what I put in there and what else I did when I get home