Hello FiveM Community
I wrote a code that should prevent policemen from shooting at each other. But unfortunately it does not work. It would be nice if someone has perhaps an idea. Sorry for my bad english…
Its for GTA IV Multiplayer, because of that it use GTA IV Natives.
CreateThread(function()
while true do
Wait(0)
if not IsCharFatallyInjured(GetPlayerPed()) then
local users = GetPlayers()
for _, i in ipairs(users) do
local userhealth = GetCharHealth(i.ped, _i)
if(IsPlayerFreeAimingAtChar(GetPlayerId(), i.ped)) then
if(IsCharModel(GetPlayerPed(), GetHashKey("M_Y_COP", _r))) then
if(IsCharModel(i.ped, GetHashKey("M_Y_COP", _r))) then
if(userhealth > GetCharHealth(i.ped, _i)) then
if(HasCharBeenDamagedByChar(i.ped, GetPlayerPed()) == true) then
SetCharHealth(i.ped, userhealth)
end
end
end
end
end
end
end
end)