[HELP] Is there a better way than this to disable AI?

The method I am currently using to disable AI in my server can be seen in the following image

However the issue I have with this is that it does not work perfectly! Every so often I will spot the odd vehicle, or the odd pedestrian or the odd parked car. For the nature of the server I am trying to create I cannot have this happen at all.

Yes for the most part it does the job, however it doesn’t take long at all before you see something
As shown here:

Any help with this would be greatly appreciated

Is the loop you’re calling it in set ‘fast enough’?
Since if the loop might not be ‘fast enough’ it might not work as desired if I follow what’s said on the Natives page of FiveM (that it should be in a loop), and since it also is called… ThisFrame, i suppose it should be called faster?

“A bit of topic”, So many years we’ve/i’ve played on SA-MP (old San Andreas) server where we went trough INSANE extends with making bots manually to make the server look alive, and here i keep seeing people asking on how to disable AI and ‘the alive world’ :rofl::rofl::rofl:

2 Likes

Basic example:

Citizen.CreateThread(function()
   Wait(50)
   PedDensity()
   NoTraffic()
end)

Might be ‘to slow’ and might need Wait(0) for example.

NOT 100% certain since I haven’t tested it (“wrote” it here on the forum!) and I would "like to keep my peds :stuck_out_tongue: "

1 Like

Hmm i’ve just read your post on another topic where you say it happens (more frequently) around car parks?

My theory is that those are vehicle generators (either from a script or game (suspect the latter though)), and that PED’s a re ‘spawned into them’ due to the game/script activating the vehicle(s), using the ‘instructions’ set in the vehicle meta files (which tell the game which drivers can drive it).

You can do it in two ways to get it all out of the game, one is to make a ‘scanner’ with a radius to detect peds in for example a radius of about 100 around you and ‘delete detected peds’ (CHECK IF THEY ARE NOT PLAYERS OF COURSE! :wink: ).

Another option which happened ON ACCIDENT when i ‘fucked up big time’ when i was ADDING peds and vehicles to my server to spawn in the normal cycle is to ‘mess with’ the popcylce.dat (from the original game) and stream that one as popcycle.meta.

When i ‘fucked up’ one small part in that one, it was litterally enough to disable ALL traffic haha so i bet ‘tuning it’ to your needs will give you the option to ‘destroy all population’ like a ‘mad scientist’ :rofl: (sorry could not resist haha)

BUT keep in mind: Doing it with streamed files like popcycle will NOT give you the
ability to ‘re-enable’ it script wise though (if you want to be able to toggle it on and off)

1 Like

Yeah, it would be gameEvents activating. For memory these are the natives

SetRandomEventFlag()
GetRandomEventFlag()

https://runtime.fivem.net/doc/natives/#_0x971927086CFD2158
https://runtime.fivem.net/doc/natives/#_0xD2D57F1D764117B1

1 Like

Yeah that about what i meant indeed, (not fully 'up to speed" with GTA V and all the event names in it (and FiveM yet), but do remember such events from IV to indeed).

Suspect that if he investigates the use of popcycle PROPERLY haha that he will be able to get rid of nearly (if not) all peds and vehicles.

I accidentally messed up some line breaks and reverted since i didn’t care about ‘no traffic’ so didn’t looked into it further, but my game was ‘completly dead of peds’ though haha

1 Like

THANKS mate! appreciate it, since I will need those to in certain parts (although still a long way to go in this project) Bookmarked :wink: :+1:

2 Likes

No problem. For memory it’s a toggle and does not need to be in a loop. Just make sure when it’s set that the entity exists - using DoesEntityExist()

2 Likes

The loop I had the two functions in were running in Citizen.Wait(0), couldn’t make it any faster if I tried safely.

The radius idea could work quite well actually thinking about it and would prevent the need to mess around with the popcycle.

My goal is to remove all traffic and all AI entirely, I’m not fussed about the option to re-enable it via a script as I just need it gone.

Im not sure I quite understand what is meant by the SetRandomEventFlag() and GetRandomEventFlag natives, would I just SetRandomFlag(false) and hope that works?

Cheers for all your help so far guys

Yes. Refer to the links I posted for them for the params.

1 Like

This indeed… BUT! keep in mind: that if you are in ‘bad luck’ and a “public helicopter spawns” at the airport… you remove/delete the pilot… well figure out the rest :rofl::rofl::rofl:

Just try indeed the randomflag tip from faxes, and see how that responds (just like he said: only need to set it once) :slight_smile:

EDIT: ALTOUGH thinking about "old memories’… In GTA IV i’ve had the issue that some flags would ‘auto reset’ if you entered a new zone for example! Not sure AT ALL how GTA V handles this though.

1 Like

Well I would be checking for vehicles anyway, otherwise I’d have random cars on the streets from where peds once were :rofl:

I will try the randomflag tip now and see how that goes.

EDIT: With SetRandomEventFlag(false) I still have vehicles appearing, looks like that wont suffice for a solution at the moment.

A long time before the virus broke out… people tried to fled, then night came and the bodysnatchers took them, even on their attempt to escape… :rofl::rofl::rofl::rofl:

Why not just try to "fuck up’ popcycle? :joy:

If that works completly, then you don’t have ‘intensive loops’ running to keep removing ‘shit you don’t want’ either :wink:

Because I don’t actually know how to go about streaming it :stuck_out_tongue:

EDIT: Or retrieving it to use it for that matter

I’ve found the SetScenarioTypeEnabled() native, suppose if I found every event name and just disabled them all once that could work?

haha then just ask! haha :rofl::man_facepalming:

It’'s not that hard actually, Do you have OpenIV installed and/or know a BIT how to use it?

(streaming i can easily give you my own script (but emptied) for as example :slight_smile:

Well you definitly found A function that i want to go and experiment with for the complete opposite reason as you haha:

I’ve come up with an idea, its crazy, but its fool proof, I’m gonna write a quick C# program to read the contents of scenarios.meta for me, its going to give me every name of each scenario, and I will just disable all of them, no need for ped density or nothing then :stuck_out_tongue:

Euhm… not 100% certain of that is a ‘completely good idea’ :joy:
I know for example that I also call quite some scenario’s for animations i use, and some scenario’s are also used in game for the player and i’m not 100% sure if that would affect the player (on for example entering/leaving’ the vehicle) :wink:

It sounds like an insane solution, but i’m definitly interested what happens hahahahah
(If it causes a "meltdown’ please tell me :rofl: