[Release] OneSync NPC Control

Hello, I made an NPC control version for my server that fixes the random car spawn that happens sometimes on OneSync, hope that also works good for you.

Download Link
https://github.com/3DSX/npc_control
Code:
client (main.lua)

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0) -- prevent crashing

		-- These natives have to be called every frame.
		SetPedDensityMultiplierThisFrame(0.0) -- set npc/ai peds density to 0
		SetRandomVehicleDensityMultiplierThisFrame(0.0) -- set random vehicles (car scenarios / cars driving off from a parking spot etc.) to 0
		SetScenarioPedDensityMultiplierThisFrame(0.0, 0.0) -- set random npc/ai peds or scenario peds to 0
		SetGarbageTrucks(false) -- Stop garbage trucks from randomly spawning
		SetRandomBoats(false) -- Stop random boats from spawning in the water.
		SetCreateRandomCops(false) -- disable random cops walking/driving around.
		SetCreateRandomCopsNotOnScenarios(false) -- stop random cops (not in a scenario) from spawning.
		SetCreateRandomCopsOnScenarios(false) -- stop random cops (in a scenario) from spawning.
		
		local x,y,z = table.unpack(GetEntityCoords(PlayerPedId()))
		ClearAreaOfVehicles(x, y, z, 1000, false, false, false, false, false)
		RemoveVehiclesFromGeneratorsInArea(x - 500.0, y - 500.0, z - 500.0, x + 500.0, y + 500.0, z + 500.0);

		-- fix OneSync NPC by Albert0
        if IsPedSittingInAnyVehicle(GetPlayerPed(-1)) then

            if GetPedInVehicleSeat(GetVehiclePedIsIn(GetPlayerPed(-1),false),-1) == GetPlayerPed(-1) then
                SetVehicleDensityMultiplierThisFrame(0.1)
                SetParkedVehicleDensityMultiplierThisFrame(0.0)
            else
                SetVehicleDensityMultiplierThisFrame(0.0)
                SetParkedVehicleDensityMultiplierThisFrame(0.1)
            end
        else
          SetParkedVehicleDensityMultiplierThisFrame(0.0)
          SetVehicleDensityMultiplierThisFrame(0.1)
        end
	end
end)

You have all permission to edit it. Enjoy!

8 Likes

Well done, those type of scripts I actually really enjoy. Happy to see a useful release.

Thanks!

We agree that on your script the pnj are disabled since I see 0 on these commands.

SetPedDensityMultiplierThisFrame(0.0)
SetRandomVehicleDensityMultiplierThisFrame(0.0)
SetScenarioPedDensityMultiplierThisFrame(0.0, 0.0)

Do I have to put 0.1 for the recovered ones?

Hello. You should keep it as 0.0 that ones to prevent bugging them and completely disable them.

Okay thanks !

so you fixed onesync npc by disabling all kind of populations ?

2 Likes

duh of course it’s a fix to just lower/disable stuff :man_facepalming:

5 Likes

thanks , I have been waiting for this for a while

The issue was the vehicles spawning randomly, no walking NPCs. They are removed aswell.

Working very well!

Hello,
I checked the codes and i see that you set all settings = 0. So we wont see any NPC and NPC Vehicles on our map right ? For OneSync fix ( random car spawn bla bla. ) what settings do you use for your server?

This is just disabling them?

Correct, this will just disable NPC. You should change the title as it can be very misleading for people who have no idea what the code is actually doing and just going off your title thinking its a fix.

Looks A LOT like a ‘fix’ I shared in #onesync on Discord quite some time ago

Which we’ve also improved a lot more since that date.

1 Like

Love this resource, really helpful

1 Like

Hey. That code + the one before that fixes the issue.

We don’t need stupid workaround ‘fixes’ to be posted here.

Either provide a proper repro so there can be a proper fix, or fuck off.