How can I add these npc/ped to the group so that they can not shoot at each other?
My code:
pedsList = {
"s_m_y_marine_02"
}
function SpawnObject(objectname)
local Player = GetPlayerPed(-1)
local x, y, z = table.unpack(GetEntityCoords(Player, true))
local heading = GetEntityHeading(Player)
RequestModel(objectname)
while not HasModelLoaded(objectname) do
Citizen.Wait(1)
end
if CheckPedRestriction(GetLocalPed(), pedsList) then
local SPed = CreatePed(29, objectname, x, y+1, z, true, true, true)
GiveWeaponToPed(SPed, GetHashKey("WEAPON_PISTOL"), math.random(20, 100), false, false)
SetCurentPedWeapon(SPed, GetHashKey("WEAPON_PISTOL"), true)
SetBlockingOfNonTemporaryEvents(obj, true)
SetPedCombatAttributes(SPed, 46, true)
SetPedFleeAttributes(SPed, 0, 0)
TriggerEvent("chatMessage", "", {255,255,255}, "^2spawned NPC")
else
TriggerEvent("chatMessage", "", {255,255,255}, "^1You don't have permission")
end
end
RegisterCommand('npc1', function(source, args)
SpawnObject('ig_cletus')
end, false)
RegisterCommand('npc2', function(source, args)
SpawnObject('s_m_y_ammucity_01')
end, false)
function CheckPedRestriction(ped, PedList)
--Checks Player Ped Skin
for i = 1, #PedList do
if GetHashKey(PedList[i]) == GetEntityModel(ped) then
return true
end
end
return false
end
function GetLocalPed()
--Grabs The Player Ped (ID)
return GetPlayerPed(PlayerId())
end