refactor(vehicleproperties): throw error for invalid or unowned entity

This commit is contained in:
Linden
2022-03-15 06:52:40 +00:00
parent 2ce934c41a
commit e971778b29

View File

@@ -158,7 +158,9 @@ end
---@param vehicle number Entity handle
---@param props table Properties
function lib.setVehicleProperties(vehicle, props)
if DoesEntityExist(vehicle) and NetworkGetEntityOwner(vehicle) == PlayerId() then
if not DoesEntityExist(vehicle) then error(("Unable to set vehicle properties for '%s' (entity does not exist)"):format(entity)) end
if NetworkGetEntityOwner(vehicle) ~= PlayerId() then error(("Unable to set vehicle properties for '%s' (client is not entity owner)"):format(entity)) end
local colorPrimary, colorSecondary = GetVehicleColours(vehicle)
local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)
@@ -480,4 +482,3 @@ function lib.setVehicleProperties(vehicle, props)
SetVehicleMod(vehicle, 49, props.modLightbar, false)
end
end
end