I'm stuck on a function code maybe you see something I missed?

I’m Bit stuck on a function I’m trying to show a menu for selected vehicle model when player is in range using code below. It’s not working as intended it shows the menu still for all vehicles I’m not seeing any errors client side logic seems correct I may missed something you may notice.

Config File is setup with

Config.BlockVehicles = {
    [1] = {model = `police`, label = `police`},
    [2] = {model = `police2`, label = `police2`},	
}

Menu should hide when near police car…

client side code I have is:

local function CarMenuAccess()
    local IsTypeRetval = false
    local veh = QBCore.Functions.GetClosestVehicle()
    for i = 1, #Config.BlockVehicles, 1 do
        if veh == Config.BlockVehicles[i].model then
            IsTypeRetval = true
        end
    end
	
    return IsTypeRetval
end

RegisterNetEvent('openmenu', function() 
CarMenuAccess() --calling the above function

--doing checks
	if IsTypeRetval then
         -----------Errors out here          
	    else
		 ---------- My code here         
    end
end)

After a can few cans of V I’m jacked up… I Noticed code was checking HASH of vehicles I’m a dumb dumb :sweat_smile: I got it working fine with this change to function.

local function CarMenuAccess()
    local IsTypeRetval = false
    local veh = QBCore.Functions.GetClosestVehicle()
	local vehtype = GetDisplayNameFromVehicleModel(GetEntityModel(veh))

    for i = 1, #Config.BlockVehicles, 1 do
        if vehtype == Config.BlockVehicles[i].model then
            IsTypeRetval = true
        end
    end
	
    return IsTypeRetval
end

I’ll leave this here incase anyone needs it :slight_smile: maybe a better way to do it but it works for what I need.
The vehtype brings back names in caps so police will now be POLICE won’t work for low letters edit config to match.