Setting up the server side handlers and functions
There are multiple examples shown in the config, and it is already prepared to ESX frameworks using OX Lib and OX Inventory
Config.RemoveMoney = function(source, amount) -- remove money function, you can set your inventory here as you like
exports.ox_inventory:RemoveItem(source, 'money', amount) -- xPlayer.removeInventoryItem('money', count)
end
Config.GetMoney = function(source) -- get the money, always returns a number, you can set here your inventory as you like
local money = exports.ox_inventory:GetItem(source, 'money', nil, true) -- xPlayer.getInventoryItem(item).count
return money
end
Config.Query = function(source, data)
-- you can put your custom query with your data-s, encode the data table to find which values are in it.
-- the query must be a STRING, and the additional informations must be in a table as the example shows.
local xPlayer = ESX.GetPlayerFromId(source) -- QBCore.Functions.GetPlayer(source)
local owner = xPlayer.identifier -- QBCore.Functions.GetIdentifier(source)
local properties = data.properties
local plate = data.plate
local query = 'INSERT INTO owned_vehicles (owner, plate, vehicle) VALUES (?,?,?)'
return query, {owner, plate, json.encode(properties)}
end
Last updated
Was this helpful?