ESX basic needs issue

Hello everyone esx-interested ^^ Since a couple of days i have a little issue. I am currently setting up an esx system on a gta v server. Most things worked fine but now my basic needs seems to be broken somehow. I tried various things and read through post and forum but did not find something similar.

Problem: When entering the marker in a shop the menu shows up, items are shown and selectable. But when i try to buy them the items are not transferred into the inventory neither is any money withdrawn from bank or wallet. I completely changed the esx basic needs and status folder but no change. Could it be issues with the ZAP Hosting Database? I read about the mixup in the shops table with store and shop. But when I switch to shops…nothing shows up in the store. (using esx shops). Any ideas where i could possibly find the reason for this?

Thanks for your help

The problem isn’t basicneeds, it’s probably your esx_shops

1 Like

Thanks for the reply. I will remove the esx_shops and try again.

Tried and removed esx_shops and checked again. I also tried to change the name of the table under items from “limit” to “weight”. Also edited the sql to implement but everything seems finde. Maybe there is issue here?

Serverside main.lua:

ESX = nil
local ShopItems = {}

TriggerEvent(‘esx:getSharedObject’, function(obj) ESX = obj end)

MySQL.ready(function()
MySQL.Async.fetchAll(‘SELECT * FROM shops LEFT JOIN items ON items.name = shops.item’, {}, function(shopResult)
for i=1, #shopResult, 1 do
if shopResult[i].name then
if ShopItems[shopResult[i].store] == nil then
ShopItems[shopResult[i].store] = {}
end

			table.insert(ShopItems[shopResult[i].store], {
				label = shopResult[i].label,
				item  = shopResult[i].item,
				price = shopResult[i].price,
			})
		else
			print(('esx_shops: invalid item "%s" found!'):format(shopResult[i].item))
		end
	end
end)

end)

ESX.RegisterServerCallback(‘esx_shops:requestDBItems’, function(source, cb)
cb(ShopItems)
end)

RegisterServerEvent(‘esx_shops:buyItem’)
AddEventHandler(‘esx_shops:buyItem’, function(itemName, amount, zone)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)

amount = ESX.Math.Round(amount)

-- is the player trying to exploit?
if amount < 0 then
	print('esx_shops: ' .. xPlayer.identifier .. ' attempted to exploit the shop!')
	return
end

-- get price
local price = 0
local itemLabel = ''

for i=1, #ShopItems[zone], 1 do
	if ShopItems[zone][i].item == itemName then
		price = ShopItems[zone][i].price
		itemLabel = ShopItems[zone][i].label
		break
	end
end

price = price * amount

-- can the player afford this item?
if xPlayer.getMoney() >= price then
	-- can the player carry the said amount of x item?
	if xPlayer.canCarryItem(itemName, amount) then
		xPlayer.removeMoney(price)
		xPlayer.addInventoryItem(itemName, amount)
		xPlayer.showNotification(_U('bought', amount, itemLabel, ESX.Math.GroupDigits(price)))
	else
		xPlayer.showNotification(_U('player_cannot_hold'))
	end
else
	local missingMoney = price - xPlayer.getMoney()
	xPlayer.showNotification(_U('not_enough', ESX.Math.GroupDigits(missingMoney)))
end

end)

clientside main.lua:

ESX = nil
local hasAlreadyEnteredMarker, lastZone
local currentAction, currentActionMsg, currentActionData = nil, nil, {}

Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent(‘esx:getSharedObject’, function(obj) ESX = obj end)
Citizen.Wait(0)
end

Citizen.Wait(5000)

ESX.TriggerServerCallback('esx_shops:requestDBItems', function(ShopItems)
	for k,v in pairs(ShopItems) do
		Config.Zones[k].Items = v
	end
end)

end)

function OpenShopMenu(zone)
local elements = {}
for i=1, #Config.Zones[zone].Items, 1 do
local item = Config.Zones[zone].Items[i]

	table.insert(elements, {
		label      = ('%s - <span style="color:green;">%s</span>'):format(item.label, _U('shop_item', ESX.Math.GroupDigits(item.price))),
		itemLabel = item.label,
		item       = item.item,
		price      = item.price,

		-- menu properties
		value      = 1,
		type       = 'slider',
		min        = 1,
		max        = 100
	})
end

ESX.UI.Menu.CloseAll()

ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop', {
	title    = _U('shop'),
	align    = 'bottom-right',
	elements = elements
}, function(data, menu)
	ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', {
		title    = _U('shop_confirm', data.current.value, data.current.itemLabel, ESX.Math.GroupDigits(data.current.price * data.current.value)),
		align    = 'bottom-right',
		elements = {
			{label = _U('no'),  value = 'no'},
			{label = _U('yes'), value = 'yes'}
	}}, function(data2, menu2)
		if data2.current.value == 'yes' then
			TriggerServerEvent('esx_shops:buyItem', data.current.item, data.current.value, zone)
		end

		menu2.close()
	end, function(data2, menu2)
		menu2.close()
	end)
end, function(data, menu)
	menu.close()

	currentAction     = 'shop_menu'
	currentActionMsg  = _U('press_menu')
	currentActionData = {zone = zone}
end)

end

AddEventHandler(‘esx_shops:hasEnteredMarker’, function(zone)
currentAction = ‘shop_menu’
currentActionMsg = _U(‘press_menu’)
currentActionData = {zone = zone}
end)

