Any way to stop NPCs in Sandy Shores from becoming agressive every time a player fires a gun?

My friends and I are doing police roleplay on my server and we’re getting pretty tired of half the NPCs in the area shooting at our cops every time they gun down another player.

Is there an easy way to stop all NPCs from becoming aggressive towards players’ gunshots? I’m not necessarily trying to stop NPCs from becoming aggressive altogether, but if that’s a side effect then I’m OK with that.

2 Likes

u can use lambda menu to ignore player tell your cops to use that so npcs dont get aggresive towards your cops

1 Like

You could also try this:

SetPlayerCanBeHassledByGangs(Player player, Bool toggle)

Though not sure if random sandy shores NPC’s count as “gangs” using that native. If you want to be sure nobody attacks the player, use this (same as in lambda menu):

SetEveryoneIgnorePlayer(Player player, Bool toggle)
1 Like

@gun I’m currently using Mello Trainer and that function doesn’t seem to work. Guess I’ll just have to wait for it to update.

@Vespura First time trying to make my own mod. Would I be able to just paste that into a .lua file and it’ll work? And what do I put for the “player” variable to wildcard every player on the server?

Make something like this your client script:

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        SetEveryoneIgnorePlayer(PlayerId(), 1)
    end
end)

@Vespura Alright, thank you. I’ll give that a try with the gang related one and see if it stops them.

@Vespura At first I thought it was working due to a bug in another script. But now It seems it’s actually not. Does anything need to be put between the brackets after “PlayerId”? Basically want it to apply to every player on the server.

Try this code, it will verify if the player is inside the area “Sandy Shores”.

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        if IsEntityInZone(GetPlayerPed(-1), "SANDY") then
        	SetEveryoneIgnorePlayer(PlayerId(), true)
        else
        	SetEveryoneIgnorePlayer(PlayerId(), false)
        end
    end
end)

If anyone is having problems with this, I recommend this plugin, you can control the amount of NPCs there are and much more

That is actually not the correct solution…
@Drift_91 asked how you can disable all peds, animals etc to attack you in just one area.
Your recommendation is just in/decreasing peds on the map.

1 Like

I have a server, and the PEDS aren’t aggressive on it. And I’m highly sure that is the plugin.

Getting the following error with that code:

Error parsing script client.lua in resource d91NoAgro: client.lua:7: 'then' expected near 'SetEveryoneIgnorePlayer'

@BlueJ vBasic doesn’t have any settings related to ped aggressiveness as far as I can see. I’ve used it in the past and didn’t notice any difference with peds. It’s more likely your trainer if you use one.

i just updated the example, i forgot to add then in the if statement :woman_facepalming:

Strange thing is that both @ghosty and @Vespura’s code doesn’t seem to work. NPCs still pay full attention to me and freak out or attack when I fire weapons or attack someone. I get the impression that the function has been renamed or maybe even removed in the latest version of the FiveM framework.

Are you guys sure that that’s all that needs to be in the client.lua? I’m pretty sure I’ve set up the __resource.lua properly.

Alright, so still can’t get it to work. Here’s what I’ve got:

__resource.lua:

client_script 'client.lua'

client.lua:

-- https://forum.cfx.re/t/any-way-to-stop-npcs-in-sandy-shores-from-becoming-agressive-every-time-a-player-fires-a-gun/53635/5

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        SetEveryoneIgnorePlayer(PlayerId(), true)
    end
end)

I fire guns or punch a ped and other peds around still react.

1 Like

Did you find how to fix that? Iv’e tried few native but did not work :frowning:

SetRelationshipBetweenGroups(0, GetHashKey("AMBIENT_GANG_HILLBILLY"), GetHashKey('PLAYER'))

Trigger this on any client you want them not to attack. Changing the number in the first part of the array will do the following:

–0 = Companion
–1 = Respect
–2 = Like
–3 = Neutral
–4 = Dislike
–5 = Hate
–255 = Pedestrians

17 Likes

is there a way to set it per play not just the ‘player’ group?

Hello

Very big problem with FiveM Programming in Linux Server.
Player character turn to NPC when exit server.

In my server, i removed all NPC’s in city. (Zero Percent NPC)

SetScenarioPedDensityMultiplierThisFrame(0.0, 0.0)
I need programming code which prevent change player to NPC.
And i want instead of becoming NPC, it will disappear.

I tested many codes, but did not work for me

Anyone able to successfully target ambient vagos? I’m able to set ballas friendly towards player ballas, and marabunta friendly towards player marabunta, but for some reason vagos isn’t seeming to work. I’ve tried using ‘AMBIENT_GANG_MEXICAN’, ‘AMBIENT_GANG_SALVA’. Is there no ‘AMBIENT_GANG_VAGOS’?