2025-06-07 22:50:13 -04:00
|
|
|
---@diagnostic disable: duplicate-set-field
|
2025-03-04 22:24:19 -05:00
|
|
|
local resourceName = "F_RealCarKeysSystem"
|
2025-05-18 23:45:37 -04:00
|
|
|
if GetResourceState(resourceName) == 'missing' then return end
|
2025-08-21 01:23:58 +02:00
|
|
|
|
2025-02-07 19:43:11 +00:00
|
|
|
VehicleKey = VehicleKey or {}
|
2025-02-07 19:25:33 +00:00
|
|
|
|
2025-08-21 01:23:58 +02:00
|
|
|
---Gives the player (self) the keys of the specified vehicle.
|
|
|
|
|
---@param vehicle number The vehicle entity handle.
|
|
|
|
|
---@param plate? string The plate of the vehicle.
|
|
|
|
|
---@return nil
|
2025-02-07 19:33:03 +00:00
|
|
|
VehicleKey.GiveKeys = function(vehicle, plate)
|
2025-08-21 01:23:58 +02:00
|
|
|
assert(vehicle, "vehicle is nil")
|
|
|
|
|
assert(DoesEntityExist(vehicle), "vehicle does not exist")
|
|
|
|
|
|
|
|
|
|
if not plate then
|
|
|
|
|
plate = GetVehicleNumberPlateText(vehicle)
|
|
|
|
|
end
|
|
|
|
|
|
2025-02-07 19:33:03 +00:00
|
|
|
TriggerServerEvent('F_RealCarKeysSystem:generateVehicleKeys', plate)
|
2025-02-07 19:25:33 +00:00
|
|
|
end
|
|
|
|
|
|
2025-08-21 01:23:58 +02:00
|
|
|
-- TODO: Test, documentation of the script is missing
|
|
|
|
|
|
|
|
|
|
---Removes the keys of the specified vehicle from the player (self).
|
|
|
|
|
---@param vehicle number The vehicle entity handle.
|
|
|
|
|
---@param plate? string The plate of the vehicle.
|
|
|
|
|
---@return nil
|
2025-02-07 19:33:03 +00:00
|
|
|
VehicleKey.RemoveKeys = function(vehicle, plate)
|
2025-08-21 01:23:58 +02:00
|
|
|
assert(vehicle, "vehicle is nil")
|
|
|
|
|
assert(DoesEntityExist(vehicle), "vehicle does not exist")
|
|
|
|
|
|
|
|
|
|
if not plate then
|
|
|
|
|
plate = GetVehicleNumberPlateText(vehicle)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
TriggerServerEvent('F_RealCarKeysSystem:removeVehicleKeysByPlate', plate)
|
2025-02-07 19:25:33 +00:00
|
|
|
end
|
2025-05-10 00:01:56 -04:00
|
|
|
|
|
|
|
|
return VehicleKey
|