[WIP] [ESX] Command to delete all pickups at once

So, I’m trying to make this command for ESX 1.2 but this only works after I restart the resource where I have the command - it only works for the first time but then all I get is:

I will need to restart the resource in order to get them removed again…
It’s like the ESX.Pickups table needs to be updated or something idk??

RegisterCommand("clearpickups", function(source, args, rawCommand) -- smth is wrong - it only works after resource restart
	if source ~= 0 then
		local xPlayer = ESX.GetPlayerFromId(source)
		if havePermission(xPlayer, {'moderator'}) then
			local totalpickups = 0
			for k,v in pairs(ESX.Pickups) do
				-- print('k = '..k)
				-- print('v.type = '..v.type)
				-- print('v.name = '..v.name)
				-- print('v.count = '..v.count)
				-- print('---------------------')
				ESX.Pickups[k] = nil
				TriggerClientEvent('esx:removePickup', -1, k)
				totalpickups = totalpickups + 1
			end
			TriggerClientEvent('chatMessage', xPlayer.source, '^*^2CLEARING PICKUPS: ^r'..totalpickups..' pickups have been successfully removed!')
		end
	end
end, false)

Any help would be much appreciated!

bumping…