qs-smartphone
qs-smartphone integration with our garage system.
2
Insert this data to the file:
if Config.Garage ~= 'op-garages' then
return
end
RegisterNetEvent('phone:setVehicleToOutSide', function(plate)
local str = [[
UPDATE owned_vehicles
SET stored = 1
WHERE plate = ?
]]
if Config.Framework == 'qb' then
str = [[
UPDATE player_vehicles
SET state = 1
WHERE plate = ?
]]
end
MySQL.Sync.execute(str, { plate })
end)
function getGarageData(identifier, plate)
local str = [[
SELECT * FROM owned_vehicles WHERE owner = ? AND (type = 'vehicle' OR type = 'car')
]]
if Config.Framework == 'qb' then
str = [[
SELECT * FROM player_vehicles WHERE citizenid = ?
]]
end
if plate then
str = str .. ([[
AND plate = "%s"
]]):format(plate)
end
local result = MySQL.Sync.fetchAll(str, { identifier })
if not result[1] then return false end
local data = {}
if Config.Framework == 'qb' then
for k, v in pairs(result) do
local inGarage = true
local garageId = v.vehicleGarage
if v.state == 1 then
inGarage = false
end
local garageObject = GlobalState.garages[tostring(garageId)]
if garageObject then
garageId = garageObject.Label
end
if inGarage then
table.insert(data, {
name = v.vehicle,
plate = v.plate,
inGarage = inGarage,
fuel = v.fuel * 10 or 1000,
engine = v.engine or 1000,
body = v.body or 1000,
vehicle = json.decode(v.mods),
garage = garageId,
})
end
end
else
for k, v in pairs(result) do
local vehicle = json.decode(v.vehicle)
if not vehicle then return end
local inGarage = true
local garageId = v.vehicleGarage
if v.stored == 1 then
inGarage = false
end
local garageObject = GlobalState.garages[tostring(garageId)]
if garageObject then
garageId = garageObject.Label
end
if inGarage then
table.insert(data, {
name = vehicle.model,
plate = v.plate,
inGarage = inGarage,
fuel = v.fuel * 10 or 1000,
engine = vehicle.engine or 1000,
body = vehicle.body or 1000,
vehicle = json.decode(v.vehicle),
garage = garageId,
})
end
end
end
return data
end
Last updated