From 5bf24e50b52f2c42c7a483c5c003ae92bf2e1648 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 30 Dec 2018 23:37:55 +0100 Subject: [PATCH] New code for job vehicles --- server/main.lua | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/server/main.lua b/server/main.lua index 4dff25a8..48663aa0 100644 --- a/server/main.lua +++ b/server/main.lua @@ -446,13 +446,40 @@ ESX.RegisterServerCallback('esx_vehicleshop:getPlayerInventory', function (sourc end) ESX.RegisterServerCallback('esx_vehicleshop:isPlateTaken', function (source, cb, plate) - MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE @plate = plate', { + MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE plate = @plate', { ['@plate'] = plate }, function (result) cb(result[1] ~= nil) end) end) +ESX.RegisterServerCallback('esx_vehicleshop:retrieveJobVehicles', function (source, cb, type) + local xPlayer = ESX.GetPlayerFromId(source) + + MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND type = @type AND job = @job', { + ['@owner'] = xPlayer.identifier, + ['@type'] = type, + ['@job'] = xPlayer.job.name + }, function (result) + cb(result) + end) +end) + +RegisterServerEvent('esx_vehicleshop:setJobVehicleState') +AddEventHandler('esx_vehicleshop:setJobVehicleState', function(plate, state) + local xPlayer = ESX.GetPlayerFromId(source) + + MySQL.Async.execute('UPDATE owned_vehicles SET stored = @stored WHERE plate = @plate AND job = @job', { + ['@stored'] = state, + ['@plate'] = plate, + ['@job'] = xPlayer.job.name + }, function(rowsChanged) + if rowsChanged == 0 then + print(('esx_vehicleshop: %s exploited the garage!'):format(xPlayer.identifier)) + end + end) +end) + function PayRent(d, h, m) MySQL.Async.fetchAll('SELECT * FROM rented_vehicles', {}, function (result) for i=1, #result, 1 do