mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-18 22:36:04 +01:00
Update vehicles.lua
This commit is contained in:
@@ -299,4 +299,34 @@ function getClosestVehicle(coords, src)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return closestVehicle, closestDistance
|
return closestVehicle, closestDistance
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks whether a vehicle is owned or not using the plate as reference
|
||||||
|
---
|
||||||
|
--- @param plate string The plate of the vehicle to check
|
||||||
|
--- @return boolean whether vehicle is owned
|
||||||
|
---
|
||||||
|
--- @usage
|
||||||
|
--- ```lua
|
||||||
|
--- local plate = "ABCD1234"
|
||||||
|
--- local isVehicleOwned = isVehicleOwned(plate)
|
||||||
|
--- ```
|
||||||
|
local vehiclesOwned = {}
|
||||||
|
|
||||||
|
function isVehicleOwned(plate)
|
||||||
|
vehDatabase = "player_vehicles"
|
||||||
|
if isStarted(ESXExport) then vehDatabase = "owned_vehicles"
|
||||||
|
elseif isStarted(OXCoreExport) then vehDatabase = "vehicles" end
|
||||||
|
|
||||||
|
if vehiclesOwned[plate] == true then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
local result = MySQL.query.await("SELECT 1 from "..vehDatabase.." WHERE plate = ?", { plate })
|
||||||
|
if json.encode(result) ~= "[]" then
|
||||||
|
vehiclesOwned[plate] = true
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user