Relations natives
By default, every ped in GTA belongs to relationship groups that decide who shoots who. When your mod spawns its own cast — a gang, a squad, a police unit — you must tell those peds who they hate, fear, respect and ignore. That is what relation natives are for.
Relationship groups
GET_PED_RELATIONSHIP_GROUP_HASH(ped) returns the group a ped belongs to; SET_PED_RELATIONSHIP_GROUP_HASH(ped, groupHash) moves it into your own group.
When you need it: the moment you spawn actors that should form a faction that did not exist before. A crew of thugs you drag out of the pool needs its own group so the game does not classify each member randomly.
Declaring the relationship
SET_RELATIONSHIP_BETWEEN_GROUPS(relationship, groupA, groupB) sets the disposition. The values matter:
| Relationship | Meaning |
|---|---|
0 (Respect) | leaves each other alone |
1 (Like) | friendly, allies in a fight |
3 (Dislike) | tense, unprovoked hostility in groups |
4 (Hate) | fights on sight |
255 (Pedestrian) | ambient default |
In real code you see the two directions set — (a,b) and (b,a) — because the game reads the pair both ways depending on which ped asks.
When you need it: your squad must fight the gang but not the civilians; your bodyguard must like the player's group and hate the attackers; your mod's cops must treat civilian peds as pedestrians while hunting the marked enemies.
Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, 4 /* Hate */, gangHash, playerGroupHash);
Function.Call(Hash.SET_RELATIONSHIP_BETWEEN_GROUPS, 4 /* Hate */, playerGroupHash, gangHash);
The global toggles
SET_EVERYONE_IGNORE_PLAYER(bool) and SET_POLICE_IGNORE_PLAYER(bool) switch the whole world's attitude toward the player at once.
When you need it: two diametrically opposite situations — a "god-in-the-city" sandbox where nobody reacts to you, and a scripted arrest where the player is handcuffed and the police must not open fire on the very roleplay moment you built. Real mods toggle these around custody scenes, then restore them.
What not to do
Don't call SET_RELATIONSHIP_BETWEEN_GROUPS every frame — it is an event, not a setting; calling it repeatedly desynchronizes combat ai and costs frames. Set it once when your faction assembles, and touch the global toggles only for the duration of the scene they gate.