Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- config = {}
- config.cars = {} -- Do not touch
- config.presets = {} -- Do not touch
- config.maxNum = 0 -- Do not touch
- ESX = nil
- TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
- config.GetUserJob = function(xPlayer)
- return xPlayer.job.name
- end
- config.GetUserJobGrade = function(xPlayer)
- return xPlayer.job.grade
- end
- config.GetUserItem = function(xPlayer)
- return xPlayer.getInventoryItem(config.ItemName).count
- end
- config.xPlayer = function(src)
- local xPlayer = ESX.GetPlayerFromId(src)
- return xPlayer
- end
- config.JobLocked = true
- config.Jobs = {
- ['mechanic'] = {
- minGrade = 1
- },
- ['taxi'] = {
- minGrade = 1
- },
- }
- config.CommandNeedItem = false
- config.UseItem = true
- config.ItemName = 'bread'
- config.RemoveItemOnUse = false
- if config.UseItem then
- ESX.RegisterUsableItem(config.ItemName, function(source)
- local xPlayer = ESX.GetPlayerFromId(source)
- local item = xPlayer.getInventoryItem(config.ItemName).count
- if item >= 1 then
- if config.RemoveItemOnUse then
- xPlayer.removeInventoryItem(config.ItemName, 1)
- end
- TriggerEvent('broker-OpenTuningLaptop', source)
- end
- end)
- end
- -- Database queries
- config.GetAllPresets = function()
- MySQL.query('SELECT * FROM broker_presets', function(result)
- for k, v in pairs(result) do
- if v.id > config.maxNum then
- config.maxNum = v.id
- end
- if not config.presets[v.owner] then
- config.presets[v.owner] = {}
- end
- table.insert( config.presets[v.owner], {id = v.id, label = v.label, tuning = v.tuning, owner = v.owner})
- end
- end)
- end
- config.GetAllTunings = function()
- MySQL.query('SELECT * FROM broker_tunings', function(result)
- for k, v in pairs(result) do
- config.cars[v.plate] = v.tuning
- end
- end)
- end
- config.SavePreset = function(tuning, label, player)
- MySQL.update('INSERT INTO broker_presets (tuning, label, owner) VALUES (@tuning, @label, @owner)',
- {
- ['@tuning'] = tuning,
- ['@label'] = label,
- ['@owner'] = player
- })
- end
- config.UpdateTuning = function(plate, tune)
- MySQL.update('UPDATE broker_tunings SET tuning = @tuning WHERE plate = @plate',
- {
- ['@plate'] = plate,
- ['@tuning'] = tune
- })
- end
- config.SaveTuning = function(plate, tune)
- MySQL.update('INSERT INTO broker_tunings (plate, tuning) VALUES (@plate, @tuning)',
- {
- ['@plate'] = plate,
- ['@tuning'] = tune
- })
- end
- config.ResetTuning = function(plate)
- MySQL.update('DELETE FROM broker_tunings WHERE plate = @plate',
- {
- ['@plate'] = plate
- })
- end
- config.DeletePreset = function(id)
- MySQL.update('DELETE FROM broker_presets WHERE id = @id',
- {
- ['@id'] = id
- })
- end
Advertisement
Add Comment
Please, Sign In to add comment