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)