查看: 195|回复: 0
收起左侧

[未解决] AI车辆生成问题

[复制链接]

升级进度: 23%

xiaojiou 发表于 2023-10-21 11:07:33 | 显示全部楼层 |阅读模式
现在也有No-NPC这种删除AI车辆的插件 但是这些插件的代码是




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

                -- These natives have to be called every frame.
                SetVehicleDensityMultiplierThisFrame(0.0) -- set traffic density to 0
                SetPedDensityMultiplierThisFrame(1.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
                SetParkedVehicleDensityMultiplierThisFrame(0.2) -- set random parked vehicles (parked car scenarios) to 0
                SetScenarioPedDensityMultiplierThisFrame(1.0, 1.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);
        end
end)



这种方法对性能占用较大 如图
image.png

我之前试过
        local ped

        Citizen.CreateThread(function()
       
        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.
        SetGarbageTrucks(false) -- Stop garbage trucks from randomly spawning
        SetRandomBoats(false) -- Stop random boats from spawning in the water.
       
                while true do
                        Citizen.Wait(1) -- prevent crashing
       
                        -- These natives have to be called every frame.
                        SetVehicleDensityMultiplierThisFrame(0.0) -- set traffic density to 0
                        SetRandomVehicleDensityMultiplierThisFrame(0.0) -- set random vehicles (car scenarios / cars driving off from a parking spot etc.) to 0
                        SetParkedVehicleDensityMultiplierThisFrame(0.0) -- set random parked vehicles (parked car scenarios) to 0
                end
        end)
        Citizen.CreateThread(function()
                while true do
                        Citizen.Wait(3000)
                        local x,y,z = table.unpack(GetEntityCoords(ped))
                        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);
                end
        end)
        Citizen.CreateThread(function()
                while true do
                        Wait(5000)
                        ped = PlayerPedId()
                end
        end)

这种方法可以删除大部分的AI车辆 并且有效降低性能占用 但是他不能把车辆全部删除干净 仍然偶尔会有一到两辆车生成

有没有什么办法 可以把AI车辆彻底删除干净 并且减少占用


回复 论坛版权

使用道具 举报

ahome_bigavatar:guest
ahome_bigavatar:welcomelogin
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|首页 ( 冀ICP备2021005225号-1 )|网站地图 |网站地图

GMT+8, 2024-2-22 19:45 , Processed in 0.125289 second(s), 27 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表