Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
fix(server): remove all mentions of health column
Browse files Browse the repository at this point in the history
Somehow I managed to completely forget to do this, which was causing the resource not to work at all for new installs
  • Loading branch information
LukeWasTakenn committed May 16, 2022
1 parent c199a82 commit 1b86dcc
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions server/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ lib.callback.register('luke_garages:GetVehicles', function(source, garageType, j
local vehicles = {}

if not job then
local results = MySQL.Sync.fetchAll("SELECT `plate`, `vehicle`, `stored`, `health`, `garage`, `job` FROM `owned_vehicles` WHERE `owner` = @identifier AND `type` = @type", {
local results = MySQL.Sync.fetchAll("SELECT `plate`, `vehicle`, `stored`, `garage`, `job` FROM `owned_vehicles` WHERE `owner` = @identifier AND `type` = @type", {
['@identifier'] = identifier,
['@type'] = garageType
})
Expand All @@ -25,8 +25,7 @@ lib.callback.register('luke_garages:GetVehicles', function(source, garageType, j
local result = results[i]
if not result.job or result.job == 'civ' then
local veh = json.decode(result.vehicle)
local health = json.decode(result.health)
vehicles[#vehicles+1] = {plate = result.plate, vehicle = veh, stored = result.stored, health = health, garage = result.garage}
vehicles[#vehicles+1] = {plate = result.plate, vehicle = veh, stored = result.stored, garage = result.garage}
end
end

Expand All @@ -35,7 +34,7 @@ lib.callback.register('luke_garages:GetVehicles', function(source, garageType, j
else
local jobs = {}
if type(job) == 'table' then for k, _ in pairs(job) do jobs[#jobs+1] = k end else jobs = job end
local results = MySQL.Sync.fetchAll('SELECT `plate`, `vehicle`, `stored`, `health`, `garage` FROM `owned_vehicles` WHERE (`owner` = @identifier OR `owner` IN (@jobs)) AND `type` = @type AND `job` IN (@jobs)', {
local results = MySQL.Sync.fetchAll('SELECT `plate`, `vehicle`, `stored`, `garage` FROM `owned_vehicles` WHERE (`owner` = @identifier OR `owner` IN (@jobs)) AND `type` = @type AND `job` IN (@jobs)', {
['@identifier'] = identifier,
['@type'] = garageType,
['@jobs'] = jobs
Expand All @@ -44,8 +43,7 @@ lib.callback.register('luke_garages:GetVehicles', function(source, garageType, j
for i = 1, #results do
local result = results[i]
local veh = json.decode(result.vehicle)
local health = json.decode(result.health)
vehicles[#vehicles+1] = {plate = result.plate, vehicle = veh, stored = result.stored, health = health, garage = result.garage}
vehicles[#vehicles+1] = {plate = result.plate, vehicle = veh, stored = result.stored, garage = result.garage}
end

return vehicles
Expand All @@ -60,7 +58,7 @@ lib.callback.register('luke_garages:GetImpound', function(source, type)

local worldVehicles = GetAllVehicles()

local results = MySQL.Sync.fetchAll('SELECT `plate`, `vehicle`, `health`, `job` FROM owned_vehicles WHERE (`owner` = @identifier OR `owner` = @job) AND `type` = @type AND `stored` = 0', {
local results = MySQL.Sync.fetchAll('SELECT `plate`, `vehicle`, `job` FROM owned_vehicles WHERE (`owner` = @identifier OR `owner` = @job) AND `type` = @type AND `stored` = 0', {
['@identifier'] = identifier,
['@type'] = type,
['@job'] = xPlayer.job.name
Expand All @@ -69,7 +67,6 @@ lib.callback.register('luke_garages:GetImpound', function(source, type)
for i = 1, #results do
local result = results[i]
local veh = json.decode(result.vehicle)
local health = json.decode(result.health)
for index = 1, #worldVehicles do
local vehicle = worldVehicles[index]
if ESX.Math.Trim(result.plate) == ESX.Math.Trim(GetVehicleNumberPlateText(vehicle)) then
Expand All @@ -79,7 +76,7 @@ lib.callback.register('luke_garages:GetImpound', function(source, type)
elseif index == #worldVehicles then
-- Allows players to only get their job vehicle from impound while having the job
if (result.job == 'civ' or result.job == nil) or result.job == xPlayer.job.name then
vehicles[#vehicles+1] = {plate = result.plate, vehicle = veh, health = health}
vehicles[#vehicles+1] = {plate = result.plate, vehicle = veh}
end
end
end
Expand Down Expand Up @@ -185,7 +182,7 @@ RegisterNetEvent('luke_garages:SpawnVehicle', function(model, plate, coords, hea
return xPlayer.showNotification(Locale('vehicle_already_exists')) end
end
end
MySQL.Async.fetchAll('SELECT vehicle, plate, health, garage FROM `owned_vehicles` WHERE plate = @plate', {['@plate'] = ESX.Math.Trim(plate)}, function(result)
MySQL.Async.fetchAll('SELECT vehicle, plate, garage FROM `owned_vehicles` WHERE plate = @plate', {['@plate'] = ESX.Math.Trim(plate)}, function(result)
if result[1] then
CreateThread(function()
local entity = Citizen.InvokeNative(`CREATE_AUTOMOBILE`, model, coords.x, coords.y, coords.z, heading)
Expand Down

0 comments on commit 1b86dcc

Please sign in to comment.