Problem "calming" the AI (Lua)

Hey you all! I’m having a problem when calming AI. I need all NPC to totally ignore me, no matter what I’m doing (shooting or whatever). To do this, I’m using a .meta file I got from a resource from LCPDFR (StopShittingBricks) and I edited it to accomplish it.
I’ve managed to make it work with pedestrians and near vehicles, but I’m having a problem with vehicles at a certain distance. You can see it by yourself in the video:


What is getting me crazy is the fact that it works perfectly with near vehicles, but don’t work with further ones, and if I shoot at that further vehicle direction, it stays “calmed”, but if I shoot at any direction except that one, it gets crazy.

Does someone know how I can solve this? I don’t mind using other resource, I was trying to develop it by myself because couldn’t find other script that made what I needed. I just need every NPC to ignore my shoots, no matter the distance, no matter the shoot direction, just need they to stay calmed.

Thank you very much!

Using SetEveryoneIgnorePlayer(player, toggle) (https://runtime.fivem.net/doc/natives/?_0x8EEDA153AD141BA4) NPC will completely ignore your shoots. But keep in mind they will completely ignore you, and it may be a behavior your want to avoid.

Hey Elio, thanks for your answer! Unfortunately, I’ve already tried that native and didn’t work either. I’m even doing this, but still doesnt work

local Player = PlayerId()

SetPoliceIgnorePlayer(Player, true)
SetEveryoneIgnorePlayer(Player, true)
SetPlayerCanBeHassledByGangs(Player, false)
SetIgnoreLowPriorityShockingEvents(Player, true)

Citizen.CreateThread(function()
    while true do
        for key,pedNpc in pairs(GetAllPeds()) do
            SetBlockingOfNonTemporaryEvents(pedNpc,true)
            SetPedFleeAttributes(pedNpc, 0, 0)
            SetPedCombatAttributes(pedNpc, 17, 1)
            if(GetPedAlertness(pedNpc) ~= 0) then
                SetPedAlertness(pedNpc,0)
            end
        end
        Citizen.Wait(0)
    end
end)

local function EnumerateEntities(initFunc, moveFunc, disposeFunc)
    return coroutine.wrap(function()
        local iter, id = initFunc()
        if not id or id == 0 then
            disposeFunc(iter)
            return
        end
      
        local enum = {handle = iter, destructor = disposeFunc}
        setmetatable(enum, entityEnumerator)
      
        local next = true
        repeat
            coroutine.yield(id)
            next, id = moveFunc(iter)
        until not next
      
        enum.destructor, enum.handle = nil, nil
        disposeFunc(iter)
    end)
end

function EnumeratePeds()
    return EnumerateEntities(FindFirstPed, FindNextPed, EndFindPed)
end

function GetAllPeds()
    local peds = {}
    for ped in EnumeratePeds() do
        if DoesEntityExist(ped) and not IsEntityDead(ped) and IsEntityAPed(ped) and IsPedHuman(ped) and not IsPedAPlayer(ped) then
            table.insert(peds, ped)
        end
    end
    return peds
end

This code is from a script I found somewhere, and calms everyone (just in case my modifications of .meta file don’t work). Do you know any other way to do this? I literally don’t know what to do

Honnestly, I `don’t really know how to achieve such a behavior. Maybe taking a look at this resource ([Release] Calm AI) will help you ?

Yeah no problem. It is a strange problem. And yes, I’ve already checked that resource, in fact, that’s the resource I based on to achieve what I’ve already achieved. It only made NPCs to stop reacting to shots, and I modified it to make NPCs stop reacting to shots or aiming at them, but I had this problem with further vehicles.
Thank you anyway bro!