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 vehicle number Entity handle
---@param props table Properties ---@param props table Properties
function lib.setVehicleProperties(vehicle, props) 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 colorPrimary, colorSecondary = GetVehicleColours(vehicle)
local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle) local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)
@@ -479,5 +481,4 @@ function lib.setVehicleProperties(vehicle, props)
if props.modLightbar then if props.modLightbar then
SetVehicleMod(vehicle, 49, props.modLightbar, false) SetVehicleMod(vehicle, 49, props.modLightbar, false)
end end
end
end end