refactor(vehicleKey): enhance key management functions with assertions, improved documentation and remove vehicle keys where they was missing
This commit is contained in:
1 parent
3289711297
commit
9e810d4b24
13 files changed
+271
-44
No files matched your search
@@ -4,14 +4,28 @@ if GetResourceState(resourceName) == 'missing' then return end
|
||||
|
||||
VehicleKey = VehicleKey or {}
|
||||
|
||||
---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
|
||||
VehicleKey.GiveKeys = function(vehicle, plate)
|
||||
if not DoesEntityExist(vehicle) then return false end
|
||||
local vehicle_display_name = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))
|
||||
return exports['t1ger_keys']:GiveTemporaryKeys(plate, vehicle_display_name, 'some_keys')
|
||||
assert(vehicle, "vehicle is nil")
|
||||
assert(DoesEntityExist(vehicle), "vehicle does not exist")
|
||||
|
||||
if not plate then
|
||||
plate = GetVehicleNumberPlateText(vehicle)
|
||||
end
|
||||
|
||||
local model = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))
|
||||
return exports['t1ger_keys']:GiveTemporaryKeys(plate, model, '')
|
||||
end
|
||||
|
||||
---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
|
||||
VehicleKey.RemoveKeys = function(vehicle, plate)
|
||||
|
||||
Prints.Info("t1ger_keys doesnt support removing keys.")
|
||||
end
|
||||
|
||||
return VehicleKey
|
||||
Reference in new issue
Block a user