378 lines
12 KiB
Lua
378 lines
12 KiB
Lua
-- Ultra Fast Sell System
|
|
-- ระบบขายของแบบเร็วที่สุด
|
|
|
|
print("💰 Loading Ultra Fast Sell System...")
|
|
|
|
-- Services
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
local Players = game:GetService("Players")
|
|
local RunService = game:GetService("RunService")
|
|
local TweenService = game:GetService("TweenService")
|
|
|
|
local LocalPlayer = Players.LocalPlayer
|
|
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
|
|
local Leaderstats = LocalPlayer:WaitForChild("leaderstats")
|
|
local Backpack = LocalPlayer:WaitForChild("Backpack")
|
|
|
|
-- Ultra Fast Sell Settings
|
|
local SellSettings = {
|
|
-- Sell Settings
|
|
AutoSell = true,
|
|
SellThreshold = 70, -- ขายเมื่อเหลือ 70%
|
|
SellImmediately = true, -- ขายทันทีเมื่อเต็ม
|
|
MaxInventorySlots = 200,
|
|
|
|
-- Performance Settings
|
|
SellDelay = 0.05, -- ดีเลย์ขาย
|
|
TeleportDelay = 0.1, -- ดีเลย์เทเลพอร์ต
|
|
UseSmoothTeleport = false, -- ใช้ smooth teleport หรือไม่
|
|
|
|
-- Smart Settings
|
|
SmartSell = true,
|
|
SellWhenNearFull = true,
|
|
SellAtThreshold = true,
|
|
|
|
-- Batch Settings
|
|
BatchSell = true,
|
|
SellBatchSize = 50,
|
|
MaxSellAttempts = 3
|
|
}
|
|
|
|
-- Performance Variables
|
|
local IsSelling = false
|
|
local LastSellTime = 0
|
|
local SellCooldown = 1 -- 1 วินาที cooldown
|
|
|
|
-- Game Objects
|
|
local GameEvents = ReplicatedStorage:WaitForChild("GameEvents")
|
|
|
|
-- Get Inventory Count
|
|
local function GetTotalInventoryCount()
|
|
local totalCount = 0
|
|
local Character = LocalPlayer.Character
|
|
|
|
local function CountFromParent(Parent)
|
|
for _, Tool in pairs(Parent:GetChildren()) do
|
|
if Tool:IsA("Tool") then
|
|
totalCount = totalCount + 1
|
|
end
|
|
end
|
|
end
|
|
|
|
CountFromParent(Backpack)
|
|
if Character then
|
|
CountFromParent(Character)
|
|
end
|
|
|
|
return totalCount
|
|
end
|
|
|
|
-- Get Crops Count
|
|
local function GetCropsCount()
|
|
local cropsCount = 0
|
|
local Character = LocalPlayer.Character
|
|
|
|
local function CountFromParent(Parent)
|
|
for _, Tool in pairs(Parent:GetChildren()) do
|
|
if Tool:IsA("Tool") then
|
|
local ItemString = Tool:FindFirstChild("Item_String")
|
|
if ItemString then
|
|
cropsCount = cropsCount + 1
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
CountFromParent(Backpack)
|
|
if Character then
|
|
CountFromParent(Character)
|
|
end
|
|
|
|
return cropsCount
|
|
end
|
|
|
|
-- Smart Sell Decision
|
|
local function ShouldSell()
|
|
local currentTime = tick()
|
|
|
|
-- Cooldown check
|
|
if (currentTime - LastSellTime) < SellCooldown then
|
|
return false, "cooldown"
|
|
end
|
|
|
|
local totalItems = GetTotalInventoryCount()
|
|
local cropsCount = GetCropsCount()
|
|
|
|
-- Immediate sell when full
|
|
if SellSettings.SellImmediately and totalItems >= SellSettings.MaxInventorySlots then
|
|
return true, "กระเป๋าเต็มทันที (" .. totalItems .. "/" .. SellSettings.MaxInventorySlots .. ")"
|
|
end
|
|
|
|
-- Sell when near full
|
|
if SellSettings.SellWhenNearFull and totalItems >= (SellSettings.MaxInventorySlots - 5) then
|
|
return true, "กระเป๋าใกล้เต็ม (" .. totalItems .. "/" .. SellSettings.MaxInventorySlots .. ")"
|
|
end
|
|
|
|
-- Sell at threshold
|
|
if SellSettings.SellAtThreshold and totalItems >= (SellSettings.MaxInventorySlots * SellSettings.SellThreshold / 100) then
|
|
return true, "ถึงเกณฑ์ขาย (" .. math.floor((totalItems / SellSettings.MaxInventorySlots) * 100) .. "%)"
|
|
end
|
|
|
|
-- Sell when have crops
|
|
if cropsCount > 0 and totalItems >= 10 then
|
|
return true, "มีผลผลิต (" .. cropsCount .. " ชิ้น)"
|
|
end
|
|
|
|
return false, "ยังไม่ถึงเวลา"
|
|
end
|
|
|
|
-- Ultra Fast Sell Function
|
|
local function SellInventory()
|
|
if IsSelling then return false end
|
|
IsSelling = true
|
|
|
|
local Character = LocalPlayer.Character
|
|
if not Character then
|
|
IsSelling = false
|
|
return false
|
|
end
|
|
|
|
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
|
|
if not HumanoidRootPart then
|
|
IsSelling = false
|
|
return false
|
|
end
|
|
|
|
local Previous = HumanoidRootPart.CFrame
|
|
local ShecklesCount = Leaderstats:FindFirstChild("Sheckles")
|
|
|
|
print("💰 เริ่มขายของ...")
|
|
|
|
-- Ultra fast teleport to sell area
|
|
if SellSettings.UseSmoothTeleport then
|
|
local targetPos = CFrame.new(62, 4, -26)
|
|
local tween = TweenService:Create(HumanoidRootPart, TweenInfo.new(SellSettings.TeleportDelay), {
|
|
CFrame = targetPos
|
|
})
|
|
tween:Play()
|
|
tween.Completed:Wait()
|
|
else
|
|
HumanoidRootPart.CFrame = CFrame.new(62, 4, -26)
|
|
end
|
|
|
|
wait(SellSettings.TeleportDelay)
|
|
|
|
local soldAmount = 0
|
|
local previousSheckles = ShecklesCount and ShecklesCount.Value or 0
|
|
|
|
if ShecklesCount then
|
|
local SellEvent = GameEvents:FindFirstChild("Sell_Inventory")
|
|
if SellEvent then
|
|
local attempts = 0
|
|
|
|
-- Batch sell
|
|
if SellSettings.BatchSell then
|
|
while attempts < SellSettings.MaxSellAttempts do
|
|
if ShecklesCount.Value ~= previousSheckles then
|
|
soldAmount = ShecklesCount.Value - previousSheckles
|
|
break
|
|
end
|
|
|
|
SellEvent:FireServer()
|
|
wait(SellSettings.SellDelay)
|
|
attempts = attempts + 1
|
|
end
|
|
else
|
|
-- Single sell
|
|
SellEvent:FireServer()
|
|
wait(SellSettings.SellDelay)
|
|
|
|
if ShecklesCount.Value ~= previousSheckles then
|
|
soldAmount = ShecklesCount.Value - previousSheckles
|
|
end
|
|
end
|
|
|
|
if soldAmount > 0 then
|
|
print("💰 ขายสำเร็จ! ได้เงิน " .. soldAmount .. " sheckles")
|
|
else
|
|
print("⚠️ ขายไม่สำเร็จ")
|
|
end
|
|
else
|
|
print("❌ ไม่พบ Sell Event")
|
|
end
|
|
end
|
|
|
|
-- Return to previous position
|
|
if SellSettings.UseSmoothTeleport then
|
|
local tween = TweenService:Create(HumanoidRootPart, TweenInfo.new(SellSettings.TeleportDelay), {
|
|
CFrame = Previous
|
|
})
|
|
tween:Play()
|
|
tween.Completed:Wait()
|
|
else
|
|
HumanoidRootPart.CFrame = Previous
|
|
end
|
|
|
|
wait(SellSettings.TeleportDelay)
|
|
|
|
IsSelling = false
|
|
LastSellTime = tick()
|
|
|
|
return soldAmount > 0
|
|
end
|
|
|
|
-- Ultra Fast Sell Loop
|
|
local function UltraFastSellLoop()
|
|
if not SellSettings.AutoSell or IsSelling then return end
|
|
|
|
local shouldSell, reason = ShouldSell()
|
|
if not shouldSell then return end
|
|
|
|
local totalItems = GetTotalInventoryCount()
|
|
local cropsCount = GetCropsCount()
|
|
|
|
print("💰 ขาย " .. cropsCount .. " ผลผลิต (" .. reason .. ") - ทั้งหมด " .. totalItems .. " ชิ้น")
|
|
|
|
local success = SellInventory()
|
|
if success then
|
|
print("✅ ขายสำเร็จ!")
|
|
else
|
|
print("❌ ขายไม่สำเร็จ")
|
|
end
|
|
end
|
|
|
|
-- Main Loop
|
|
local function StartUltraFastSellLoop()
|
|
print("💰 Starting Ultra Fast Sell Loop...")
|
|
|
|
spawn(function()
|
|
while true do
|
|
local success, err = pcall(UltraFastSellLoop)
|
|
if not success then
|
|
print("⚠️ Ultra Fast Sell error: " .. tostring(err))
|
|
end
|
|
wait(0.5) -- ตรวจสอบทุก 0.5 วินาที
|
|
end
|
|
end)
|
|
|
|
print("✅ Ultra Fast Sell Loop started")
|
|
end
|
|
|
|
-- Simple UI
|
|
local function CreateUltraFastSellUI()
|
|
print("🎨 Creating Ultra Fast Sell UI...")
|
|
|
|
local ScreenGui = Instance.new("ScreenGui")
|
|
ScreenGui.Name = "UltraFastSellUI"
|
|
ScreenGui.Parent = PlayerGui
|
|
ScreenGui.ResetOnSpawn = false
|
|
|
|
local MainFrame = Instance.new("Frame")
|
|
MainFrame.Name = "MainFrame"
|
|
MainFrame.Parent = ScreenGui
|
|
MainFrame.BackgroundColor3 = Color3.fromRGB(25, 25, 30)
|
|
MainFrame.BorderSizePixel = 0
|
|
MainFrame.Position = UDim2.new(0, 400, 0, 300)
|
|
MainFrame.Size = UDim2.new(0, 250, 0, 200)
|
|
MainFrame.Active = true
|
|
MainFrame.Draggable = true
|
|
|
|
local Corner = Instance.new("UICorner")
|
|
Corner.CornerRadius = UDim.new(0, 12)
|
|
Corner.Parent = MainFrame
|
|
|
|
local Stroke = Instance.new("UIStroke")
|
|
Stroke.Parent = MainFrame
|
|
Stroke.Color = Color3.fromRGB(100, 255, 100)
|
|
Stroke.Thickness = 2
|
|
|
|
-- Title
|
|
local Title = Instance.new("TextLabel")
|
|
Title.Parent = MainFrame
|
|
Title.BackgroundColor3 = Color3.fromRGB(100, 255, 100)
|
|
Title.BorderSizePixel = 0
|
|
Title.Size = UDim2.new(1, 0, 0, 40)
|
|
Title.Font = Enum.Font.SourceSansBold
|
|
Title.Text = "💰 Ultra Fast Sell"
|
|
Title.TextColor3 = Color3.fromRGB(255, 255, 255)
|
|
Title.TextSize = 16
|
|
|
|
local TitleCorner = Instance.new("UICorner")
|
|
TitleCorner.CornerRadius = UDim.new(0, 12)
|
|
TitleCorner.Parent = Title
|
|
|
|
-- Status
|
|
local StatusLabel = Instance.new("TextLabel")
|
|
StatusLabel.Parent = MainFrame
|
|
StatusLabel.BackgroundTransparency = 1
|
|
StatusLabel.Position = UDim2.new(0, 10, 0, 50)
|
|
StatusLabel.Size = UDim2.new(1, -20, 0, 20)
|
|
StatusLabel.Font = Enum.Font.SourceSans
|
|
StatusLabel.Text = "สถานะ: พร้อมขาย"
|
|
StatusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
|
|
StatusLabel.TextSize = 12
|
|
StatusLabel.TextXAlignment = Enum.TextXAlignment.Left
|
|
|
|
-- Stats
|
|
local StatsLabel = Instance.new("TextLabel")
|
|
StatsLabel.Parent = MainFrame
|
|
StatsLabel.BackgroundTransparency = 1
|
|
StatsLabel.Position = UDim2.new(0, 10, 0, 80)
|
|
StatsLabel.Size = UDim2.new(1, -20, 0, 100)
|
|
StatsLabel.Font = Enum.Font.SourceSans
|
|
StatsLabel.Text = "สถิติ:\n- เกณฑ์ขาย: " .. SellSettings.SellThreshold .. "%\n- ดีเลย์ขาย: " .. SellSettings.SellDelay .. " วินาที\n- ดีเลย์เทเลพอร์ต: " .. SellSettings.TeleportDelay .. " วินาที\n- กระเป๋า: " .. SellSettings.MaxInventorySlots .. " ช่อง"
|
|
StatsLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
|
|
StatsLabel.TextSize = 10
|
|
StatsLabel.TextXAlignment = Enum.TextXAlignment.Left
|
|
StatsLabel.TextYAlignment = Enum.TextYAlignment.Top
|
|
|
|
-- Manual Sell Button
|
|
local SellButton = Instance.new("TextButton")
|
|
SellButton.Parent = MainFrame
|
|
SellButton.BackgroundColor3 = Color3.fromRGB(100, 255, 100)
|
|
SellButton.BorderSizePixel = 0
|
|
SellButton.Position = UDim2.new(0, 10, 1, -40)
|
|
SellButton.Size = UDim2.new(1, -20, 0, 30)
|
|
SellButton.Font = Enum.Font.SourceSansBold
|
|
SellButton.Text = "ขายทันที"
|
|
SellButton.TextColor3 = Color3.fromRGB(255, 255, 255)
|
|
SellButton.TextSize = 14
|
|
|
|
local ButtonCorner = Instance.new("UICorner")
|
|
ButtonCorner.CornerRadius = UDim.new(0, 6)
|
|
ButtonCorner.Parent = SellButton
|
|
|
|
SellButton.MouseButton1Click:Connect(function()
|
|
if not IsSelling then
|
|
SellInventory()
|
|
end
|
|
end)
|
|
|
|
print("✅ Ultra Fast Sell UI created")
|
|
end
|
|
|
|
-- Initialize
|
|
print("💰 Initializing Ultra Fast Sell System...")
|
|
|
|
wait(1)
|
|
|
|
CreateUltraFastSellUI()
|
|
StartUltraFastSellLoop()
|
|
|
|
game:GetService("StarterGui"):SetCore("SendNotification", {
|
|
Title = "💰 Ultra Fast Sell",
|
|
Text = "ระบบขายของเร็วที่สุดพร้อมใช้งาน!",
|
|
Duration = 3
|
|
})
|
|
|
|
print("💰 " .. string.rep("=", 50))
|
|
print("✅ Ultra Fast Sell System พร้อมใช้งาน!")
|
|
print("💰 เกณฑ์ขาย: " .. SellSettings.SellThreshold .. "%")
|
|
print("💰 ดีเลย์ขาย: " .. SellSettings.SellDelay .. " วินาที")
|
|
print("💰 ดีเลย์เทเลพอร์ต: " .. SellSettings.TeleportDelay .. " วินาที")
|
|
print("💰 " .. string.rep("=", 50))
|
|
|
|
return {
|
|
Settings = SellSettings,
|
|
UI = ScreenGui
|
|
} |