[Request] an option to disable NPC spawn

It would be great if FiveM add an option to disable Peds, Generated vehicles and so on because right now we have to do it with loops and it’s not a reliable solution because when someone’s connection interrupts it’s going spawn hell of peds and vehicles for others and it’s really annoying

We do have a such a thing on FiveM forced in onsync_infinity so how about adding it to the onesync and onesync+ as convar so we can manually turn it on or off

2 Likes

Use this https://github.com/danini1705/No-NPC

there is no point on using this I know how to remove NPC but the problem is it’s not a reliable solution because when player’s connection interrupts it start generating bots and when player reconnect it will bring all of those bots with himself also it’s a loop with 0ms delay which impact performance

https://runtime.fivem.net/doc/natives/?_0x8C95333CFC3340F3

A one liner. No need to call it every frames.

This option exists : https://github.com/citizenfx/fivem/blob/875a0fbd3428b2edc7c633e7add0ddded46339db/code/components/citizen-server-impl/src/state/ServerGameState_Scripting.cpp#L342

Set entity lockdown mode to strict or relaxed
You can also cancel it during EntityCreating event, but in this case, you should disable population client side too because the game won’t stop trying to create entities

1 Like

A question is that a native? because it can’t find it?
https://runtime.fivem.net/doc/natives

I tried this both in client and server side it’s not a native or I am doing something wrong

Error loading script server.lua in resource esx_aduty: @esx_aduty/server.lua:2286: attempt to call a nil value (global 'SetEntityLockdownMode')
stack traceback:
        @esx_aduty/server.lua:2286: in main chunk
Failed to load script server.lua.
Started resource esx_aduty

1 Like

This is a server side native and the name is SET_SYNC_ENTITY_LOCKDOWN_MODE (0x0071321B).
I use C# and it was not defined either (like DeleteEntity server side).

You have to call with the hex value, I don’t know lua but it shoud be:
Citizen.InvokeNative(0x0071321B, “relaxed”)
Possible values : “relaxed”, “strict” or “inactive”

2 Likes

Man you are a savior thank you so much <3
and I didn’t know DeleteEntity exist on serverside it can be so useful if you don’t mind can you send me the hex value of that native so I can call it please?

0xFAA3D236
(You can see hashes here: https://runtime.fivem.net/doc/natives/?_0xAE3CBE5BF394C9C9)

1 Like

Thank you

@Less thank you for help and it was working, but it was not what I expected because when you set the mode to relaxed or strict it will despawn every entity you spawn, I need something like onesync_infinity to only disable NPC which generating by game

If they are created server side, they wont.

Alternately you can (server side):

AddEventHandler('entityCreating', function(entity)
    if GetEntityPopulationType(entity) ~= 7 then
        CancelEvent()
    end
end)

Look here: https://github.com/citizenfx/fivem/blob/master/code/components/lovely-script/src/Lovely.cpp#L84

They use these natives:

Setting EntityLockDown to strict will to the same because it check if onesync bigmode or EntityLockDown is strict (+ it disable all client side entities)

To reply to your first question, if you want be 100% sure client won’t create entities, you have to use the “No-NPC” script + cancel the entityCreating event (see my code above) OR lockdown strict + create entities server side ?
Options are here :slight_smile:

3 Likes

Worked great thanks, it gives the functionality I wanted but soon I am gonna implement your 2nd advice in my code create entities server side thanks for help