If anyone can help me with this… Insted of being npc, I would like it to detect if player has job named like : ballas, vagos, families, thelostmc
they would be helped by their respective gang…
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
if PlayerData.job.name == "family" then
--set relation
end
You just need to add some ESX variables:
ESX = nil --put this with other global variables
--and put this in your thread
while ESX.GetPlayerData().job == nil do
Citizen.Wait(10)
end
PlayerData = ESX.GetPlayerData()
Example from my script:
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
while ESX.GetPlayerData().job == nil do
Citizen.Wait(10)
end
PlayerData = ESX.GetPlayerData()
while true do
Wait(1)
if IsPedModel(GetPlayerPed(-1), GetHashKey('U_M_Y_Zombie_01')) or IsPedModel(GetPlayerPed(-1), GetHashKey('T-600-SJ')) then
SetRelationshipBetweenGroups(5, GetHashKey("legionis"), GetHashKey("PLAYER"))
SetRelationshipBetweenGroups(5, GetHashKey("PLAYER"), GetHashKey("legionis"))
elseif PlayerData.job.name == "legion" then
SetRelationshipBetweenGroups(1, GetHashKey("legionis"), GetHashKey("PLAYER"))
SetRelationshipBetweenGroups(1, GetHashKey("PLAYER"), GetHashKey("legionis"))
else
SetRelationshipBetweenGroups(5, GetHashKey("legionis"), GetHashKey("PLAYER"))
SetRelationshipBetweenGroups(5, GetHashKey("PLAYER"), GetHashKey("legionis"))
end
end
end)
is there a version of GetHashKey(“PLAYER”) but its for jobs “”“example”“” GetHashKey(“mafia”) just added a mafia job they are going to hang out on grove street, and i want the ambient npc ballas not to shoot at the mafia members, ,
You can’t get a hash key from a job, because it doesn’t have a hash value.
If I’m logically thinking, what you can do is just simply create a thread where it checks if the player has the necessary job and then disable peds from attacking them.
I been pieceing to get bits of code from here and there, syntax checks out in luaedit, and im slowly learning more and more check what i have so far, i been testing it and it does not work but I feel like im getting close
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
while ESX.GetPlayerData().job == nil do
Citizen.Wait(10)
end
PlayerData = ESX.GetPlayerData()
while true do
Wait(1)
if ESX.GetPlayerData().job == "mafia" then
SetRelationshipBetweenGroups(1, GetHashKey("AMBIENT_GANG_BALLAS"), GetHashKey("PlayerData"))
SetRelationshipBetweenGroups(1, GetHashKey("PlayerData"), GetHashKey("AMBIENT_GANG_BALLAS"))
end
end
end)```
i think the first part needs work, i saw that bit on another page, that == nil do needs to have something about the mafia job im sure but, I still don’t know what im doing. im close i can tell
**edit haha i got it from this page, little here and a little there , I feel dumb but my brain is working (thats a good thing)
maybe adding a AddRelationshipGroup(“mafia”) somewhere
CreateThread(function()
while ESX == nil do
TriggerEvent(‘esx:getSharedObject’, function(obj) ESX = obj end)
Citizen.Wait(0)
end
while ESX.GetPlayerData().job == nil do
Wait(10)
end
while true do
local playerped = GetPlayerPed()
local PlRelGroup = GetPedRelationshipGroupHash(playerped)
if ESX.GetPlayerData().job == “mafia” then
SetRelationshipBetweenGroups(1, GetHashKey(“AMBIENT_GANG_BALLAS”), PlRelGroup)
SetRelationshipBetweenGroups(1, PlRelGroup, GetHashKey(“AMBIENT_GANG_BALLAS”))
else
SetRelationshipBetweenGroups(4, GetHashKey(“AMBIENT_GANG_BALLAS”), PlRelGroup)
SetRelationshipBetweenGroups(4, PlRelGroup, GetHashKey(“AMBIENT_GANG_BALLAS”))
end
Wait(5000)
end
end)
this is my newest version but still not working, syntax checks out and it throws no errors, but its missing something
i named it client.lua and in the __resource.lua i made this