diff --git a/server/main.lua b/server/main.lua index 36de1d1..b752fdd 100644 --- a/server/main.lua +++ b/server/main.lua @@ -32,6 +32,7 @@ exports('DoesPlayerVehiclePlateExist', doesEntityPlateExist) ---@field state State ---@field depotPrice integer ---@field props table ox_lib properties table +---@field coords table vector4 ---@class PlayerVehiclesFilters ---@field citizenid? string @@ -82,7 +83,7 @@ end ---@param filters? PlayerVehiclesInternalFilters ---@return PlayerVehicle[] local function getPlayerVehiclesInternal(filters) - local query = 'SELECT id, citizenid, vehicle, mods, garage, state, depotprice FROM player_vehicles' + local query = 'SELECT id, citizenid, vehicle, mods, garage, state, depotprice, coords FROM player_vehicles' local whereClause, placeholders = buildWhereClause(filters) lib.print.debug(query .. whereClause) local results = MySQL.query.await(query .. whereClause, placeholders) @@ -95,7 +96,8 @@ local function getPlayerVehiclesInternal(filters) garage = data.garage, state = data.state, depotPrice = data.depotprice, - props = json.decode(data.mods) + props = json.decode(data.mods), + coords = json.decode(data.coords) } end return ownedVehicles @@ -217,6 +219,7 @@ exports('GetVehicleIdByPlate', getVehicleIdByPlate) ---@field state? State ---@field depotPrice? integer ---@field props? table ox_lib properties table +---@field coords? table vector4 ---@param vehicleId integer ---@param options SaveVehicleOptions @@ -265,6 +268,11 @@ local function buildSaveVehicleQuery(vehicleId, options) end end + if options.coords then + crumbs[#crumbs+1] = 'coords = ?' + placeholders[#placeholders+1] = json.encode(options.coords) + end + placeholders[#placeholders+1] = vehicleId return string.format('UPDATE player_vehicles SET %s WHERE id = ?', table.concat(crumbs, ',')), placeholders diff --git a/vehicles.sql b/vehicles.sql index 779b301..f733419 100644 --- a/vehicles.sql +++ b/vehicles.sql @@ -15,6 +15,7 @@ CREATE TABLE IF NOT EXISTS `player_vehicles` ( `depotprice` int(11) NOT NULL DEFAULT 0, `drivingdistance` int(50) DEFAULT NULL, `status` text DEFAULT NULL, + `coords` text NOT NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `plate` (`plate`), FOREIGN KEY (`citizenid`) REFERENCES `players` (`citizenid`) ON DELETE CASCADE ON UPDATE CASCADE,