Hello. So I want to make esx_vehicleshop show only specific category if the player has got certain job. For example: if he is police member then I want to show only police named category in the shop menu. I tried checking the job in the server.lua but that doesn’t work properly and I don’t have an idea how to make it in client.lua.
server.lua
MySQL.ready(function()
local vehicles
if ESX.PlayerData.job.name == 'legion' then
Categories = MySQL.Sync.fetchAll('SELECT * FROM vehicle_categories WHERE name = @name', {
['@name'] = 'legionveh',
})
vehicles = MySQL.Sync.fetchAll('SELECT * FROM vehicles WHERE category = @category', {
['@category'] = 'legionveh',
})
else
Categories = MySQL.Sync.fetchAll('SELECT * FROM vehicle_categories')
vehicles = MySQL.Sync.fetchAll('SELECT * FROM vehicles')
end
for i=1, #vehicles, 1 do
local vehicle = vehicles[i]
for j=1, #Categories, 1 do
if Categories[j].name == vehicle.category then
vehicle.categoryLabel = Categories[j].label
break
end
end
table.insert(Vehicles, vehicle)
end
-- send information after db has loaded, making sure everyone gets vehicle information
TriggerClientEvent('esx_vehicleshop:sendCategories', -1, Categories)
TriggerClientEvent('esx_vehicleshop:sendVehicles', -1, Vehicles)
end)
Any tips appreciated.