AddEventHandler(‘esx_shops:hasExitedMarker’, function(zone)
currentAction = nil
ESX.UI.Menu.CloseAll()
end)

– Create Blips
Citizen.CreateThread(function()
for k,v in pairs(Config.Zones) do
for i = 1, #v.Pos, 1 do
local blip = AddBlipForCoord(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z)

		SetBlipSprite (blip, 52)
		SetBlipScale  (blip, 1.0)
		SetBlipColour (blip, 2)
		SetBlipAsShortRange(blip, true)

		BeginTextCommandSetBlipName('STRING')
		AddTextComponentSubstringPlayerName(_U('shops'))
		EndTextCommandSetBlipName(blip)
	end
end

end)

– Enter / Exit marker events
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerCoords = GetEntityCoords(PlayerPedId())
local isInMarker, letSleep, currentZone = false, false

	for k,v in pairs(Config.Zones) do
		for i = 1, #v.Pos, 1 do
			local distance = GetDistanceBetweenCoords(playerCoords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true)

			if distance < Config.DrawDistance then
				DrawMarker(Config.Type, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, nil, nil, false)
				letSleep = false

				if distance < Config.Size.x then
					isInMarker  = true
					currentZone = k
					lastZone    = k
				end
			end
		end
	end

	if isInMarker and not hasAlreadyEnteredMarker then
		hasAlreadyEnteredMarker = true
		TriggerEvent('esx_shops:hasEnteredMarker', currentZone)
	end

	if not isInMarker and hasAlreadyEnteredMarker then
		hasAlreadyEnteredMarker = false
		TriggerEvent('esx_shops:hasExitedMarker', lastZone)
	end

	if letSleep then
		Citizen.Wait(500)
	end
end

end)

– Key Controls
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)

	if currentAction then
		ESX.ShowHelpNotification(currentActionMsg)

		if IsControlJustReleased(0, 38) then
			if currentAction == 'shop_menu' then
				OpenShopMenu(currentActionData.zone)
			end

			currentAction = nil
		end
	else
		Citizen.Wait(500)
	end
end

end)

And the used SQL File:

USE essentialmode;

CREATE TABLE shops (
id int(11) NOT NULL AUTO_INCREMENT,
store varchar(100) NOT NULL,
item varchar(100) NOT NULL,
price int(11) NOT NULL,

PRIMARY KEY (`id`)

);

INSERT INTO shops (store, item, price) VALUES
(‘TwentyFourSeven’,‘bread’,30),
(‘TwentyFourSeven’,‘water’,15),
(‘RobsLiquor’,‘bread’,30),
(‘RobsLiquor’,‘water’,15),
(‘LTDgasoline’,‘bread’,30),
(‘LTDgasoline’,‘water’,15)
;

maybe someone notices a mistake. I did not change a thing in those files.

And the server.cfg. Might be an issue of the current load order? But basically from the docs just status and es extended are needed.

You probably don’t want to change these!

Only change them if you’re using a server with multiple network interfaces.

These resources will start by default.

start mapmanager
start chat
start spawnmanager
start sessionmanager
start fivem
start hardcap
exec resources/vMenu/config/permissions.cfg
add_ace group.admin “vMenu.Everything” allow
setr vmenu_bans_database_filepath “resources/vMenu/”
start vMenu
start ■■■■■■■
start RPDeath
start scoreboard
start baseevents

start bob74_ipl
start trafficadjuster
start PvP

MYSQL ASYNC

start async
start mysql-async
start essentialmode
start esplugin_mysql
start es_admin2
start es_ui
add_ace resource.essentialmode command.add_principal allow
add_ace resource.essentialmode command.add_ace allow
start ghmattimysql

ESSENTIAL MODS

start es_extended

ESX REQUIRED MODS

start instance
start cron
start skinchanger
start esx_skin
start esx_menu_default
start esx_menu_list
start esx_menu_dialog
start esx_addonaccount
start esx_addoninventory
start esx_datastore
start esx_society
start esx_service
start esx_billing

start esx_kashacters
start esx_voice
start esx_phone

start pNotify

#ESX JOBS

start esx_jobs
start esx_joblisting
start esx_mechanicjob
start esx_policejob
start esx_criminalrecords
start esx_property
start esx_realestateagentjob
start esx_bankerjob
start esx_ambulancejob
start esx_vehicleshop
#start esx_truckshop
start esx_taxijob

#ESX ANY OTHER MODS

start esx_garage
start esx_license
start esx_weaponshop
start esx_drugs
start esx_identity
start esx_dmvschool
start esx_lscustom
start esx_clotheshop
start esx_camera
start esx_holdup
start esx_atm
start esx_barbershop

start esx_animations
start esx_jb_eden_garage2
start esx_accessories
start esx_boat
start esx_boilerplate
start esx_cruisecontrol
start esx_migrate
start esx_rpchat
start esx_sit
start esx_status
start esx_basicneeds

#ESX SHOPS

start esx_tattoosShops
start esx_shops

OTHER

start mapaddons
start ft_libs

#start Advanced911
start fivem-seatbelt

Try this shop plugin, In my opinion its much better

Not really, it’s not that good. I wouldn’t recommend a user that is having essential problems, a custom script that isn’t made by the original ESX coders because it will give him even more problems :stuck_out_tongue:

1 Like

The one i linked is legit plug and play like half of the plugins. ESX shops is shit anyway.

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