1088 lines
35 KiB
Lua
1088 lines
35 KiB
Lua
-- Ultimate Optimized System
|
|
-- ระบบรวมที่ปรับปรุงการเก็บของ ขายของ และเลี้ยงสัตว์ให้เร็วขึ้นและ Smooth ขึ้น
|
|
|
|
print("🚀 Loading Ultimate Optimized System...")
|
|
|
|
-- Services
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
local Players = game:GetService("Players")
|
|
local RunService = game:GetService("RunService")
|
|
local TweenService = game:GetService("TweenService")
|
|
local HttpService = game:GetService("HttpService")
|
|
|
|
local LocalPlayer = Players.LocalPlayer
|
|
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
|
|
local Leaderstats = LocalPlayer:WaitForChild("leaderstats")
|
|
local Backpack = LocalPlayer:WaitForChild("Backpack")
|
|
|
|
print("✅ Services loaded")
|
|
|
|
-- ป้องกันการรันซ้ำ
|
|
if _G.UltimateOptimizedSystemLoaded then
|
|
print("⚠️ Ultimate Optimized System already loaded, removing old one...")
|
|
if _G.UltimateOptimizedSystemUI then
|
|
_G.UltimateOptimizedSystemUI:Destroy()
|
|
end
|
|
end
|
|
_G.UltimateOptimizedSystemLoaded = true
|
|
|
|
-- Game Objects
|
|
local GameEvents = ReplicatedStorage:WaitForChild("GameEvents")
|
|
local Farms = workspace:WaitForChild("Farm")
|
|
|
|
print("✅ Game objects found")
|
|
|
|
-- Ultimate Optimized Settings
|
|
local UltimateSettings = {
|
|
-- Harvest Settings (เก็บของ)
|
|
AutoHarvest = true,
|
|
HarvestSpeed = "Ultra Fast",
|
|
HarvestDelay = 0.001, -- ดีเลย์น้อยที่สุด
|
|
MaxHarvestPerSecond = 100, -- เก็บสูงสุดต่อวินาที
|
|
ParallelHarvest = true, -- เก็บแบบ Parallel
|
|
BatchHarvest = true, -- เก็บเป็นชุด
|
|
HarvestBatchSize = 25, -- ขนาดชุด
|
|
UseThreading = true,
|
|
MaxThreads = 8,
|
|
|
|
-- Sell Settings (ขายของ)
|
|
AutoSell = true,
|
|
SellThreshold = 70, -- ขายเมื่อเหลือ 70%
|
|
SellImmediately = true, -- ขายทันทีเมื่อเต็ม
|
|
SellDelay = 0.05, -- ดีเลย์ขาย
|
|
TeleportDelay = 0.1, -- ดีเลย์เทเลพอร์ต
|
|
BatchSell = true,
|
|
MaxSellAttempts = 3,
|
|
|
|
-- Pet Settings (เลี้ยงสัตว์)
|
|
AutoHatchEgg = true,
|
|
AutoFeedPets = true,
|
|
AutoBuyEggs = true,
|
|
AutoEquipPets = true,
|
|
SelectedEggType = "Common Egg",
|
|
MaxPetsToHatch = 10,
|
|
HatchInterval = 30, -- ฟักไข่ทุก 30 วินาที
|
|
FeedInterval = 60, -- ให้อาหารทุก 60 วินาที
|
|
BuyInterval = 120, -- ซื้อไข่ทุก 2 นาที
|
|
|
|
-- Performance Settings
|
|
MaxInventorySlots = 200,
|
|
UseSmoothAnimations = true,
|
|
AnimationDuration = 0.5,
|
|
UseCache = true,
|
|
CacheDuration = 0.05,
|
|
SmartInventory = true,
|
|
|
|
-- Harvest Filter
|
|
HarvestGolden = true,
|
|
HarvestSpecial = false,
|
|
HarvestNormal = true
|
|
}
|
|
|
|
-- Performance Variables
|
|
local HarvestCache = {}
|
|
local LastCacheTime = 0
|
|
local IsHarvesting = false
|
|
local IsSelling = false
|
|
local IsProcessingPets = false
|
|
local LastHatchTime = 0
|
|
local LastFeedTime = 0
|
|
local LastBuyTime = 0
|
|
local LastSellTime = 0
|
|
local SellCooldown = 1
|
|
|
|
-- Pet Data
|
|
local PetEggTypes = {
|
|
["Common Egg"] = { HatchTime = 600, Price = 100, Rarity = "Common" },
|
|
["Uncommon Egg"] = { HatchTime = 1200, Price = 500, Rarity = "Uncommon" },
|
|
["Rare Egg"] = { HatchTime = 7200, Price = 2500, Rarity = "Rare" },
|
|
["Legendary Egg"] = { HatchTime = 14400, Price = 10000, Rarity = "Legendary" },
|
|
["Mythical Egg"] = { HatchTime = 18400, Price = 50000, Rarity = "Mythical" }
|
|
}
|
|
|
|
local PetEvents = {}
|
|
|
|
-- Find Player's Farm
|
|
local function GetFarm(PlayerName)
|
|
local AllFarms = Farms:GetChildren()
|
|
for _, Farm in pairs(AllFarms) do
|
|
local Important = Farm:FindFirstChild("Important")
|
|
if Important then
|
|
local Data = Important:FindFirstChild("Data")
|
|
if Data then
|
|
local Owner = Data:FindFirstChild("Owner")
|
|
if Owner and Owner.Value == PlayerName then
|
|
return Farm
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return nil
|
|
end
|
|
|
|
local MyFarm = GetFarm(LocalPlayer.Name)
|
|
if not MyFarm then
|
|
warn("❌ Cannot find player's farm!")
|
|
game:GetService("StarterGui"):SetCore("SendNotification", {
|
|
Title = "Ultimate Optimized System",
|
|
Text = "ไม่พบฟาร์มของคุณ!",
|
|
Duration = 5
|
|
})
|
|
return
|
|
end
|
|
|
|
print("✅ Found player farm: " .. MyFarm.Name)
|
|
|
|
local MyImportant = MyFarm:FindFirstChild("Important")
|
|
local PlantsPhysical = MyImportant:FindFirstChild("Plants_Physical")
|
|
|
|
-- Find Pet Events
|
|
local function FindPetEvents()
|
|
print("🔍 ค้นหา Pet RemoteEvents...")
|
|
|
|
for _, obj in pairs(ReplicatedStorage:GetDescendants()) do
|
|
if obj:IsA("RemoteEvent") or obj:IsA("RemoteFunction") then
|
|
local name = obj.Name:lower()
|
|
if name:find("pet") or name:find("egg") or name:find("hatch") or
|
|
name:find("feed") or name:find("animal") or name:find("equip") or
|
|
name:find("buy") or name:find("sell") or name:find("spawn") then
|
|
PetEvents[obj.Name] = obj
|
|
print("🐾 พบ Pet Event: " .. obj.Name)
|
|
end
|
|
end
|
|
end
|
|
|
|
if next(PetEvents) == nil then
|
|
print("⚠️ ไม่พบ Pet Events เฉพาะ จะใช้ GameEvents แทน")
|
|
local possibleEvents = {
|
|
"HatchEgg", "FeedPet", "BuyEgg", "EquipPet", "UnequipPet", "SellPet",
|
|
"Hatch", "Feed", "Buy", "Equip", "Unequip", "Sell"
|
|
}
|
|
|
|
for _, eventName in pairs(possibleEvents) do
|
|
local event = GameEvents:FindFirstChild(eventName)
|
|
if event then
|
|
PetEvents[eventName] = event
|
|
print("🐾 พบ GameEvent: " .. eventName)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
FindPetEvents()
|
|
|
|
-- Ultra Fast Harvest Functions
|
|
local function ShouldHarvestPlant(Plant)
|
|
local plantName = Plant.Name:lower()
|
|
|
|
local specialEffects = {
|
|
"shocked", "moonlit", "twisted", "burnt", "frozen", "wet",
|
|
"bloodlit", "zombified", "celestial", "disco", "plasma",
|
|
"voidtouched", "honeyglazed", "pollinated", "chilled",
|
|
"radiant", "aurora", "crystal", "shadow", "ethereal"
|
|
}
|
|
|
|
local hasSpecialEffect = false
|
|
for _, effect in pairs(specialEffects) do
|
|
if plantName:find(effect) then
|
|
hasSpecialEffect = true
|
|
break
|
|
end
|
|
end
|
|
|
|
local isGolden = plantName:find("golden") or plantName:find("gold")
|
|
|
|
if Plant:IsA("Model") and Plant.PrimaryPart then
|
|
local primaryPart = Plant.PrimaryPart
|
|
if primaryPart.Color == Color3.new(1, 0.8, 0) or
|
|
primaryPart.Color == Color3.fromRGB(255, 215, 0) then
|
|
isGolden = true
|
|
end
|
|
|
|
if primaryPart:FindFirstChild("PointLight") or
|
|
primaryPart:FindFirstChild("SpotLight") or
|
|
primaryPart:FindFirstChild("SurfaceLight") then
|
|
hasSpecialEffect = true
|
|
end
|
|
end
|
|
|
|
if hasSpecialEffect and not UltimateSettings.HarvestSpecial then
|
|
return false
|
|
end
|
|
|
|
if isGolden and not UltimateSettings.HarvestGolden then
|
|
return false
|
|
end
|
|
|
|
if not isGolden and not hasSpecialEffect and not UltimateSettings.HarvestNormal then
|
|
return false
|
|
end
|
|
|
|
return true
|
|
end
|
|
|
|
local function GetHarvestablePlants()
|
|
local currentTime = tick()
|
|
|
|
if UltimateSettings.UseCache and (currentTime - LastCacheTime) < UltimateSettings.CacheDuration then
|
|
return HarvestCache
|
|
end
|
|
|
|
local Plants = {}
|
|
|
|
local function CollectHarvestable(Parent)
|
|
for _, Plant in pairs(Parent:GetChildren()) do
|
|
if #Plants >= UltimateSettings.MaxHarvestPerSecond then
|
|
break
|
|
end
|
|
|
|
local Fruits = Plant:FindFirstChild("Fruits")
|
|
if Fruits then
|
|
CollectHarvestable(Fruits)
|
|
end
|
|
|
|
local Prompt = Plant:FindFirstChild("ProximityPrompt", true)
|
|
if Prompt and Prompt.Enabled and ShouldHarvestPlant(Plant) then
|
|
table.insert(Plants, Plant)
|
|
end
|
|
end
|
|
end
|
|
|
|
CollectHarvestable(PlantsPhysical)
|
|
|
|
HarvestCache = Plants
|
|
LastCacheTime = currentTime
|
|
|
|
return Plants
|
|
end
|
|
|
|
local function HarvestPlant(Plant)
|
|
local Prompt = Plant:FindFirstChild("ProximityPrompt", true)
|
|
if Prompt and Prompt.Enabled then
|
|
fireproximityprompt(Prompt)
|
|
return true
|
|
end
|
|
return false
|
|
end
|
|
|
|
local function BatchHarvestPlants(Plants, startIndex, endIndex)
|
|
local harvested = 0
|
|
for i = startIndex, endIndex do
|
|
if Plants[i] then
|
|
if HarvestPlant(Plants[i]) then
|
|
harvested = harvested + 1
|
|
end
|
|
end
|
|
end
|
|
return harvested
|
|
end
|
|
|
|
-- Inventory Functions
|
|
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
|
|
|
|
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
|
|
|
|
-- Ultra Fast Sell Functions
|
|
local function ShouldSell()
|
|
local currentTime = tick()
|
|
|
|
if (currentTime - LastSellTime) < SellCooldown then
|
|
return false, "cooldown"
|
|
end
|
|
|
|
local totalItems = GetTotalInventoryCount()
|
|
local cropsCount = GetCropsCount()
|
|
|
|
if UltimateSettings.SellImmediately and totalItems >= UltimateSettings.MaxInventorySlots then
|
|
return true, "กระเป๋าเต็มทันที (" .. totalItems .. "/" .. UltimateSettings.MaxInventorySlots .. ")"
|
|
end
|
|
|
|
if totalItems >= (UltimateSettings.MaxInventorySlots - 5) then
|
|
return true, "กระเป๋าใกล้เต็ม (" .. totalItems .. "/" .. UltimateSettings.MaxInventorySlots .. ")"
|
|
end
|
|
|
|
if totalItems >= (UltimateSettings.MaxInventorySlots * UltimateSettings.SellThreshold / 100) then
|
|
return true, "ถึงเกณฑ์ขาย (" .. math.floor((totalItems / UltimateSettings.MaxInventorySlots) * 100) .. "%)"
|
|
end
|
|
|
|
if cropsCount > 0 and totalItems >= 10 then
|
|
return true, "มีผลผลิต (" .. cropsCount .. " ชิ้น)"
|
|
end
|
|
|
|
return false, "ยังไม่ถึงเวลา"
|
|
end
|
|
|
|
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("💰 เริ่มขายของ...")
|
|
|
|
HumanoidRootPart.CFrame = CFrame.new(62, 4, -26)
|
|
wait(UltimateSettings.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
|
|
|
|
if UltimateSettings.BatchSell then
|
|
while attempts < UltimateSettings.MaxSellAttempts do
|
|
if ShecklesCount.Value ~= previousSheckles then
|
|
soldAmount = ShecklesCount.Value - previousSheckles
|
|
break
|
|
end
|
|
|
|
SellEvent:FireServer()
|
|
wait(UltimateSettings.SellDelay)
|
|
attempts = attempts + 1
|
|
end
|
|
else
|
|
SellEvent:FireServer()
|
|
wait(UltimateSettings.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
|
|
|
|
HumanoidRootPart.CFrame = Previous
|
|
wait(UltimateSettings.TeleportDelay)
|
|
|
|
IsSelling = false
|
|
LastSellTime = tick()
|
|
|
|
return soldAmount > 0
|
|
end
|
|
|
|
-- Pet Functions
|
|
local function GetAllPets()
|
|
local pets = {}
|
|
local Character = LocalPlayer.Character
|
|
|
|
local function isPetTool(tool)
|
|
if not tool:IsA("Tool") then return false end
|
|
|
|
local indicators = {
|
|
"PetData", "Pet_Data", "PetInfo", "Pet_Info",
|
|
"AnimalData", "Animal_Data", "CreatureData",
|
|
"IsPet", "Pet", "Animal", "Creature"
|
|
}
|
|
|
|
for _, indicator in pairs(indicators) do
|
|
if tool:FindFirstChild(indicator) then
|
|
return true, indicator
|
|
end
|
|
end
|
|
|
|
local name = tool.Name:lower()
|
|
local petNames = {
|
|
"dog", "cat", "bunny", "rabbit", "chicken", "cow", "pig", "sheep",
|
|
"bee", "ant", "butterfly", "dragonfly", "mouse", "rat", "hamster"
|
|
}
|
|
|
|
for _, petName in pairs(petNames) do
|
|
if name:find(petName) then
|
|
return true, "NameMatch"
|
|
end
|
|
end
|
|
|
|
return false
|
|
end
|
|
|
|
for _, tool in pairs(Backpack:GetChildren()) do
|
|
local isPet, indicator = isPetTool(tool)
|
|
if isPet then
|
|
table.insert(pets, {
|
|
Tool = tool,
|
|
Name = tool.Name,
|
|
Location = "Backpack",
|
|
Indicator = indicator
|
|
})
|
|
end
|
|
end
|
|
|
|
if Character then
|
|
for _, tool in pairs(Character:GetChildren()) do
|
|
local isPet, indicator = isPetTool(tool)
|
|
if isPet then
|
|
table.insert(pets, {
|
|
Tool = tool,
|
|
Name = tool.Name,
|
|
Location = "Equipped",
|
|
Indicator = indicator
|
|
})
|
|
end
|
|
end
|
|
end
|
|
|
|
return pets
|
|
end
|
|
|
|
local function GetAvailableEggs()
|
|
local eggs = {}
|
|
local Character = LocalPlayer.Character
|
|
|
|
local function isEggTool(tool)
|
|
if not tool:IsA("Tool") then return false end
|
|
|
|
local indicators = {
|
|
"EggData", "Egg_Data", "EggInfo", "Egg_Info",
|
|
"HatchData", "Hatch_Data", "IsEgg", "Egg"
|
|
}
|
|
|
|
for _, indicator in pairs(indicators) do
|
|
if tool:FindFirstChild(indicator) then
|
|
return true, indicator
|
|
end
|
|
end
|
|
|
|
local name = tool.Name:lower()
|
|
if name:find("egg") then
|
|
return true, "NameMatch"
|
|
end
|
|
|
|
for eggType, _ in pairs(PetEggTypes) do
|
|
if tool.Name == eggType then
|
|
return true, "EggTypeMatch"
|
|
end
|
|
end
|
|
|
|
return false
|
|
end
|
|
|
|
local function CollectFromParent(Parent)
|
|
for _, tool in pairs(Parent:GetChildren()) do
|
|
local isEgg, indicator = isEggTool(tool)
|
|
if isEgg then
|
|
table.insert(eggs, {
|
|
Tool = tool,
|
|
Name = tool.Name,
|
|
Indicator = indicator
|
|
})
|
|
end
|
|
end
|
|
end
|
|
|
|
CollectFromParent(Backpack)
|
|
if Character then
|
|
CollectFromParent(Character)
|
|
end
|
|
|
|
return eggs
|
|
end
|
|
|
|
-- Smooth Pet Actions
|
|
local function SmoothHatchEgg(eggData)
|
|
if not eggData or not eggData.Tool then return false end
|
|
|
|
local eggTool = eggData.Tool
|
|
print("🥚 กำลังฟักไข่: " .. eggTool.Name)
|
|
|
|
if UltimateSettings.UseSmoothAnimations then
|
|
local Character = LocalPlayer.Character
|
|
if Character and Character:FindFirstChild("Humanoid") then
|
|
local Humanoid = Character:FindFirstChild("Humanoid")
|
|
Humanoid.WalkSpeed = 0
|
|
wait(UltimateSettings.AnimationDuration)
|
|
Humanoid.WalkSpeed = 16
|
|
end
|
|
end
|
|
|
|
local methods = {
|
|
function()
|
|
if PetEvents.HatchEgg then
|
|
PetEvents.HatchEgg:FireServer(eggTool)
|
|
return "HatchEgg Event"
|
|
end
|
|
end,
|
|
function()
|
|
for eventName, event in pairs(PetEvents) do
|
|
if eventName:lower():find("hatch") then
|
|
event:FireServer(eggTool)
|
|
return eventName .. " Event"
|
|
end
|
|
end
|
|
end,
|
|
function()
|
|
local events = {"HatchEgg", "Hatch", "Pet_Hatch", "Egg_Hatch"}
|
|
for _, eventName in pairs(events) do
|
|
local event = GameEvents:FindFirstChild(eventName)
|
|
if event then
|
|
event:FireServer(eggTool)
|
|
return eventName .. " GameEvent"
|
|
end
|
|
end
|
|
end
|
|
}
|
|
|
|
for _, method in pairs(methods) do
|
|
local success, result = pcall(method)
|
|
if success and result then
|
|
print("✅ ฟักไข่สำเร็จ: " .. eggTool.Name .. " ด้วยวิธี " .. result)
|
|
return true
|
|
end
|
|
end
|
|
|
|
return false
|
|
end
|
|
|
|
local function SmoothFeedPet(petData)
|
|
if not petData or not petData.Tool then return false end
|
|
|
|
local petTool = petData.Tool
|
|
print("🍼 กำลังให้อาหาร: " .. petTool.Name)
|
|
|
|
if UltimateSettings.UseSmoothAnimations then
|
|
local Character = LocalPlayer.Character
|
|
if Character and Character:FindFirstChild("Humanoid") then
|
|
local Humanoid = Character:FindFirstChild("Humanoid")
|
|
Humanoid.WalkSpeed = 0
|
|
wait(UltimateSettings.AnimationDuration)
|
|
Humanoid.WalkSpeed = 16
|
|
end
|
|
end
|
|
|
|
local methods = {
|
|
function()
|
|
if PetEvents.FeedPet then
|
|
PetEvents.FeedPet:FireServer(petTool)
|
|
return "FeedPet Event"
|
|
end
|
|
end,
|
|
function()
|
|
for eventName, event in pairs(PetEvents) do
|
|
if eventName:lower():find("feed") then
|
|
event:FireServer(petTool)
|
|
return eventName .. " Event"
|
|
end
|
|
end
|
|
end,
|
|
function()
|
|
local events = {"FeedPet", "Feed", "Pet_Feed", "Animal_Feed"}
|
|
for _, eventName in pairs(events) do
|
|
local event = GameEvents:FindFirstChild(eventName)
|
|
if event then
|
|
event:FireServer(petTool)
|
|
return eventName .. " GameEvent"
|
|
end
|
|
end
|
|
end
|
|
}
|
|
|
|
for _, method in pairs(methods) do
|
|
local success, result = pcall(method)
|
|
if success and result then
|
|
print("✅ ให้อาหารสำเร็จ: " .. petTool.Name .. " ด้วยวิธี " .. result)
|
|
return true
|
|
end
|
|
end
|
|
|
|
return false
|
|
end
|
|
|
|
local function SmoothBuyEgg(eggType)
|
|
if not PetEggTypes[eggType] then return false end
|
|
|
|
print("🛒 กำลังซื้อไข่: " .. eggType)
|
|
|
|
if UltimateSettings.UseSmoothAnimations then
|
|
local Character = LocalPlayer.Character
|
|
if Character and Character:FindFirstChild("Humanoid") then
|
|
local Humanoid = Character:FindFirstChild("Humanoid")
|
|
Humanoid.WalkSpeed = 0
|
|
wait(UltimateSettings.AnimationDuration)
|
|
Humanoid.WalkSpeed = 16
|
|
end
|
|
end
|
|
|
|
local methods = {
|
|
function()
|
|
if PetEvents.BuyEgg then
|
|
PetEvents.BuyEgg:FireServer(eggType)
|
|
return "BuyEgg Event"
|
|
end
|
|
end,
|
|
function()
|
|
for eventName, event in pairs(PetEvents) do
|
|
if eventName:lower():find("buy") then
|
|
event:FireServer(eggType)
|
|
return eventName .. " Event"
|
|
end
|
|
end
|
|
end,
|
|
function()
|
|
local events = {"BuyEgg", "Buy", "Pet_Buy", "Egg_Buy"}
|
|
for _, eventName in pairs(events) do
|
|
local event = GameEvents:FindFirstChild(eventName)
|
|
if event then
|
|
event:FireServer(eggType)
|
|
return eventName .. " GameEvent"
|
|
end
|
|
end
|
|
end
|
|
}
|
|
|
|
for _, method in pairs(methods) do
|
|
local success, result = pcall(method)
|
|
if success and result then
|
|
print("✅ ซื้อไข่สำเร็จ: " .. eggType .. " ด้วยวิธี " .. result)
|
|
return true
|
|
end
|
|
end
|
|
|
|
return false
|
|
end
|
|
|
|
-- Main Loops
|
|
local function UltraFastHarvestLoop()
|
|
if not UltimateSettings.AutoHarvest or IsSelling or IsProcessingPets then return end
|
|
|
|
local currentCount = GetTotalInventoryCount()
|
|
if currentCount >= UltimateSettings.MaxInventorySlots then
|
|
if ShouldSell() then
|
|
SellInventory()
|
|
end
|
|
return
|
|
end
|
|
|
|
local Plants = GetHarvestablePlants()
|
|
if #Plants == 0 then return end
|
|
|
|
local availableSlots = UltimateSettings.MaxInventorySlots - currentCount
|
|
local maxHarvest = math.min(#Plants, availableSlots, UltimateSettings.MaxHarvestPerSecond)
|
|
|
|
if UltimateSettings.ParallelHarvest and UltimateSettings.UseThreading then
|
|
local threads = {}
|
|
local batchSize = math.ceil(maxHarvest / UltimateSettings.MaxThreads)
|
|
|
|
for i = 1, UltimateSettings.MaxThreads do
|
|
local startIndex = (i - 1) * batchSize + 1
|
|
local endIndex = math.min(i * batchSize, maxHarvest)
|
|
|
|
if startIndex <= endIndex then
|
|
local thread = spawn(function()
|
|
return BatchHarvestPlants(Plants, startIndex, endIndex)
|
|
end)
|
|
table.insert(threads, thread)
|
|
end
|
|
end
|
|
|
|
local totalHarvested = 0
|
|
for _, thread in pairs(threads) do
|
|
totalHarvested = totalHarvested + (thread or 0)
|
|
end
|
|
|
|
if totalHarvested > 0 then
|
|
print("⚡ Ultra Fast Harvest: " .. totalHarvested .. " ต้น")
|
|
end
|
|
|
|
else
|
|
local harvested = 0
|
|
for i = 1, maxHarvest do
|
|
if HarvestPlant(Plants[i]) then
|
|
harvested = harvested + 1
|
|
end
|
|
wait(UltimateSettings.HarvestDelay)
|
|
end
|
|
|
|
if harvested > 0 then
|
|
print("⚡ Ultra Fast Harvest: " .. harvested .. " ต้น")
|
|
end
|
|
end
|
|
end
|
|
|
|
local function UltraFastSellLoop()
|
|
if not UltimateSettings.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
|
|
|
|
local function SmoothHatchEggLoop()
|
|
if not UltimateSettings.AutoHatchEgg or IsProcessingPets then return end
|
|
|
|
local currentTime = tick()
|
|
if (currentTime - LastHatchTime) < UltimateSettings.HatchInterval then return end
|
|
|
|
local eggs = GetAvailableEggs()
|
|
if #eggs == 0 then return end
|
|
|
|
print("🥚 พบไข่ทั้งหมด " .. #eggs .. " ฟอง")
|
|
|
|
IsProcessingPets = true
|
|
local hatchedCount = 0
|
|
|
|
for _, eggData in pairs(eggs) do
|
|
if hatchedCount >= UltimateSettings.MaxPetsToHatch then break end
|
|
if not UltimateSettings.AutoHatchEgg then break end
|
|
|
|
if SmoothHatchEgg(eggData) then
|
|
hatchedCount = hatchedCount + 1
|
|
wait(2)
|
|
end
|
|
wait(0.5)
|
|
end
|
|
|
|
if hatchedCount > 0 then
|
|
print("✅ ฟักไข่สำเร็จทั้งหมด " .. hatchedCount .. " ฟอง")
|
|
end
|
|
|
|
LastHatchTime = currentTime
|
|
IsProcessingPets = false
|
|
end
|
|
|
|
local function SmoothFeedPetsLoop()
|
|
if not UltimateSettings.AutoFeedPets or IsProcessingPets then return end
|
|
|
|
local currentTime = tick()
|
|
if (currentTime - LastFeedTime) < UltimateSettings.FeedInterval then return end
|
|
|
|
local pets = GetAllPets()
|
|
if #pets == 0 then return end
|
|
|
|
print("🐾 พบสัตว์เลี้ยงทั้งหมด " .. #pets .. " ตัว")
|
|
|
|
IsProcessingPets = true
|
|
local fedCount = 0
|
|
|
|
for _, petData in pairs(pets) do
|
|
if not UltimateSettings.AutoFeedPets then break end
|
|
|
|
if SmoothFeedPet(petData) then
|
|
fedCount = fedCount + 1
|
|
wait(1)
|
|
end
|
|
wait(0.3)
|
|
end
|
|
|
|
if fedCount > 0 then
|
|
print("✅ ให้อาหารสำเร็จทั้งหมด " .. fedCount .. " ตัว")
|
|
end
|
|
|
|
LastFeedTime = currentTime
|
|
IsProcessingPets = false
|
|
end
|
|
|
|
local function SmoothBuyEggsLoop()
|
|
if not UltimateSettings.AutoBuyEggs or IsProcessingPets then return end
|
|
|
|
local currentTime = tick()
|
|
if (currentTime - LastBuyTime) < UltimateSettings.BuyInterval then return end
|
|
|
|
local eggs = GetAvailableEggs()
|
|
if #eggs >= UltimateSettings.MaxPetsToHatch then return end
|
|
|
|
local eggType = UltimateSettings.SelectedEggType
|
|
local eggInfo = PetEggTypes[eggType]
|
|
|
|
if eggInfo then
|
|
print("🔄 กำลังซื้อไข่: " .. eggType .. " (ราคา: " .. eggInfo.Price .. ")")
|
|
if SmoothBuyEgg(eggType) then
|
|
print("✅ ซื้อไข่สำเร็จ: " .. eggType)
|
|
else
|
|
print("❌ ซื้อไข่ไม่สำเร็จ: " .. eggType)
|
|
end
|
|
else
|
|
print("⚠️ ไม่พบข้อมูลไข่: " .. eggType)
|
|
end
|
|
|
|
LastBuyTime = currentTime
|
|
end
|
|
|
|
-- Start All Loops
|
|
local function StartUltimateOptimizedLoops()
|
|
print("🚀 Starting Ultimate Optimized Loops...")
|
|
|
|
-- Ultra Fast Harvest Loop
|
|
spawn(function()
|
|
while _G.UltimateOptimizedSystemLoaded do
|
|
local success, err = pcall(UltraFastHarvestLoop)
|
|
if not success then
|
|
print("⚠️ Harvest error: " .. tostring(err))
|
|
end
|
|
wait(0.05)
|
|
end
|
|
end)
|
|
|
|
-- Ultra Fast Sell Loop
|
|
spawn(function()
|
|
while _G.UltimateOptimizedSystemLoaded do
|
|
local success, err = pcall(UltraFastSellLoop)
|
|
if not success then
|
|
print("⚠️ Sell error: " .. tostring(err))
|
|
end
|
|
wait(0.5)
|
|
end
|
|
end)
|
|
|
|
-- Smooth Hatch Egg Loop
|
|
spawn(function()
|
|
while _G.UltimateOptimizedSystemLoaded do
|
|
local success, err = pcall(SmoothHatchEggLoop)
|
|
if not success then
|
|
print("⚠️ Hatch error: " .. tostring(err))
|
|
end
|
|
wait(UltimateSettings.HatchInterval)
|
|
end
|
|
end)
|
|
|
|
-- Smooth Feed Pets Loop
|
|
spawn(function()
|
|
while _G.UltimateOptimizedSystemLoaded do
|
|
local success, err = pcall(SmoothFeedPetsLoop)
|
|
if not success then
|
|
print("⚠️ Feed error: " .. tostring(err))
|
|
end
|
|
wait(UltimateSettings.FeedInterval)
|
|
end
|
|
end)
|
|
|
|
-- Smooth Buy Eggs Loop
|
|
spawn(function()
|
|
while _G.UltimateOptimizedSystemLoaded do
|
|
local success, err = pcall(SmoothBuyEggsLoop)
|
|
if not success then
|
|
print("⚠️ Buy error: " .. tostring(err))
|
|
end
|
|
wait(UltimateSettings.BuyInterval)
|
|
end
|
|
end)
|
|
|
|
print("✅ All Ultimate Optimized Loops started")
|
|
end
|
|
|
|
-- Simple UI
|
|
local function CreateUltimateOptimizedUI()
|
|
print("🎨 Creating Ultimate Optimized UI...")
|
|
|
|
local oldUI = PlayerGui:FindFirstChild("UltimateOptimizedSystemUI")
|
|
if oldUI then oldUI:Destroy() end
|
|
|
|
local ScreenGui = Instance.new("ScreenGui")
|
|
ScreenGui.Name = "UltimateOptimizedSystemUI"
|
|
ScreenGui.Parent = PlayerGui
|
|
ScreenGui.ResetOnSpawn = false
|
|
|
|
_G.UltimateOptimizedSystemUI = ScreenGui
|
|
|
|
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, 50, 0, 50)
|
|
MainFrame.Size = UDim2.new(0, 350, 0, 400)
|
|
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(255, 100, 100)
|
|
Stroke.Thickness = 2
|
|
|
|
-- Title
|
|
local Title = Instance.new("TextLabel")
|
|
Title.Parent = MainFrame
|
|
Title.BackgroundColor3 = Color3.fromRGB(255, 100, 100)
|
|
Title.BorderSizePixel = 0
|
|
Title.Size = UDim2.new(1, 0, 0, 40)
|
|
Title.Font = Enum.Font.SourceSansBold
|
|
Title.Text = "🚀 Ultimate Optimized System"
|
|
Title.TextColor3 = Color3.fromRGB(255, 255, 255)
|
|
Title.TextSize = 16
|
|
|
|
local TitleCorner = Instance.new("UICorner")
|
|
TitleCorner.CornerRadius = UDim.new(0, 12)
|
|
TitleCorner.Parent = Title
|
|
|
|
-- Content
|
|
local ContentFrame = Instance.new("ScrollingFrame")
|
|
ContentFrame.Parent = MainFrame
|
|
ContentFrame.BackgroundTransparency = 1
|
|
ContentFrame.Position = UDim2.new(0, 10, 0, 50)
|
|
ContentFrame.Size = UDim2.new(1, -20, 1, -60)
|
|
ContentFrame.CanvasSize = UDim2.new(0, 0, 0, 500)
|
|
ContentFrame.ScrollBarThickness = 8
|
|
|
|
-- Toggle Functions
|
|
local function CreateToggle(text, yPos, callback, defaultState)
|
|
local ToggleFrame = Instance.new("Frame")
|
|
ToggleFrame.Parent = ContentFrame
|
|
ToggleFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 40)
|
|
ToggleFrame.BorderSizePixel = 0
|
|
ToggleFrame.Position = UDim2.new(0, 0, 0, yPos)
|
|
ToggleFrame.Size = UDim2.new(1, 0, 0, 30)
|
|
|
|
local FrameCorner = Instance.new("UICorner")
|
|
FrameCorner.CornerRadius = UDim.new(0, 6)
|
|
FrameCorner.Parent = ToggleFrame
|
|
|
|
local Label = Instance.new("TextLabel")
|
|
Label.Parent = ToggleFrame
|
|
Label.BackgroundTransparency = 1
|
|
Label.Position = UDim2.new(0, 10, 0, 0)
|
|
Label.Size = UDim2.new(1, -70, 1, 0)
|
|
Label.Font = Enum.Font.SourceSans
|
|
Label.Text = text
|
|
Label.TextColor3 = Color3.fromRGB(255, 255, 255)
|
|
Label.TextSize = 12
|
|
Label.TextXAlignment = Enum.TextXAlignment.Left
|
|
|
|
local Toggle = Instance.new("TextButton")
|
|
Toggle.Parent = ToggleFrame
|
|
Toggle.BackgroundColor3 = defaultState and Color3.fromRGB(50, 200, 100) or Color3.fromRGB(200, 100, 100)
|
|
Toggle.BorderSizePixel = 0
|
|
Toggle.Position = UDim2.new(1, -60, 0, 5)
|
|
Toggle.Size = UDim2.new(0, 55, 0, 20)
|
|
Toggle.Font = Enum.Font.SourceSansBold
|
|
Toggle.Text = defaultState and "เปิด" or "ปิด"
|
|
Toggle.TextColor3 = Color3.fromRGB(255, 255, 255)
|
|
Toggle.TextSize = 10
|
|
|
|
local ToggleCorner = Instance.new("UICorner")
|
|
ToggleCorner.CornerRadius = UDim.new(0, 4)
|
|
ToggleCorner.Parent = Toggle
|
|
|
|
local isOn = defaultState or false
|
|
Toggle.MouseButton1Click:Connect(function()
|
|
isOn = not isOn
|
|
Toggle.Text = isOn and "เปิด" or "ปิด"
|
|
local targetColor = isOn and Color3.fromRGB(50, 200, 100) or Color3.fromRGB(200, 100, 100)
|
|
|
|
TweenService:Create(Toggle, TweenInfo.new(0.3), {
|
|
BackgroundColor3 = targetColor
|
|
}):Play()
|
|
|
|
if callback then callback(isOn) end
|
|
end)
|
|
|
|
return Toggle
|
|
end
|
|
|
|
-- Create Toggles
|
|
CreateToggle("⚡ Ultra Fast Harvest", 10, function(state) UltimateSettings.AutoHarvest = state end, UltimateSettings.AutoHarvest)
|
|
CreateToggle("💰 Ultra Fast Sell", 50, function(state) UltimateSettings.AutoSell = state end, UltimateSettings.AutoSell)
|
|
CreateToggle("🥚 Smooth Hatch", 90, function(state) UltimateSettings.AutoHatchEgg = state end, UltimateSettings.AutoHatchEgg)
|
|
CreateToggle("🍼 Smooth Feed", 130, function(state) UltimateSettings.AutoFeedPets = state end, UltimateSettings.AutoFeedPets)
|
|
CreateToggle("🛒 Smooth Buy", 170, function(state) UltimateSettings.AutoBuyEggs = state end, UltimateSettings.AutoBuyEggs)
|
|
CreateToggle("🔄 Parallel Harvest", 210, function(state) UltimateSettings.ParallelHarvest = state end, UltimateSettings.ParallelHarvest)
|
|
CreateToggle("📦 Batch Harvest", 250, function(state) UltimateSettings.BatchHarvest = state end, UltimateSettings.BatchHarvest)
|
|
CreateToggle("🎭 Smooth Animations", 290, function(state) UltimateSettings.UseSmoothAnimations = state end, UltimateSettings.UseSmoothAnimations)
|
|
|
|
print("✅ Ultimate Optimized UI created")
|
|
end
|
|
|
|
-- Initialize
|
|
print("🚀 Initializing Ultimate Optimized System...")
|
|
|
|
wait(1)
|
|
|
|
CreateUltimateOptimizedUI()
|
|
StartUltimateOptimizedLoops()
|
|
|
|
game:GetService("StarterGui"):SetCore("SendNotification", {
|
|
Title = "🚀 Ultimate Optimized System",
|
|
Text = "ระบบรวมที่ปรับปรุงแล้วพร้อมใช้งาน!",
|
|
Duration = 3
|
|
})
|
|
|
|
print("🚀 " .. string.rep("=", 50))
|
|
print("✅ Ultimate Optimized System พร้อมใช้งาน!")
|
|
print("⚡ การปรับปรุง:")
|
|
print(" - เก็บของเร็วขึ้น (Ultra Fast Harvest)")
|
|
print(" - ขายของเร็วขึ้น (Ultra Fast Sell)")
|
|
print(" - เลี้ยงสัตว์ Smooth ขึ้น (Smooth Pet System)")
|
|
print(" - ระบบ Threading สำหรับประสิทธิภาพสูงสุด")
|
|
print(" - Smart Inventory Management")
|
|
print(" - Parallel Processing")
|
|
print("🚀 " .. string.rep("=", 50))
|
|
|
|
return {
|
|
Settings = UltimateSettings,
|
|
UI = _G.UltimateOptimizedSystemUI,
|
|
MyFarm = MyFarm
|
|
} |