-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautosell.lua
More file actions
59 lines (52 loc) · 1.45 KB
/
autosell.lua
File metadata and controls
59 lines (52 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
local maxPrice = 50000 --// You can't sell items worth more than 50k
--// Modules
local InfoModule = require(game.ReplicatedStorage.Modules.Info)
--// Variables
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local List = LocalPlayer.PlayerGui.Gui.Frames.Inventory.SubInventory.Holder.List
--// Quick sell
local function sellItem(itemName, amount)
spawn(function()
local args = {
[1] = "QuickSell",
[2] = itemName,
[3] = amount
}
game:GetService("ReplicatedStorage").Events.InventoryActions:InvokeServer(unpack(args))
end)
end
--// Checks if item is under max price
_G.autosell = true
local function isValidItem(name, maxprice)
if _G.autosell then
local RAP = InfoModule:ReturnItemFromModule(name).recentAveragePrice
return RAP <= maxprice
end
return false
end
--// Gets all items into a table
local items = {}
for i,v in pairs(List:GetChildren()) do
if v:IsA("Frame") then
if not items[v.Name] then
items[v.Name] = 1
else
items[v.Name] = items[v.Name] + 1
end
end
end
--// Sell current items
for itemName, amount in pairs(items) do
if isValidItem(itemName, maxPrice) then
sellItem(itemName)
end
end
--// Sell items being added
List.ChildAdded:Connect(function(item)
if item:IsA("Frame") then
if isValidItem(item.Name, maxPrice) then
sellItem(item.Name)
end
end
end)