Hey, I did this but that resulted in flashing of hud text. Although this has definitely improved the performance a lot.
Idea: It would also make sense if only the unemployed were allowed to search trash cans.
You did the sleep = 5 ?? You can do sleep = 1 and see if that changes anything for you
What you can do is if you’re at a distance of > 10 then sleep, whenever you’re close keep the sleep at 0. Which is what I’ve currently done, since it’s drawing text it kind of needs to be 0.
I got this down to 0.23 then just decided to make my own, thanks anyway, good idea
If he takes out the constant sweep of checking for dumpsters the resource would take less time.
Hi, sorry not been around much.
This is what I done to bring the resource usage down
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if canSearch then
local ped = GetPlayerPed(-1)
local pos = GetEntityCoords(ped)
local dumpsterFound = false
local dumpsterAround = false
for i = 1, #dumpsters do
local dumpster = GetClosestObjectOfType(pos.x, pos.y, pos.z, 1.0, dumpsters[i], false, false, false)
local dumpPos = GetEntityCoords(dumpster)
local dist = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, dumpPos.x, dumpPos.y, dumpPos.z, true)
if dumpster then
dumpsterAround = true
end
if dist < 1.8 then
DrawText3Ds(dumpPos.x, dumpPos.y, dumpPos.z + 1.0, 'Press [~y~H~w~] to dumpster dive')
if IsControlJustReleased(0, 74) then
for i = 1, #searched do
if searched[i] == dumpster then
dumpsterFound = true
end
if i == #searched and dumpsterFound then
exports['mythic_notify']:DoHudText('error', 'You already searched this dumpster')
elseif i == #searched and not dumpsterFound then
startSearching(searchTime, 'amb@prop_human_bum_bin@base', 'base', 'onyx:giveDumpsterReward')
TriggerServerEvent('onyx:startDumpsterTimer', dumpster)
table.insert(searched, dumpster)
end
end
end
end
end
if not dumpsterAround then
Citizen.Wait(5000)
end
end
end
end)
Probably add more sleeps and get it down to 0.1
I got it 0.01, im talking about when near the dumpster
local sleep = 0
Citizen.CreateThread(function()
while true do
sleep = 1500
if canSearch then
local ped = GetPlayerPed(-1)
local pos = GetEntityCoords(ped)
local dumpsterFound = false
for i = 1, #dumpsters do
local dumpster = GetClosestObjectOfType(pos.x, pos.y, pos.z, 1.0, dumpsters[i], false, false, false)
local dumpPos = GetEntityCoords(dumpster)
local dist = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, dumpPos.x, dumpPos.y, dumpPos.z, true)
if dist < 1.8 then
sleep = 5
DrawText3Ds(dumpPos.x, dumpPos.y, dumpPos.z + 1.0, 'Нажмите [~y~H~w~] чтобы обыскать контейнер')
if IsControlJustReleased(0, 74) then
for i = 1, #searched do
if searched[i] == dumpster then
dumpsterFound = true
end
if i == #searched and dumpsterFound then
ESX.ShowNotification('Этот мусорный контейнер уже пуст')
elseif i == #searched and not dumpsterFound then
startSearching(searchTime, 'amb@prop_human_bum_bin@base', 'base', 'onyx:giveDumpsterReward')
TriggerServerEvent('onyx:startDumpsterTimer', dumpster)
table.insert(searched, dumpster)
end
end
end
end
end
end
Citizen.Wait(sleep)
end
end)
Если это возможно, я тебя поцелую
Не нужно ))
does not seem to work nothing in bins do any one have better mysql
Hello i got problem… i remade this to military loot crate and when u go like 50 m away u can loot itagain… and the cooldown is ignored any idea what to do ?
SQL query:
``
INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`, `price`) VALUES
('glassbottle', 'Glass Bottle', 1, 0, 1, 0),
('wallet', 'Wallet', 1, 0, 1, 0),
('oldshoe', 'Old Shoe', 1, 0, 1, 0),
('mouldybread', 'Mouldy Bread', 1, 0, 1, 0),
('plastic', 'Plastic', 1, 0, 1, 0),
('electronics', 'Electronics', 1, 0, 1, 0),
('lowgradefemaleseed', 'Female Seed', 1, 0, 1, 0),
('lowgrademaleseed', 'Male Seed', 1, 0, 1, 0),
('deadbatteries', 'Dead Batteries', 1, 0, 1, 0),
('cellphone', 'Phone', 1, 0, 1, 0),
('rubber', 'Rubber', 1, 0, 1, 0),
('brokenfishingrod', 'Broken Fishing Rod', 1, 0, 1, 0),
('cartire', 'Car Tire', 1, 0, 1, 0),
('oldring', 'Old Ring', 1, 0, 1, 0),
('advancedlockpick', 'Advanced Lockpick', 1, 0, 1, 0),
('expiredburger', 'Expired Burger', 1, 0, 1, 0)
#1054 - Unknown column 'weight' in 'field list'
I have a car building script in my city and I edited this script to not only control searching dumpsters for trash/loot but to also be able to search wrecked cars and such for car parts. Everything in 1 resource both pulling from different props and loot tables.
did you want to release it?
Let me finish adding in a few things then I will. The searching for car parts will only work with Opod Project Cars script, but you can easily modify the items it will give to something else if you have a different car building scirpt.
Easy fix. Change weight to limit. Doing same thing in script. Anything that says weight replace it with limit.