diff --git a/Attributions.md b/Attributions.md index a902bc1..bad4521 100644 --- a/Attributions.md +++ b/Attributions.md @@ -27,27 +27,6 @@ --- -### dirk\_lib - -**Purpose:** Vehicle fuel and vehicle key bridging systems -**Repository:** [dirk\_lib](https://github.com/DirkDigglerz/dirk_lib) - -
-Implementation Details - -**Code we use:** - -* Client-side vehicle fuel management -* Vehicle key bridging functionality - -**Modifications made:** - -* None - code used as-is with full credit to original author - -
- ---- - ### ox\_lib **Purpose:** External compatibility and architectural inspiration diff --git a/modules/fuel/_default/client.lua b/modules/fuel/_default/client.lua index 0e4e9c1..8430733 100644 --- a/modules/fuel/_default/client.lua +++ b/modules/fuel/_default/client.lua @@ -2,26 +2,28 @@ Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return 'default' end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return GetVehicleFuelLevel(vehicle) end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil -Fuel.SetFuel = function(vehicle, fuel) +Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end - return SetVehicleFuelLevel(vehicle, fuel) + SetVehicleFuelLevel(vehicle, fuel) end return Fuel \ No newline at end of file diff --git a/modules/fuel/bigDaddy-Fuel/client.lua b/modules/fuel/bigDaddy-Fuel/client.lua index 941f529..56b1721 100644 --- a/modules/fuel/bigDaddy-Fuel/client.lua +++ b/modules/fuel/bigDaddy-Fuel/client.lua @@ -3,25 +3,27 @@ local resourceName = "BigDaddy-Fuel" if GetResourceState(resourceName) == 'missing' then return end Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return resourceName end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['BigDaddy-Fuel']:GetFuel(vehicle) end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil -Fuel.SetFuel = function(vehicle, fuel) +Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end exports['BigDaddy-Fuel']:SetFuel(vehicle, fuel) end diff --git a/modules/fuel/cdn-fuel/client.lua b/modules/fuel/cdn-fuel/client.lua index c94ead0..c4fd02f 100644 --- a/modules/fuel/cdn-fuel/client.lua +++ b/modules/fuel/cdn-fuel/client.lua @@ -3,27 +3,29 @@ local resourceName = "cdn-fuel" if GetResourceState(resourceName) == 'missing' then return end Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return resourceName end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['cdn-fuel']:GetFuel(vehicle) end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil -Fuel.SetFuel = function(vehicle, fuel) +Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end - return exports['cdn-fuel']:SetFuel(vehicle, fuel) + exports['cdn-fuel']:SetFuel(vehicle, fuel) end return Fuel \ No newline at end of file diff --git a/modules/fuel/esx-sna-fuel/client.lua b/modules/fuel/esx-sna-fuel/client.lua index 8205284..87eefe7 100644 --- a/modules/fuel/esx-sna-fuel/client.lua +++ b/modules/fuel/esx-sna-fuel/client.lua @@ -3,25 +3,27 @@ local resourceName = "esx-sna-fuel" if GetResourceState(resourceName) == 'missing' then return end Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return resourceName end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['esx-sna-fuel']:GetFuel(vehicle) end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil -Fuel.SetFuel = function(vehicle, fuel) +Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end exports['esx-sna-fuel']:SetFuel(vehicle, fuel) end diff --git a/modules/fuel/lc_fuel/client.lua b/modules/fuel/lc_fuel/client.lua index 21b03a3..7471143 100644 --- a/modules/fuel/lc_fuel/client.lua +++ b/modules/fuel/lc_fuel/client.lua @@ -3,27 +3,29 @@ local resourceName = "lc_fuel" if GetResourceState(resourceName) == 'missing' then return end Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return resourceName end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports["lc_fuel"]:GetFuel(vehicle) end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end - return exports["lc_fuel"]:SetFuel(vehicle, fuel) + exports["lc_fuel"]:SetFuel(vehicle, fuel) end return Fuel \ No newline at end of file diff --git a/modules/fuel/legacyfuel/client.lua b/modules/fuel/legacyfuel/client.lua index 273f17d..49a875c 100644 --- a/modules/fuel/legacyfuel/client.lua +++ b/modules/fuel/legacyfuel/client.lua @@ -4,27 +4,29 @@ if GetResourceState(resourceName) == 'missing' then return end if GetResourceState("qb-fuel") == 'started' then return end Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return resourceName end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['LegacyFuel']:GetFuel(vehicle) end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end - return exports['LegacyFuel']:SetFuel(vehicle, fuel) + exports['LegacyFuel']:SetFuel(vehicle, fuel) end return Fuel \ No newline at end of file diff --git a/modules/fuel/okokGasStation/client.lua b/modules/fuel/okokGasStation/client.lua index 0069a12..f71a6c5 100644 --- a/modules/fuel/okokGasStation/client.lua +++ b/modules/fuel/okokGasStation/client.lua @@ -3,27 +3,29 @@ local resourceName = "okokGasStation" if GetResourceState(resourceName) == 'missing' then return end Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return resourceName end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['okokGasStation']:GetFuel(vehicle) end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end - return exports['okokGasStation']:SetFuel(vehicle, fuel) + exports['okokGasStation']:SetFuel(vehicle, fuel) end return Fuel \ No newline at end of file diff --git a/modules/fuel/ox_fuel/client.lua b/modules/fuel/ox_fuel/client.lua index 7008bab..c643b95 100644 --- a/modules/fuel/ox_fuel/client.lua +++ b/modules/fuel/ox_fuel/client.lua @@ -3,29 +3,30 @@ local resourceName = "ox_fuel" if GetResourceState(resourceName) == 'missing' then return end Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return resourceName end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return Entity(vehicle).state.fuel end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end - local currentFuel = Entity(vehicle).state.fuel - Entity(vehicle).state.fuel = currentFuel and currentFuel + fuel or fuel - return Entity(vehicle).state.fuel + local state = Entity(vehicle).state + state.fuel = (state.fuel or 0) + fuel end return Fuel \ No newline at end of file diff --git a/modules/fuel/ps-fuel/client.lua b/modules/fuel/ps-fuel/client.lua index f083538..520a6b6 100644 --- a/modules/fuel/ps-fuel/client.lua +++ b/modules/fuel/ps-fuel/client.lua @@ -3,27 +3,29 @@ local resourceName = "ps-fuel" if GetResourceState(resourceName) == 'missing' then return end Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return resourceName end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports["ps-fuel"]:GetFuel(vehicle) end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end - return exports["ps-fuel"]:SetFuel(vehicle, fuel) + exports["ps-fuel"]:SetFuel(vehicle, fuel) end return Fuel \ No newline at end of file diff --git a/modules/fuel/qb-fuel/client.lua b/modules/fuel/qb-fuel/client.lua index 581e7e6..8c57932 100644 --- a/modules/fuel/qb-fuel/client.lua +++ b/modules/fuel/qb-fuel/client.lua @@ -3,27 +3,29 @@ local resourceName = "qb-fuel" if GetResourceState(resourceName) == 'missing' then return end Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return resourceName end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['qb-fuel']:GetFuel(vehicle) end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end - return exports['qb-fuel']:SetFuel(vehicle, fuel) + exports['qb-fuel']:SetFuel(vehicle, fuel) end return Fuel \ No newline at end of file diff --git a/modules/fuel/qs-fuelstations/client.lua b/modules/fuel/qs-fuelstations/client.lua index ec4a91e..84e9e93 100644 --- a/modules/fuel/qs-fuelstations/client.lua +++ b/modules/fuel/qs-fuelstations/client.lua @@ -3,27 +3,29 @@ local resourceName = "qs-fuelstations" if GetResourceState(resourceName) == 'missing' then return end Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return resourceName end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['qs-fuelstations']:GetFuel(vehicle) end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil -Fuel.SetFuel = function(vehicle, fuel) +Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end - return exports['qs-fuelstations']:SetFuel(vehicle, fuel) + exports['qs-fuelstations']:SetFuel(vehicle, fuel) end return Fuel \ No newline at end of file diff --git a/modules/fuel/renewed-Fuel/client.lua b/modules/fuel/renewed-Fuel/client.lua index 0408a99..c5c0b90 100644 --- a/modules/fuel/renewed-Fuel/client.lua +++ b/modules/fuel/renewed-Fuel/client.lua @@ -3,27 +3,29 @@ local resourceName = "Renewed-Fuel" if GetResourceState(resourceName) == 'missing' then return end Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return resourceName end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end return exports['Renewed-Fuel']:GetFuel(vehicle) end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end - return exports['Renewed-Fuel']:SetFuel(vehicle, fuel) + exports['Renewed-Fuel']:SetFuel(vehicle, fuel) end return Fuel \ No newline at end of file diff --git a/modules/fuel/ti_fuel/client.lua b/modules/fuel/ti_fuel/client.lua index 7c9e77d..005a078 100644 --- a/modules/fuel/ti_fuel/client.lua +++ b/modules/fuel/ti_fuel/client.lua @@ -3,28 +3,30 @@ local resourceName = "ti_fuel" if GetResourceState(resourceName) == 'missing' then return end Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return resourceName end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end local level, _ = exports["ti_fuel"]:getFuel(vehicle) return level end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil -Fuel.SetFuel = function(vehicle, fuel) +Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end - return exports['ti_fuel']:setFuel(vehicle, fuel, "RON91") + exports['ti_fuel']:setFuel(vehicle, fuel, type or "RON91") end return Fuel \ No newline at end of file diff --git a/modules/fuel/x-fuel/client.lua b/modules/fuel/x-fuel/client.lua index fc2d054..712c5de 100644 --- a/modules/fuel/x-fuel/client.lua +++ b/modules/fuel/x-fuel/client.lua @@ -3,26 +3,28 @@ local resourceName = "x-fuel" if GetResourceState(resourceName) == 'missing' then return end Fuel = Fuel or {} ----This will get the name of the Fuel being used (if a supported Fuel). +---Returns the name of the active fuel resource. +---If no supported resource is found, "default" will be returned. ---@return string Fuel.GetResourceName = function() return resourceName end ----This will get the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@return number fuel The fuel level of the vehicle. +---Returns the current fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@return number The vehicle fuel level. Fuel.GetFuel = function(vehicle) if not DoesEntityExist(vehicle) then return 0.0 end local level, _ = exports["x-fuel"]:getFuel(vehicle) return level end ----This will set the fuel level of the vehicle. ----@param vehicle number The vehicle entity ID. ----@param fuel number The fuel level to set. +---Sets the fuel level of a vehicle. +---@param vehicle number The vehicle entity handle. +---@param fuel number The fuel level to assign. +---@param type? string The fuel type, used only in ti_fuel. (default: RON91) ---@return nil -Fuel.SetFuel = function(vehicle, fuel) +Fuel.SetFuel = function(vehicle, fuel, type) if not DoesEntityExist(vehicle) then return end return exports['x-fuel']:SetFuel(vehicle, fuel) end diff --git a/modules/vehicleKey/F_RealCarKeysSystem/client/client.lua b/modules/vehicleKey/F_RealCarKeysSystem/client/client.lua index 249c770..9426293 100644 --- a/modules/vehicleKey/F_RealCarKeysSystem/client/client.lua +++ b/modules/vehicleKey/F_RealCarKeysSystem/client/client.lua @@ -1,15 +1,39 @@ ---@diagnostic disable: duplicate-set-field local resourceName = "F_RealCarKeysSystem" 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 plate then return false end + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + TriggerServerEvent('F_RealCarKeysSystem:generateVehicleKeys', plate) end +-- 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 VehicleKey.RemoveKeys = function(vehicle, plate) - return true + 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) end return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/MrNewbVehicleKeys/client/client.lua b/modules/vehicleKey/MrNewbVehicleKeys/client/client.lua index a05405f..bfd4a99 100644 --- a/modules/vehicleKey/MrNewbVehicleKeys/client/client.lua +++ b/modules/vehicleKey/MrNewbVehicleKeys/client/client.lua @@ -4,13 +4,33 @@ 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 plate then return false end + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + return exports.MrNewbVehicleKeys:GiveKeysByPlate(plate) 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) - if not plate then return false end + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + return exports.MrNewbVehicleKeys:RemoveKeysByPlate(plate) end diff --git a/modules/vehicleKey/Renewed-Vehiclekeys/client/client.lua b/modules/vehicleKey/Renewed-Vehiclekeys/client/client.lua index 62e4da7..69653bc 100644 --- a/modules/vehicleKey/Renewed-Vehiclekeys/client/client.lua +++ b/modules/vehicleKey/Renewed-Vehiclekeys/client/client.lua @@ -4,13 +4,33 @@ 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 plate then return false end + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + return exports['Renewed-Vehiclekeys']:addKey(plate) 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) - if not plate then return false end + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + return exports['Renewed-Vehiclekeys']:removeKey(plate) end diff --git a/modules/vehicleKey/_default/client/client.lua b/modules/vehicleKey/_default/client/client.lua index adb02d3..6d66938 100644 --- a/modules/vehicleKey/_default/client/client.lua +++ b/modules/vehicleKey/_default/client/client.lua @@ -1,19 +1,20 @@ ---@diagnostic disable: duplicate-set-field VehicleKey = VehicleKey or {} ----This will give keys to the specifed vehicle/plate. ----@param vehicle number The vehicle entity ID. ----@param plate string The plate of the vehicle. +---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) - return true, Prints.Error("There Is No Vehicle Key System Installed") + Prints.Info("There is no compatible vehicle key resource.") end ----This will remove keys from the specifed vehicle/plate. ----@param vehicle number The vehicle entity ID. ----@param plate string The plate of the vehicle. ----@return boolean | nil +---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) - return true, Prints.Error("There Is No Vehicle Key System Installed") + Prints.Info("There is no compatible vehicle key resource.") end return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/cd_garage/client/client.lua b/modules/vehicleKey/cd_garage/client/client.lua index 9ab85d1..d45dc23 100644 --- a/modules/vehicleKey/cd_garage/client/client.lua +++ b/modules/vehicleKey/cd_garage/client/client.lua @@ -4,13 +4,27 @@ 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 plate then return false end + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + TriggerEvent('cd_garage:AddKeys', plate) 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) - return true + Prints.Info("cd_garage doesnt support removing keys.") end return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/jacksam/client.lua b/modules/vehicleKey/jacksam/client.lua index 0da5d3e..d47b413 100644 --- a/modules/vehicleKey/jacksam/client.lua +++ b/modules/vehicleKey/jacksam/client.lua @@ -4,14 +4,34 @@ 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 plate then return false end - return TriggerServerEvent("vehicles_keys:selfGiveVehicleKeys", plate) + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + + TriggerServerEvent("vehicles_keys:selfGiveVehicleKeys", plate) 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) - if not plate then return false end - return TriggerServerEvent("vehicles_keys:selfRemoveKeys", plate) + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + + TriggerServerEvent("vehicles_keys:selfRemoveKeys", plate) end return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/mVehicle/client/client.lua b/modules/vehicleKey/mVehicle/client/client.lua new file mode 100644 index 0000000..5216aac --- /dev/null +++ b/modules/vehicleKey/mVehicle/client/client.lua @@ -0,0 +1,26 @@ +---@diagnostic disable: duplicate-set-field +local resourceName = "mVehicle" +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) + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + exports.mVehicle:AddTemporalVehicleClient(vehicle) +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("mVehicle doesnt support removing keys.") +end + +return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/mk_vehiclekeys/client/client.lua b/modules/vehicleKey/mk_vehiclekeys/client/client.lua index 0c7d643..cf2c004 100644 --- a/modules/vehicleKey/mk_vehiclekeys/client/client.lua +++ b/modules/vehicleKey/mk_vehiclekeys/client/client.lua @@ -1,16 +1,29 @@ ---@diagnostic disable: duplicate-set-field local resourceName = "mk_vehiclekeys" 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 vehicle and not DoesEntityExist(vehicle) then return false end - return exports["mk_vehiclekeys"]:AddKey(vehicle) + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + exports["mk_vehiclekeys"]:AddKey(vehicle) 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) - if not vehicle and not DoesEntityExist(vehicle) then return false end - return exports["mk_vehiclekeys"]:RemoveKey(vehicle) + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + exports["mk_vehiclekeys"]:RemoveKey(vehicle) end return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/mono_carkeys/client/client.lua b/modules/vehicleKey/mono_carkeys/client/client.lua deleted file mode 100644 index 7ee881a..0000000 --- a/modules/vehicleKey/mono_carkeys/client/client.lua +++ /dev/null @@ -1,16 +0,0 @@ ----@diagnostic disable: duplicate-set-field -local resourceName = "mono_carkeys" -if GetResourceState(resourceName) == 'missing' then return end - -VehicleKey = VehicleKey or {} -VehicleKey.GiveKeys = function(vehicle, plate) - if not plate then return false end - TriggerServerEvent('mono_carkeys:CreateKey', plate) -end - -VehicleKey.RemoveKeys = function(vehicle, plate) - if not plate then return false end - TriggerServerEvent('mono_carkeys:DeleteKey', 1, plate) -end - -return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/okokGarage/client/client.lua b/modules/vehicleKey/okokGarage/client/client.lua index 705c2f0..fee3fa4 100644 --- a/modules/vehicleKey/okokGarage/client/client.lua +++ b/modules/vehicleKey/okokGarage/client/client.lua @@ -4,13 +4,35 @@ 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 plate then return false end + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + TriggerServerEvent('okokGarage:GiveKeys', plate) 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) - return true + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + + local source = GetPlayerServerId(PlayerId()) + TriggerServerEvent("okokGarage:RemoveKeys", plate, source) end return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/qb-vehiclekeys/client/client.lua b/modules/vehicleKey/qb-vehiclekeys/client/client.lua index 861c8d8..bc01002 100644 --- a/modules/vehicleKey/qb-vehiclekeys/client/client.lua +++ b/modules/vehicleKey/qb-vehiclekeys/client/client.lua @@ -4,13 +4,33 @@ 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 plate then return false end + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + TriggerServerEvent("qb-vehiclekeys:server:AcquireVehicleKeys", plate) 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) - if not plate then return false end + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + TriggerEvent("qb-vehiclekeys:client:RemoveKeys", plate) end diff --git a/modules/vehicleKey/qbx_vehiclekeys/client/client.lua b/modules/vehicleKey/qbx_vehiclekeys/client/client.lua index 0502ac1..69c4ac9 100644 --- a/modules/vehicleKey/qbx_vehiclekeys/client/client.lua +++ b/modules/vehicleKey/qbx_vehiclekeys/client/client.lua @@ -4,13 +4,34 @@ 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 plate then return false end - TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate) + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + + TriggerServerEvent("qb-vehiclekeys:server:AcquireVehicleKeys", plate) 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) - return true + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + + TriggerEvent("qb-vehiclekeys:client:RemoveKeys", plate) end return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/qs-vehiclekeys/client/client.lua b/modules/vehicleKey/qs-vehiclekeys/client/client.lua index 2280713..06bdfdd 100644 --- a/modules/vehicleKey/qs-vehiclekeys/client/client.lua +++ b/modules/vehicleKey/qs-vehiclekeys/client/client.lua @@ -4,18 +4,36 @@ 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 vehicle then return false end + 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)) - local verifiedPlate = GetVehicleNumberPlateText(vehicle) - return exports['qs-vehiclekeys']:GiveKeys(verifiedPlate, model, true) + return exports['qs-vehiclekeys']:GiveKeys(plate, model, true) 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) - if not vehicle then return false end + 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)) - local verifiedPlate = GetVehicleNumberPlateText(vehicle) - return exports['qs-vehiclekeys']:RemoveKeys(verifiedPlate, model) + return exports['qs-vehiclekeys']:RemoveKeys(plate, model) end return VehicleKey \ No newline at end of file diff --git a/modules/vehicleKey/t1ger_keys/client/client.lua b/modules/vehicleKey/t1ger_keys/client/client.lua index a040a7a..e996071 100644 --- a/modules/vehicleKey/t1ger_keys/client/client.lua +++ b/modules/vehicleKey/t1ger_keys/client/client.lua @@ -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 \ No newline at end of file diff --git a/modules/vehicleKey/wasabi_carlock/client/client.lua b/modules/vehicleKey/wasabi_carlock/client/client.lua index bde20f5..328699d 100644 --- a/modules/vehicleKey/wasabi_carlock/client/client.lua +++ b/modules/vehicleKey/wasabi_carlock/client/client.lua @@ -4,13 +4,33 @@ 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 plate and vehicle then plate = GetVehicleNumberPlateText(vehicle) end + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + exports.wasabi_carlock:GiveKey(plate) 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) - if not plate and vehicle then plate = GetVehicleNumberPlateText(vehicle) end + assert(vehicle, "vehicle is nil") + assert(DoesEntityExist(vehicle), "vehicle does not exist") + + if not plate then + plate = GetVehicleNumberPlateText(vehicle) + end + exports.wasabi_carlock:RemoveKey(plate) end