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

npc
sandyshores
agressive

#1

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.


Gang scripts
#2

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


#3

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)

#4

@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?


#5

Make something like this your client script:

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

#6

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


#7

@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.


#8

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)

#9

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


#10

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.


#11

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


#12

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.


#13

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


#14

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.


#15

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.fivem.net/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.


#16

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


#17
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


#18

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