Add lockState support to vehicle properties (#83)

Hello,

I’d like to propose a small improvement to vehicle properties handling.

This change adds support for the vehicle door lock state (lockState) by:
- Including lockState in the VehicleProperties type
- Reading the value using GetVehicleDoorLockStatus in getVehicleProperties
- Applying the value using SetVehicleDoorsLocked in setVehicleProperties

This allows vehicle lock status to be properly saved and restored alongside other vehicle properties.

Let me know if this fits the project direction or if any adjustments are needed.
This allows the vehicle lock status to be properly saved and restored alongside other vehicle properties.

Note: Two additional commits and pull requests were accidentally opened during this process and have already been closed. Sorry for the noise.

Thank you!

Signed-off-by: Angelo Rodrigues De Morais Barroso <115129101+Angelo90810@users.noreply.github.com>
This commit is contained in:
Angelo Rodrigues De Morais Barroso
2026-01-19 19:46:37 -03:00
committed by GitHub
parent ae16b78bc4
commit c8db003cbc

View File

@@ -12,6 +12,7 @@ if cache.game == 'redm' then return end
---@field model? number ---@field model? number
---@field plate? string ---@field plate? string
---@field plateIndex? number ---@field plateIndex? number
---@field lockState? number
---@field bodyHealth? number ---@field bodyHealth? number
---@field engineHealth? number ---@field engineHealth? number
---@field tankHealth? number ---@field tankHealth? number
@@ -202,6 +203,7 @@ function lib.getVehicleProperties(vehicle)
model = GetEntityModel(vehicle), model = GetEntityModel(vehicle),
plate = GetVehicleNumberPlateText(vehicle), plate = GetVehicleNumberPlateText(vehicle),
plateIndex = GetVehicleNumberPlateTextIndex(vehicle), plateIndex = GetVehicleNumberPlateTextIndex(vehicle),
lockState = GetVehicleDoorLockStatus(vehicle),
bodyHealth = math.floor(GetVehicleBodyHealth(vehicle) + 0.5), bodyHealth = math.floor(GetVehicleBodyHealth(vehicle) + 0.5),
engineHealth = math.floor(GetVehicleEngineHealth(vehicle) + 0.5), engineHealth = math.floor(GetVehicleEngineHealth(vehicle) + 0.5),
tankHealth = math.floor(GetVehiclePetrolTankHealth(vehicle) + 0.5), tankHealth = math.floor(GetVehiclePetrolTankHealth(vehicle) + 0.5),
@@ -322,6 +324,10 @@ function lib.setVehicleProperties(vehicle, props, fixVehicle)
SetVehicleNumberPlateTextIndex(vehicle, props.plateIndex) SetVehicleNumberPlateTextIndex(vehicle, props.plateIndex)
end end
if props.lockState ~= nil then
SetVehicleDoorsLocked(vehicle, props.lockState)
end
if props.bodyHealth then if props.bodyHealth then
SetVehicleBodyHealth(vehicle, props.bodyHealth + 0.0) SetVehicleBodyHealth(vehicle, props.bodyHealth + 0.0)
end end