local Gangs = {
{
Group = "AMBIENT_GANG_BALLAS",
Models = {
"g_m_y_ballasout_01",
"g_m_y_ballaorig_01",
"csb_ballasog",
"g_m_y_ballaeast_01",
"a_m_y_soucent_02",
"g_m_y_strpunk_01",
"ig_ballasog",
"g_f_y_ballas_01",
"csb_grove_str_dlr"
}
},
{
Group = "AMBIENT_GANG_FAMILY",
Models = {
"g_f_y_families_01",
"g_m_y_famfor_01",
"g_m_y_famdnf_01",
"g_m_y_famca_01",
"mp_m_famdd_01",
"csb_ramp_gang",
"ig_ramp_gang"
}
}
}
local CurrentGang = nil
Citizen.CreateThread(function()
while true do
if CurrentGang == nil then
-- Default Gang NONE
RemovePedFromGroup(GetPlayerPed(PlayerId()))
CurrentGang = "NONE"
else
local SuspectedGang = FindPlayerSupposedGang()
if CurrentGang ~= SuspectedGang then
-- Gang Change
if SuspectedGang ~= "NONE" then
SetPedRelationshipGroupHash(GetPlayerPed(PlayerId()), GetHashKey(SuspectedGang))
CurrentGang = SuspectedGang
else
RemovePedFromGroup(GetPlayerPed(PlayerId()))
CurrentGang = "NONE"
end
-- Safe Respawn Catch
if CurrentGang ~= "NONE" then
if GetPedRelationshipGroupHash(GetPlayerPed(PlayerId())) ~= GetHashKey(CurrentGang) then
SetPedRelationshipGroupHash(GetPlayerPed(PlayerId()), GetHashKey(CurrentGang))
end
end
end
end
Citizen.Wait(0)
end
end)
function FindPlayerSupposedGang()
local ped = GetPlayerPed(PlayerId())
for a = 1, #Gangs do
for b = 1, #Gangs[a].Models do
if IsPedModel(ped, GetHashKey(Gangs[a].Models[b])) then
return Gangs[a].Group
end
end
end
return "NONE"
end
To be fair you don’t really need them long lines of code when you can break it down into tables and loops.
To sum it up this code will basically make the AI treat you as one of their own. If someone shoots at you they will attack etc. You can not shoot your team though. If you want to enable friendly fire on your gang then you could mess with some natives to do that.
5 Likes