Disable Friendly Fire while aiming

Can someone help me? I want to create a script.
If someone aims with a specific weapon on a player or the players vehicle the local player who is aiming should not he able to shoot at the player/ vehicle.
Like the same, you cannot shoot on story characters in GTAV if you aim on them.

Hi there,

I still have something older, maybe you can use it and improve it!

client.lua file:

local blacklist = {}

-- Add the entities you want to blacklist here
blacklist["prop_traffic_03a"] = true
blacklist["t20"] = true

Citizen.CreateThread(function()
    local sleep = 0

    while true do
        local pId = PlayerId()
        local isAiming, targetPed = GetEntityPlayerIsFreeAimingAt(pId)
        
        if isAiming then
            local archetypeName = GetEntityModel(targetPed)

            if blacklist[archetypeName] then
                DisablePlayerFiring(pId, true)
                DisableControlAction(0, 24, true)
                DisableControlAction(0, 92,  true)
                DisableControlAction(0, 142, true)
                DisableControlAction(0, 223, true)
                DisableControlAction(0, 229, true)
                DisableControlAction(0, 257, true)
                DisableControlAction(0, 346, true)
            end
        end

        Citizen.Wait(sleep)
    end
end)

Thanks it works!

1 Like