Skip to content

Commit

Permalink
add(client/mods): canInteract (whether to show the mod or not)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frowmza committed Mar 26, 2024
1 parent 33e0e17 commit adfe105
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions client/modules/vehicle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions data/decals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit adfe105

Please sign in to comment.