From adfe105d274c5d1be0eeae1bdbc34d79b680b104 Mon Sep 17 00:00:00 2001 From: Frowmza <66181451+Frowmza@users.noreply.github.com> Date: Tue, 26 Mar 2024 16:54:18 +0000 Subject: [PATCH] add(client/mods): canInteract (whether to show the mod or not) --- client/modules/vehicle.lua | 11 +++++++++-- data/decals.lua | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/client/modules/vehicle.lua b/client/modules/vehicle.lua index a8f2f29..db713d7 100644 --- a/client/modules/vehicle.lua +++ b/client/modules/vehicle.lua @@ -142,9 +142,16 @@ function Vehicle.getVehicleDecals() local vehicle = cache.vehicle for mod, modData in pairs(require 'data.decals') do - local blacklist, id, toggle, menuId, custom in modData - if (not blacklist or (not isVehicleBlacklist(vehicle, blacklist))) and menuId == currentMenu then + local blacklist, id, toggle, menuId, custom, canInteract in modData + local canInteractMenu = true + if canInteract then + local success, resp = pcall(canInteract, vehicle) + if not success or not resp then + canInteractMenu = false + end + end + if canInteractMenu and ((not blacklist or (not isVehicleBlacklist(vehicle, blacklist))) and menuId == currentMenu) then local add = false local appliedMod = mod == modType if appliedMod then found = true end diff --git a/data/decals.lua b/data/decals.lua index 4af5f90..1616f8e 100644 --- a/data/decals.lua +++ b/data/decals.lua @@ -390,6 +390,13 @@ return { onToggle = function(vehicle, index, toggle) SetVehicleExtra(vehicle, index, not toggle) end, + canInteract = function(vehicle) + for extra = 0, 20 do + if DoesExtraExist(vehicle, extra) then + return true + end + end + end, onClick = function(vehicle) local mods = {} local count = 0