Hello,
i have a small script, that does the following:
-
Disable weapon drops from NPC
-
Disable EMS dispatch
-
Disable all ai cops
Problem is, when i run resmon 1 in console, this script takes alot of resources and drops fps.
Would there be any way to optimise this script? Thanks!
local pedindex = {}
function SetWeaponDrops()
local handle, ped = FindFirstPed()
local finished = false
repeat
if not IsEntityDead(ped) then
pedindex[ped] = {}
end
finished, ped = FindNextPed(handle)
until not finished
EndFindPed(handle)
for peds,_ in pairs(pedindex) do
if peds ~= nil then
SetPedDropsWeaponsWhenDead(peds, false)
end
end
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
SetWeaponDrops()
for i = 1, 15 do
EnableDispatchService(i, false)
end
local playerPed = GetPlayerPed(-1)
local playerLocalisation = GetEntityCoords(playerPed)
ClearAreaOfCops(playerLocalisation.x, playerLocalisation.y, playerLocalisation.z, 400.0)
end
end)