Roblox-Bot-Lua/Main/GaG/UltimateGaGFarm_Simple.lua
2025-07-21 10:41:54 +07:00

2214 lines
83 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Ultimate GaG Auto Farm - Simple Version with Auto Walk
-- UI แบบง่าย ไม่ต้อง collapse + เดินแบบ random เหมือนคน
print("🌱 Loading Ultimate GaG Auto Farm (Simple)...")
-- 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")
print("✅ Services loaded")
-- ป้องกันการรันซ้ำ
if _G.UltimateGaGFarmLoaded then
print("⚠️ Ultimate GaG Farm already loaded, removing old one...")
if _G.UltimateGaGFarmUI then
_G.UltimateGaGFarmUI:Destroy()
end
end
_G.UltimateGaGFarmLoaded = true
-- Game Objects
local GameEvents = ReplicatedStorage:WaitForChild("GameEvents")
local Farms = workspace:WaitForChild("Farm")
print("✅ Game objects found")
-- Pet System Data (from PetEggs.lua and PetList.lua)
local PetEggTypes = {
["Common Egg"] = { HatchTime = 600, Price = 100 },
["Uncommon Egg"] = { HatchTime = 1200, Price = 500 },
["Rare Egg"] = { HatchTime = 7200, Price = 2500 },
["Legendary Egg"] = { HatchTime = 14400, Price = 10000 },
["Mythical Egg"] = { HatchTime = 18400, Price = 50000 },
["Bug Egg"] = { HatchTime = 28800, Price = 25000 },
["Night Egg"] = { HatchTime = 15000, Price = 15000 },
["Bee Egg"] = { HatchTime = 14400, Price = 20000 },
["Anti Bee Egg"] = { HatchTime = 15000, Price = 30000 },
["Common Summer Egg"] = { HatchTime = 1200, Price = 800 },
["Rare Summer Egg"] = { HatchTime = 14400, Price = 8000 },
["Paradise Egg"] = { HatchTime = 24000, Price = 50000 },
["Oasis Egg"] = { HatchTime = 15000, Price = 25000 }
}
local PetMutations = {
["Golden"] = { Boost = 0.1, Rarity = "Rare" },
["Rainbow"] = { Boost = 0.2, Rarity = "Epic" },
["Shiny"] = { Boost = 0.3, Rarity = "Legendary" },
["Mega"] = { SizeMultiplier = 2, Rarity = "Special" },
["Tiny"] = { SizeMultiplier = -0.9, Rarity = "Special" }
}
-- Pet RemoteEvents (คาดการณ์จากโครงสร้างเกม)
local PetEvents = {}
-- ฟังก์ชันค้นหา Pet RemoteEvents และ Debug ข้อมูล
local function FindPetEvents()
print("🔍 ค้นหา Pet RemoteEvents...")
-- ค้นหาใน ReplicatedStorage ทั้งหมด
for _, obj in pairs(ReplicatedStorage:GetDescendants()) do
if obj:IsA("RemoteEvent") or obj:IsA("RemoteFunction") then
local name = obj.Name:lower()
-- ค้นหา RemoteEvents ที่เกี่ยวข้องกับ Pet
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 .. " (" .. obj.ClassName .. ") - " .. obj:GetFullName())
end
end
end
-- ลิสต์ RemoteEvents ทั้งหมดใน GameEvents สำหรับ Debug
print("\n📋 GameEvents ทั้งหมด:")
for _, obj in pairs(GameEvents:GetChildren()) do
if obj:IsA("RemoteEvent") or obj:IsA("RemoteFunction") then
print(" " .. obj.ClassName .. ": " .. obj.Name)
end
end
-- ถ้าไม่พบ Pet Events เฉพาะ ให้ใช้ GameEvents
if next(PetEvents) == nil then
print("⚠️ ไม่พบ Pet Events เฉพาะ จะใช้ GameEvents แทน")
-- ลองค้นหา events ที่อาจเกี่ยวข้อง
local possibleEvents = {
"HatchEgg", "FeedPet", "BuyEgg", "EquipPet", "UnequipPet", "SellPet",
"Hatch", "Feed", "Buy", "Equip", "Unequip", "Sell",
"Pet_Hatch", "Pet_Feed", "Pet_Buy", "Pet_Equip",
"Animal_Hatch", "Animal_Feed", "Egg_Hatch", "Egg_Buy"
}
for _, eventName in pairs(possibleEvents) do
local event = GameEvents:FindFirstChild(eventName)
if event then
PetEvents[eventName] = event
print("🐾 พบ GameEvent: " .. eventName)
end
end
end
print("\n🎯 Pet Events ที่จะใช้งาน:")
for name, event in pairs(PetEvents) do
print(" " .. name .. " -> " .. event.ClassName)
end
end
-- เรียกใช้หา Pet Events
FindPetEvents()
-- ระบบ Debug Commands สำหรับทดสอบระบบ Pet
_G.UltimateGaGFarmDebug = {
-- ตรวจสอบสัตว์เลี้ยง
CheckPets = function()
local pets = GetAllPets()
print("🐾 === สัตว์เลี้ยงที่พบ ===`")
print("📊 จำนวนทั้งหมด: " .. #pets .. " ตัว")
for i, pet in ipairs(pets) do
print(string.format(" %d. %s (%s) - %s [%s]", i, pet.Name, pet.Location, pet.Indicator, pet.Tool.ClassName))
end
return pets
end,
-- ตรวจสอบไข่
CheckEggs = function()
local eggs = GetAvailableEggs()
print("🥚 === ไข่ที่พบ ===`")
print("📊 จำนวนทั้งหมด: " .. #eggs .. " ฟอง")
for i, egg in ipairs(eggs) do
print(string.format(" %d. %s - %s [%s]", i, egg.Name, egg.Indicator, egg.Tool.ClassName))
end
return eggs
end,
-- ทดสอบฟักไข่
TestHatch = function(eggName)
local eggs = GetAvailableEggs()
local targetEgg = nil
for _, egg in ipairs(eggs) do
if not eggName or egg.Name:find(eggName) then
targetEgg = egg
break
end
end
if not targetEgg then
print("⚠️ ไม่พบไข่: " .. (eggName or "ไม่ระบุ"))
return false
end
print("🥚 ทดสอบฟักไข่: " .. targetEgg.Name)
return HatchEgg(targetEgg)
end,
-- ทดสอบให้อาหาร
TestFeed = function(petName)
local pets = GetAllPets()
local targetPet = nil
for _, pet in ipairs(pets) do
if not petName or pet.Name:find(petName) then
targetPet = pet
break
end
end
if not targetPet then
print("⚠️ ไม่พบสัตว์เลี้ยง: " .. (petName or "ไม่ระบุ"))
return false
end
print("🍼 ทดสอบให้อาหาร: " .. targetPet.Name)
return FeedPet(targetPet.Tool)
end,
-- ทดสอบซื้อไข่
TestBuy = function(eggType)
eggType = eggType or "Common Egg"
print("🛒 ทดสอบซื้อไข่: " .. eggType)
return BuyEgg(eggType)
end,
-- แสดง RemoteEvents ทั้งหมด
ShowEvents = function()
print("📡 === Pet RemoteEvents ที่พบ ===`")
local count = 0
for name, event in pairs(PetEvents) do
count = count + 1
print(string.format(" %d. %s (%s) - %s", count, name, event.ClassName, event:GetFullName()))
end
if count == 0 then
print("⚠️ ไม่พบ Pet Events")
end
print("📡 === สำคัญ Farm RemoteEvents ===`")
local farmEvents = {"Plant_RE", "Sell_Inventory", "BuySeedStock"}
for _, eventName in ipairs(farmEvents) do
local event = GameEvents:FindFirstChild(eventName)
if event then
print("" .. eventName .. " (" .. event.ClassName .. ")")
else
print("" .. eventName .. " - ไม่พบ")
end
end
return PetEvents
end,
-- สถานะระบบทั้งหมด
Status = function()
print("📊 === สถานะระบบ Ultimate GaG Farm ===`")
local pets = GetAllPets()
local eggs = GetAvailableEggs()
local ownedSeeds = GetOwnedSeeds()
local crops = GetInvCrops()
local plants = GetHarvestablePlants()
print("🌱 ระบบฟาร์ม:")
print(" เมล็ด: " .. (ownedSeeds[Settings.SelectedSeed] and ownedSeeds[Settings.SelectedSeed].Count or 0))
print(" ผลผลิต: " .. #crops)
print(" พืชเก็บได้: " .. #plants)
print("🐾 ระบบเลี้ยงสัตว์:")
print(" สัตว์เลี้ยง: " .. #pets .. " ตัว")
print(" ไข่: " .. #eggs .. " ฟอง")
print(" Pet Events: " .. (function() local c=0; for _ in pairs(PetEvents) do c=c+1 end return c end)())
print("⚙️ การตั้งค่า:")
print(" Auto Plant: " .. (Settings.AutoPlant and "เปิด" or "ปิด"))
print(" Auto Harvest: " .. (Settings.AutoHarvest and "เปิด" or "ปิด"))
print(" Auto Sell: " .. (Settings.AutoSell and "เปิด" or "ปิด"))
print(" Auto Walk: " .. (Settings.AutoWalk and "เปิด" or "ปิด"))
print(" Auto Hatch: " .. (Settings.AutoHatchEgg and "เปิด" or "ปิด"))
print(" Auto Feed: " .. (Settings.AutoFeedPets and "เปิด" or "ปิด"))
print(" Auto Buy Eggs: " .. (Settings.AutoBuyEggs and "เปิด" or "ปิด"))
end
}
-- แสดงข้อมูล Debug ตอนเริ่มต้น
print("🛠️ Debug Commands พร้อมใช้งาน! ใช้ _G.UltimateGaGFarmDebug.Status() เพื่อดูสถานะ")
-- แสดงสถานะเริ่มต้น
spawn(function()
wait(2) -- รอให้ระบบโหลดเสร็จ
_G.UltimateGaGFarmDebug.Status()
end)
-- Simple Settings
local Settings = {
-- Auto Farm Settings
AutoPlant = false,
AutoHarvest = false,
AutoSell = false,
AutoBuy = false,
AutoWalk = false,
-- Basic Settings
SelectedSeed = "Carrot",
HarvestAll = true,
HarvestSpeed = "Ultra Fast",
SellThreshold = 15,
PlantRandom = false,
-- Auto Sell Settings
AutoSellWhenFull = true,
MaxInventorySlots = 200, -- จำนวนช่องกระเป๋าสูงสุด (เพิ่มเป็น 30)
-- Walk Settings
WalkSpeed = "ปกติ", -- "ช้า", "ปกติ", "เร็ว"
WalkRandomness = true,
WalkRadius = 20,
-- Pet/Animal Settings
AutoHatchEgg = false,
AutoFeedPets = false,
AutoBuyEggs = false,
AutoEquipPets = false,
SelectedEggType = "Common Egg",
MaxPetsToHatch = 5,
FeedWhenHungry = true,
AutoSellBadPets = false,
-- Harvest Filtering Settings (การกรองการเก็บ)
HarvestNormalOnly = true, -- เก็บแค่ผลปกติและทอง
HarvestGolden = true, -- เก็บผลทอง
HarvestSpecial = false, -- เก็บผลพิเศษ (มีแสง/พลัง)
-- Speed Optimization
HarvestDelay = 0.01, -- ดีเลย์ระหว่างการเก็บ
MaxHarvestPerLoop = 50 -- จำนวนสูงสุดต่อลูป
}
-- Find Player's Farm
local function GetFarmOwner(Farm)
local Important = Farm:FindFirstChild("Important")
if not Important then return nil end
local Data = Important:FindFirstChild("Data")
if not Data then return nil end
local Owner = Data:FindFirstChild("Owner")
if not Owner then return nil end
return Owner.Value
end
local function GetFarm(PlayerName)
local AllFarms = Farms:GetChildren()
for _, Farm in pairs(AllFarms) do
local Owner = GetFarmOwner(Farm)
if Owner == PlayerName then
return Farm
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 GaG Farm",
Text = "ไม่พบฟาร์มของคุณ!",
Duration = 5
})
return
end
print("✅ Found player farm: " .. MyFarm.Name)
-- หา Pet และ Egg ในฟาร์ม
local PetArea = MyFarm:FindFirstChild("Pets") or MyFarm:FindFirstChild("Animals")
local EggArea = MyFarm:FindFirstChild("Eggs") or MyFarm:FindFirstChild("PetEggs")
if PetArea then
print("🐾 พบ Pet Area: " .. PetArea.Name)
else
print("⚠️ ไม่พบ Pet Area ในฟาร์ม")
end
if EggArea then
print("🥚 พบ Egg Area: " .. EggArea.Name)
else
print("⚠️ ไม่พบ Egg Area ในฟาร์ม")
end
local MyImportant = MyFarm:FindFirstChild("Important")
local PlantLocations = MyImportant:FindFirstChild("Plant_Locations")
local PlantsPhysical = MyImportant:FindFirstChild("Plants_Physical")
-- Helper Functions
local function GetArea(Base)
local Center = Base:GetPivot()
local Size = Base.Size
local X1 = math.ceil(Center.X - (Size.X/2))
local Z1 = math.ceil(Center.Z - (Size.Z/2))
local X2 = math.floor(Center.X + (Size.X/2))
local Z2 = math.floor(Center.Z + (Size.Z/2))
return X1, Z1, X2, Z2
end
local Dirt = PlantLocations:FindFirstChildOfClass("Part")
local X1, Z1, X2, Z2 = GetArea(Dirt)
local FarmCenter = Vector3.new((X1 + X2) / 2, 4, (Z1 + Z2) / 2)
-- Get Harvestable Plants (ปรับปรุงด้วยการกรองและความเร็ว)
local function GetHarvestablePlants()
local Plants = {}
-- ฟังก์ชันตรวจสอบว่าควรเก็บหรือไม่
local function ShouldHarvestPlant(Plant)
-- ตรวจสอบว่ามีแสง/พลังพิเศษหรือไม่
local plantName = Plant.Name:lower()
-- ตรวจสอบผลที่มีแสง/พลังพิเศษ (จาก PetMutations)
local specialEffects = {
"shocked", "moonlit", "twisted", "burnt", "frozen", "wet",
"bloodlit", "zombified", "celestial", "disco", "plasma",
"voidtouched", "honeyglazed", "pollinated", "chilled",
"radiant", "aurora", "crystal", "shadow", "ethereal",
"cursed", "blessed", "elemental", "mystical", "enchanted"
}
-- ตรวจสอบจากชื่อ
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")
-- ตรวจสอบจากสีของ Model
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
-- ตรวจสอบแสงพิเศษ (สีสวยหรือมี PointLight)
if primaryPart:FindFirstChild("PointLight") or
primaryPart:FindFirstChild("SpotLight") or
primaryPart:FindFirstChild("SurfaceLight") then
hasSpecialEffect = true
end
end
-- ตัดสินใจตามการตั้งค่า
if hasSpecialEffect and not Settings.HarvestSpecial then
return false -- ไม่เก็บผลพิเศษ
end
if isGolden and not Settings.HarvestGolden then
return false -- ไม่เก็บผลทอง
end
if not isGolden and not hasSpecialEffect and not Settings.HarvestNormalOnly then
return false -- ไม่เก็บผลปกติ
end
return true
end
local function CollectHarvestable(Parent)
for _, Plant in pairs(Parent:GetChildren()) do
-- กระจายความเร็ว - หยุดถ้าเก็บครบแล้ว
if #Plants >= Settings.MaxHarvestPerLoop 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)
-- เก็บจากฟาร์มอื่นๆ (ถ้าเปิด)
if Settings.HarvestAll and #Plants < Settings.MaxHarvestPerLoop then
local farmsToCheck = {}
for _, Farm in pairs(Farms:GetChildren()) do
if Farm ~= MyFarm then
table.insert(farmsToCheck, Farm)
end
end
-- เก็บจากฟาร์มอื่นแบบ parallel แต่ไม่รอนาน
for _, Farm in pairs(farmsToCheck) do
if #Plants >= Settings.MaxHarvestPerLoop then break end
local OtherPlantsPhysical = Farm:FindFirstChild("Important")
if OtherPlantsPhysical then
OtherPlantsPhysical = OtherPlantsPhysical:FindFirstChild("Plants_Physical")
if OtherPlantsPhysical then
CollectHarvestable(OtherPlantsPhysical)
end
end
end
end
return Plants
end
-- Auto Walk System (เดินแบบ random เหมือนคน)
local function GetRandomWalkPoint()
local Character = LocalPlayer.Character
if not Character then return nil end
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if not HumanoidRootPart then return nil end
local currentPos = HumanoidRootPart.Position
-- สุ่มจุดในรัศมีรอบฟาร์ม
local angle = math.random() * math.pi * 2
local distance = math.random(5, Settings.WalkRadius)
local newX = FarmCenter.X + math.cos(angle) * distance
local newZ = FarmCenter.Z + math.sin(angle) * distance
-- จำกัดให้อยู่ในฟาร์ม
newX = math.max(X1, math.min(X2, newX))
newZ = math.max(Z1, math.min(Z2, newZ))
return Vector3.new(newX, 4, newZ)
end
local function AutoWalkLoop()
if not Settings.AutoWalk then return end
local Character = LocalPlayer.Character
if not Character then
print("⚠️ ไม่พบ Character")
return
end
local Humanoid = Character:FindFirstChild("Humanoid")
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if not Humanoid or not HumanoidRootPart then
print("⚠️ ไม่พบ Humanoid หรือ HumanoidRootPart")
return
end
-- หาพืชที่เก็บได้ใกล้ๆ ก่อน
local Plants = GetHarvestablePlants()
local targetPos = nil
if #Plants > 0 and Settings.AutoHarvest then
-- เดินไปที่พืชที่ใกล้ที่สุด
local currentPos = HumanoidRootPart.Position
local closestDist = math.huge
for _, Plant in pairs(Plants) do
if Plant and Plant.Parent then
local plantPos = Plant:GetPivot().Position
local dist = (currentPos - plantPos).Magnitude
if dist < closestDist and dist < 50 then
closestDist = dist
targetPos = plantPos
end
end
end
end
-- ถ้าไม่มีพืชให้เก็บ หรือ randomness เดินแบบสุ่ม
if not targetPos or (Settings.WalkRandomness and math.random(1, 3) == 1) then
targetPos = GetRandomWalkPoint()
end
if targetPos then
print("🚶 เดินไปที่: " .. string.format("%.1f, %.1f, %.1f", targetPos.X, targetPos.Y, targetPos.Z))
-- เดินไปแบบ safe
pcall(function()
Humanoid:MoveTo(targetPos)
end)
-- รอให้เดินถึงหรือใกล้เป้าหมาย (แบบ non-blocking)
spawn(function()
local timeout = 0
while timeout < 30 and _G.UltimateGaGFarmLoaded and Settings.AutoWalk do
if not HumanoidRootPart.Parent then break end
local currentPos = HumanoidRootPart.Position
local distance = (currentPos - targetPos).Magnitude
if distance < 8 then
print("✅ เดินถึงจุดหมาย")
break
end
timeout = timeout + 1
wait(0.3)
end
end)
else
print("⚠️ ไม่สามารถหาจุดเดินได้")
end
end
-- Plant Function
local function Plant(Position, Seed)
local PlantEvent = GameEvents:FindFirstChild("Plant_RE")
if PlantEvent then
PlantEvent:FireServer(Position, Seed)
wait(0.3)
return true
end
return false
end
-- Get Owned Seeds
local function GetOwnedSeeds()
local Seeds = {}
local Character = LocalPlayer.Character
local function CollectFromParent(Parent)
for _, Tool in pairs(Parent:GetChildren()) do
if Tool:IsA("Tool") then
local PlantName = Tool:FindFirstChild("Plant_Name")
local Count = Tool:FindFirstChild("Numbers")
if PlantName and Count then
Seeds[PlantName.Value] = {
Count = Count.Value,
Tool = Tool
}
end
end
end
end
CollectFromParent(Backpack)
if Character then
CollectFromParent(Character)
end
return Seeds
end
-- Harvest Plant Function
local function HarvestPlant(Plant)
local Prompt = Plant:FindFirstChild("ProximityPrompt", true)
if Prompt and Prompt.Enabled then
fireproximityprompt(Prompt)
return true
end
return false
end
-- Get Inventory Crops และนับจำนวนทั้งหมด
local function GetInvCrops()
local Crops = {}
local Character = LocalPlayer.Character
local function CollectFromParent(Parent)
for _, Tool in pairs(Parent:GetChildren()) do
if Tool:IsA("Tool") then
local ItemString = Tool:FindFirstChild("Item_String")
if ItemString then
table.insert(Crops, Tool)
end
end
end
end
CollectFromParent(Backpack)
if Character then
CollectFromParent(Character)
end
return Crops
end
-- นับจำนวน Tools ทั้งหมดในกระเป๋า (รวมเมล็ดและผลผลิต)
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 IsInventoryFull()
local currentCount = GetTotalInventoryCount()
return currentCount >= Settings.MaxInventorySlots
end
-- ตรวจสอบว่าควรขายหรือไม่ (เน้นกระเป๋าเต็มเป็นหลัก)
local function ShouldAutoSell()
local crops = GetInvCrops()
local cropCount = #crops
local totalItems = GetTotalInventoryCount()
-- ลำดับความสำคัญ: กระเป๋าเต็มก่อน
if Settings.AutoSellWhenFull and IsInventoryFull() then
return true, "กระเป๋าเต็ม (" .. totalItems .. "/" .. Settings.MaxInventorySlots .. ")"
end
-- ขายเมื่อใกล้เต็ม (เหลือแค่ 1-2 ช่อง) - เก็บให้มากกว่าเดิม
if Settings.AutoSellWhenFull and totalItems >= (Settings.MaxInventorySlots - 1) then
return true, "กระเป๋าใกล้เต็ม (" .. totalItems .. "/" .. Settings.MaxInventorySlots .. ")"
end
-- ขายเมื่อถึงเกณฑ์ที่ตั้งไว้ (แต่ไม่สำคัญเท่ากระเป๋าเต็ม)
if not Settings.AutoSellWhenFull and cropCount >= Settings.SellThreshold then
return true, "ถึงเกณฑ์ผลผลิต (" .. cropCount .. "/" .. Settings.SellThreshold .. ")"
end
return false, "ยังไม่ถึงเวลา (" .. totalItems .. "/" .. Settings.MaxInventorySlots .. ")"
end
-- Sell Inventory Function
local IsSelling = false
local function SellInventory()
if IsSelling then return end
IsSelling = true
local Character = LocalPlayer.Character
if not Character then
IsSelling = false
return
end
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if not HumanoidRootPart then
IsSelling = false
return
end
local Previous = HumanoidRootPart.CFrame
local ShecklesCount = Leaderstats:FindFirstChild("Sheckles")
-- Teleport to sell area
HumanoidRootPart.CFrame = CFrame.new(62, 4, -26)
wait(0.5)
if ShecklesCount then
local PreviousSheckles = ShecklesCount.Value
-- Try to sell
local SellEvent = GameEvents:FindFirstChild("Sell_Inventory")
if SellEvent then
local attempts = 0
while attempts < 10 do
if ShecklesCount.Value ~= PreviousSheckles then break end
SellEvent:FireServer()
wait(0.2)
attempts = attempts + 1
end
print("💰 ขายได้เงิน " .. (ShecklesCount.Value - PreviousSheckles) .. " sheckles")
end
end
-- Return to previous position
HumanoidRootPart.CFrame = Previous
wait(0.2)
IsSelling = false
end
-- Pet Management Functions
-- หาสัตว์เลี้ยงทั้งหมด (ปรับปรุงการตรวจจับ)
local function GetAllPets()
local pets = {}
local Character = LocalPlayer.Character
-- ฟังก์ชันตรวจสอบว่าเป็น Pet Tool หรือไม่
local function isPetTool(tool)
if not tool:IsA("Tool") then return false end
-- ตรวจสอบ properties ที่อาจบ่งบอกว่าเป็น Pet
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",
"fox", "wolf", "bear", "deer", "monkey", "squirrel", "owl", "eagle",
"turtle", "frog", "snake", "lizard", "fish", "shark", "whale"
}
for _, petName in pairs(petNames) do
if name:find(petName) then
return true, "NameMatch"
end
end
return false
end
-- ค้นหาใน Backpack
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,
DataObject = tool:FindFirstChild(indicator)
})
end
end
-- ค้นหาใน Character
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,
DataObject = tool:FindFirstChild(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
-- ตรวจสอบ properties ที่อาจบ่งบอกว่าเป็น Egg
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
-- ตรวจสอบจาก PetEggTypes
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,
DataObject = tool:FindFirstChild(indicator)
})
end
end
end
CollectFromParent(Backpack)
if Character then
CollectFromParent(Character)
end
return eggs
end
-- ฟักไข่ (ปรับปรุงการส่ง parameters)
local function HatchEgg(eggData)
if not eggData or not eggData.Tool then
print("⚠️ ไม่มี Egg Tool")
return false
end
local eggTool = eggData.Tool
print("🔍 พยายามฟักไข่: " .. eggTool.Name .. " (" .. eggData.Indicator .. ")")
-- ลองหลายวิธีในการฟักไข่
local methods = {
-- วิธีที่ 1: ใช้ RemoteEvent ที่พบ
function()
if PetEvents.HatchEgg then
PetEvents.HatchEgg:FireServer(eggTool)
return "HatchEgg Event"
end
end,
-- วิธีที่ 2: ใช้ชื่อ Event อื่นๆ
function()
for eventName, event in pairs(PetEvents) do
if eventName:lower():find("hatch") then
event:FireServer(eggTool)
return eventName .. " Event"
end
end
end,
-- วิธีที่ 3: ลองใช้ parameter ต่างๆ
function()
if PetEvents.HatchEgg then
PetEvents.HatchEgg:FireServer(eggTool.Name)
return "HatchEgg with Name"
end
end,
-- วิธีที่ 4: ตรวจสอบ GameEvents
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,
-- วิธีที่ 5: ลองใช้ ProximityPrompt (ถ้ามี)
function()
local prompt = eggTool:FindFirstChild("ProximityPrompt", true)
if prompt then
fireproximityprompt(prompt)
return "ProximityPrompt"
end
end
}
-- ลองแต่ละวิธี
for i, method in ipairs(methods) do
local success, result = pcall(method)
if success and result then
print("✅ ฟักไข่สำเร็จ: " .. eggTool.Name .. " ด้วยวิธี " .. result)
return true
end
end
print("❌ ไม่สามารถฟักไข่ได้: " .. eggTool.Name)
return false
end
-- ให้อาหารสัตว์เลี้ยง (ปรับปรุงการส่ง parameters)
local function FeedPet(petData, foodType)
if not petData or not petData.Tool then
print("⚠️ ไม่มี Pet Tool")
return false
end
local petTool = petData.Tool
foodType = foodType or "Basic Food"
print("🔍 พยายามให้อาหาร: " .. petTool.Name .. " (" .. petData.Indicator .. ")")
-- ลองหลายวิธีในการให้อาหาร
local methods = {
-- วิธีที่ 1: ใช้ RemoteEvent ที่พบ
function()
if PetEvents.FeedPet then
PetEvents.FeedPet:FireServer(petTool, foodType)
return "FeedPet Event"
end
end,
-- วิธีที่ 2: ใช้ชื่อ Event อื่นๆ
function()
for eventName, event in pairs(PetEvents) do
if eventName:lower():find("feed") then
event:FireServer(petTool, foodType)
return eventName .. " Event"
end
end
end,
-- วิธีที่ 3: ลองใช้ parameter ต่างๆ
function()
if PetEvents.FeedPet then
PetEvents.FeedPet:FireServer(petTool)
return "FeedPet without food type"
end
end,
-- วิธีที่ 4: ตรวจสอบ GameEvents
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, foodType)
return eventName .. " GameEvent"
end
end
end,
-- วิธีที่ 5: ลองใช้ ProximityPrompt (ถ้ามี)
function()
local prompt = petTool:FindFirstChild("ProximityPrompt", true)
if prompt then
fireproximityprompt(prompt)
return "ProximityPrompt"
end
end
}
-- ลองแต่ละวิธี
for i, method in ipairs(methods) do
local success, result = pcall(method)
if success and result then
print("✅ ให้อาหารสำเร็จ: " .. petTool.Name .. " ด้วยวิธี " .. result)
return true
end
end
print("❌ ไม่สามารถให้อาหารได้: " .. petTool.Name)
return false
end
-- ซื้อไข่ (ปรับปรุงการส่ง parameters)
local function BuyEgg(eggType)
if not PetEggTypes[eggType] then
print("⚠️ ไม่มีไข่ประเภท: " .. eggType)
return false
end
print("🔍 พยายามซื้อไข่: " .. eggType)
-- ลองหลายวิธีในการซื้อไข่
local methods = {
-- วิธีที่ 1: ใช้ RemoteEvent ที่พบ
function()
if PetEvents.BuyEgg then
PetEvents.BuyEgg:FireServer(eggType)
return "BuyEgg Event"
end
end,
-- วิธีที่ 2: ใช้ชื่อ Event อื่นๆ
function()
for eventName, event in pairs(PetEvents) do
if eventName:lower():find("buy") then
event:FireServer(eggType)
return eventName .. " Event"
end
end
end,
-- วิธีที่ 3: ลองใช้ parameter ต่างๆ
function()
if PetEvents.BuyEgg then
local price = PetEggTypes[eggType].Price
PetEvents.BuyEgg:FireServer(eggType, price)
return "BuyEgg with price"
end
end,
-- วิธีที่ 4: ตรวจสอบ GameEvents
function()
local events = {"BuyEgg", "Buy", "Pet_Buy", "Egg_Buy", "Purchase", "Shop"}
for _, eventName in pairs(events) do
local event = GameEvents:FindFirstChild(eventName)
if event then
event:FireServer(eggType)
return eventName .. " GameEvent"
end
end
end,
-- วิธีที่ 5: ลองใช้ Shop หรือ NPC
function()
-- ค้นหา Shop หรือ NPC ในเกม
local shops = workspace:FindFirstChild("Shops") or workspace:FindFirstChild("Shop")
if shops then
for _, shop in pairs(shops:GetChildren()) do
local prompt = shop:FindFirstChild("ProximityPrompt", true)
if prompt then
fireproximityprompt(prompt)
return "Shop ProximityPrompt"
end
end
end
end
}
-- ลองแต่ละวิธี
for i, method in ipairs(methods) do
local success, result = pcall(method)
if success and result then
print("✅ ซื้อไข่สำเร็จ: " .. eggType .. " ด้วยวิธี " .. result)
return true
end
end
print("❌ ไม่สามารถซื้อไข่ได้: " .. eggType)
return false
end
-- Auto Pet Functions (ปรับปรุงการเรียกใช้)
local function AutoHatchEggLoop()
if not Settings.AutoHatchEgg then return end
local eggs = GetAvailableEggs()
if #eggs == 0 then
print("📝 ไม่มีไข่ให้ฟัก")
return
end
print("🥚 พบไข่ทั้งหมด " .. #eggs .. " ฟอง")
local hatchedCount = 0
for _, eggData in pairs(eggs) do
if hatchedCount >= Settings.MaxPetsToHatch then
print("⏹️ ถึงจำนวนสูงสุดแล้ว (" .. Settings.MaxPetsToHatch .. ")")
break
end
if not Settings.AutoHatchEgg then break end
print("🔄 กำลังฟักไข่: " .. eggData.Name)
if HatchEgg(eggData) then
hatchedCount = hatchedCount + 1
wait(2) -- เพิ่มเวลารอให้เซิร์ฟเวอร์ประมวลผล
else
print("❌ ฟักไข่ไม่สำเร็จ: " .. eggData.Name)
end
wait(0.5) -- รอระหว่างแต่ละครั้ง
end
if hatchedCount > 0 then
print("✅ ฟักไข่สำเร็จทั้งหมด " .. hatchedCount .. " ฟอง")
else
print("⚠️ ไม่สามารถฟักไข่ได้เลย")
end
end
local function AutoFeedPetsLoop()
if not Settings.AutoFeedPets then return end
local pets = GetAllPets()
if #pets == 0 then
print("📝 ไม่มีสัตว์เลี้ยงให้ให้อาหาร")
return
end
print("🐾 พบสัตว์เลี้ยงทั้งหมด " .. #pets .. " ตัว")
local fedCount = 0
for _, petData in pairs(pets) do
if not Settings.AutoFeedPets then break end
print("🔄 กำลังให้อาหาร: " .. petData.Name)
-- ตรวจสอบว่าสัตว์หิวหรือไม่ (อาจต้องดูจาก PetData)
if Settings.FeedWhenHungry then
if FeedPet(petData) then
fedCount = fedCount + 1
wait(1) -- เพิ่มเวลารอ
else
print("❌ ให้อาหารไม่สำเร็จ: " .. petData.Name)
end
end
wait(0.3) -- รอระหว่างแต่ละตัว
end
if fedCount > 0 then
print("✅ ให้อาหารสำเร็จทั้งหมด " .. fedCount .. " ตัว")
else
print("⚠️ ไม่สามารถให้อาหารได้เลย")
end
end
local function AutoBuyEggsLoop()
if not Settings.AutoBuyEggs then return end
local eggs = GetAvailableEggs()
if #eggs >= Settings.MaxPetsToHatch then
print("📝 มีไข่เพียงพอแล้ว (" .. #eggs .. "/" .. Settings.MaxPetsToHatch .. ")")
return
end
local eggType = Settings.SelectedEggType
local eggInfo = PetEggTypes[eggType]
if eggInfo then
print("🔄 กำลังซื้อไข่: " .. eggType .. " (ราคา: " .. eggInfo.Price .. ")")
if BuyEgg(eggType) then
print("✅ ซื้อไข่สำเร็จ: " .. eggType)
else
print("❌ ซื้อไข่ไม่สำเร็จ: " .. eggType)
end
else
print("⚠️ ไม่พบข้อมูลไข่: " .. eggType)
end
end
-- Auto Functions
local function AutoPlantLoop()
if not Settings.AutoPlant then return end
local OwnedSeeds = GetOwnedSeeds()
local SeedData = OwnedSeeds[Settings.SelectedSeed]
if not SeedData or SeedData.Count <= 0 then
return
end
local Count = SeedData.Count
local Tool = SeedData.Tool
-- Equip the tool
local Character = LocalPlayer.Character
if Character and Tool.Parent == Backpack then
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
Humanoid:EquipTool(Tool)
wait(0.5)
end
end
local Planted = 0
if Settings.PlantRandom then
-- Plant at random points
local FarmLands = PlantLocations:GetChildren()
for i = 1, math.min(Count, 20) do
if not Settings.AutoPlant then break end
local FarmLand = FarmLands[math.random(1, #FarmLands)]
local LX1, LZ1, LX2, LZ2 = GetArea(FarmLand)
local X = math.random(LX1, LX2)
local Z = math.random(LZ1, LZ2)
local Point = Vector3.new(X, 4, Z)
if Plant(Point, Settings.SelectedSeed) then
Planted = Planted + 1
end
end
else
-- Plant in grid pattern
for X = X1, X2, 2 do
for Z = Z1, Z2, 2 do
if Planted >= math.min(Count, 30) or not Settings.AutoPlant then break end
local Point = Vector3.new(X, 0.13, Z)
if Plant(Point, Settings.SelectedSeed) then
Planted = Planted + 1
wait(0.1)
end
end
if Planted >= math.min(Count, 30) or not Settings.AutoPlant then break end
end
end
if Planted > 0 then
print("🌱 ปลูก " .. Planted .. " เมล็ด " .. Settings.SelectedSeed)
end
end
local function AutoHarvestLoop()
if not Settings.AutoHarvest then return end
-- ตรวจสอบกระเป๋าก่อนเก็บ - เก็บจนเต็มจริงๆ
local currentCount = GetTotalInventoryCount()
if currentCount >= Settings.MaxInventorySlots then
print("⚠️ กระเป๋าเต็มจริงๆ! (" .. currentCount .. "/" .. Settings.MaxInventorySlots .. ") หยุดเก็บชั่วคราว")
return
end
local Plants = GetHarvestablePlants()
if #Plants == 0 then return end
local Harvested = 0
local availableSlots = Settings.MaxInventorySlots - currentCount
local maxHarvestPerLoop = math.min(#Plants, availableSlots, Settings.MaxHarvestPerLoop)
-- รายละเอียดผลที่จะเก็บ
local normalCount = 0
local goldenCount = 0
local specialCount = 0
for _, plant in pairs(Plants) do
local plantName = plant.Name:lower()
if plantName:find("golden") or plantName:find("gold") then
goldenCount = goldenCount + 1
elseif plantName:find("shocked") or plantName:find("moonlit") or plantName:find("celestial") then
specialCount = specialCount + 1
else
normalCount = normalCount + 1
end
end
print(string.format("🎒 กระเป๋า: %d/%d | ผล: ปกติ %d, ทอง %d, พิเศษ %d",
currentCount, Settings.MaxInventorySlots, normalCount, goldenCount, specialCount))
-- เก็บแบบ Ultra Fast (Parallel Processing)
if Settings.HarvestSpeed == "Ultra Fast" then
local harvestTasks = {}
-- เก็บแบบ Parallel โดยไม่รอ
for i = 1, maxHarvestPerLoop do
if not Settings.AutoHarvest then break end
local Plant = Plants[i]
if Plant then
spawn(function()
pcall(function()
if HarvestPlant(Plant) then
Harvested = Harvested + 1
end
end)
end)
end
end
-- รอเพียงเล็กน้อยเพื่อไม่ให้ค้าง
wait(Settings.HarvestDelay)
else
-- เก็บแบบ Sequential (ทีละต้น)
for i = 1, maxHarvestPerLoop do
if not Settings.AutoHarvest then break end
local Plant = Plants[i]
if Plant then
pcall(function()
if HarvestPlant(Plant) then
Harvested = Harvested + 1
end
end)
-- ดีเลย์ตามความเร็วที่ตั้งไว้
if Settings.HarvestSpeed == "Fast" then
wait(0.02)
else -- Normal
wait(0.05)
end
end
end
end
-- ปรับปรุงการรายงานผลลัพธ์
if Harvested > 0 then
local inventoryCount = GetTotalInventoryCount()
local inventoryPercent = math.floor((inventoryCount / Settings.MaxInventorySlots) * 100)
-- นับผลที่เก็บได้จริง
local harvestedNormal = 0
local harvestedGolden = 0
local harvestedSpecial = 0
local crops = GetInvCrops()
for _, crop in pairs(crops) do
local cropName = crop.Name:lower()
if cropName:find("golden") or cropName:find("gold") then
harvestedGolden = harvestedGolden + 1
elseif cropName:find("shocked") or cropName:find("celestial") or cropName:find("moonlit") then
harvestedSpecial = harvestedSpecial + 1
else
harvestedNormal = harvestedNormal + 1
end
end
print(string.format("🚜 เก็บ %d ต้น | กระเป๋า: %d/%d (%d%%) | ปกติ:%d ทอง:%d พิเศษ:%d",
Harvested, inventoryCount, Settings.MaxInventorySlots, inventoryPercent,
harvestedNormal, harvestedGolden, harvestedSpecial))
-- แจ้งเตือนเมื่อใกล้เต็ม
if inventoryCount >= (Settings.MaxInventorySlots - 5) then
print("⚠️ กระเป๋าใกล้เต็ม! เหลือ " .. (Settings.MaxInventorySlots - inventoryCount) .. " ช่อง")
end
-- แจ้งเตือนเมื่อเต็ม
if inventoryCount >= Settings.MaxInventorySlots then
print("🎒 กระเป๋าเต็มแล้ว! จะขายในรอบถัดไป")
end
end
end
local function AutoSellLoop()
if not Settings.AutoSell then return end
local shouldSell, reason = ShouldAutoSell()
if not shouldSell then return end
local Crops = GetInvCrops()
local totalItems = GetTotalInventoryCount()
print("💰 ขาย " .. #Crops .. " ผลผลิต (" .. reason .. ") - ทั้งหมด " .. totalItems .. " ชิ้น")
SellInventory()
end
-- Create Simple Scrollable UI
local function CreateSimpleUI()
print("🎨 Creating Simple Scrollable UI...")
-- Remove old UI
local oldUI = PlayerGui:FindFirstChild("UltimateGaGFarmUI")
if oldUI then oldUI:Destroy() end
-- ScreenGui
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "UltimateGaGFarmUI"
ScreenGui.Parent = PlayerGui
ScreenGui.ResetOnSpawn = false
ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
_G.UltimateGaGFarmUI = ScreenGui
-- Main Frame
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, 320, 0, 400)
MainFrame.Active = true
MainFrame.Draggable = true
MainFrame.ZIndex = 1
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(70, 170, 255)
Stroke.Thickness = 2
-- Shadow
local Shadow = Instance.new("Frame")
Shadow.Parent = ScreenGui
Shadow.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
Shadow.BackgroundTransparency = 0.7
Shadow.BorderSizePixel = 0
Shadow.Position = UDim2.new(0, 52, 0, 52)
Shadow.Size = UDim2.new(0, 320, 0, 400)
Shadow.ZIndex = 0
local ShadowCorner = Instance.new("UICorner")
ShadowCorner.CornerRadius = UDim.new(0, 12)
ShadowCorner.Parent = Shadow
-- Title Bar
local TitleBar = Instance.new("Frame")
TitleBar.Name = "TitleBar"
TitleBar.Parent = MainFrame
TitleBar.BackgroundColor3 = Color3.fromRGB(45, 130, 220)
TitleBar.BorderSizePixel = 0
TitleBar.Size = UDim2.new(1, 0, 0, 40)
TitleBar.ZIndex = 2
local TitleCorner = Instance.new("UICorner")
TitleCorner.CornerRadius = UDim.new(0, 12)
TitleCorner.Parent = TitleBar
local TitleGradient = Instance.new("UIGradient")
TitleGradient.Parent = TitleBar
TitleGradient.Color = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.fromRGB(45, 130, 220)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(25, 110, 200))
})
TitleGradient.Rotation = 90
local Title = Instance.new("TextLabel")
Title.Parent = TitleBar
Title.BackgroundTransparency = 1
Title.Position = UDim2.new(0, 15, 0, 0)
Title.Size = UDim2.new(1, -50, 1, 0)
Title.Font = Enum.Font.SourceSansBold
Title.Text = "🌱 ระบบฟาร์มอัตโนมัติ"
Title.TextColor3 = Color3.fromRGB(255, 255, 255)
Title.TextSize = 16
Title.TextXAlignment = Enum.TextXAlignment.Left
Title.ZIndex = 3
-- Close Button
local CloseButton = Instance.new("TextButton")
CloseButton.Parent = TitleBar
CloseButton.BackgroundColor3 = Color3.fromRGB(220, 80, 80)
CloseButton.BorderSizePixel = 0
CloseButton.Position = UDim2.new(1, -35, 0, 5)
CloseButton.Size = UDim2.new(0, 30, 0, 30)
CloseButton.Font = Enum.Font.SourceSansBold
CloseButton.Text = "×"
CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
CloseButton.TextSize = 18
CloseButton.ZIndex = 3
local CloseCorner = Instance.new("UICorner")
CloseCorner.CornerRadius = UDim.new(0, 6)
CloseCorner.Parent = CloseButton
-- Content Frame with Scroll
local ContentFrame = Instance.new("ScrollingFrame")
ContentFrame.Parent = MainFrame
ContentFrame.BackgroundTransparency = 1
ContentFrame.Position = UDim2.new(0, 15, 0, 50)
ContentFrame.Size = UDim2.new(1, -30, 1, -65)
ContentFrame.CanvasSize = UDim2.new(0, 0, 0, 500)
ContentFrame.ScrollBarThickness = 8
ContentFrame.ScrollBarImageColor3 = Color3.fromRGB(70, 170, 255)
ContentFrame.ScrollingDirection = Enum.ScrollingDirection.Y
ContentFrame.ZIndex = 2
-- Helper function สำหรับสร้าง toggle
local function CreateToggle(parent, text, yPos, callback, defaultState)
local ToggleFrame = Instance.new("Frame")
ToggleFrame.Parent = parent
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)
ToggleFrame.ZIndex = 3
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
Label.ZIndex = 4
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
Toggle.ZIndex = 4
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
-- Helper function สำหรับสร้าง dropdown
local function CreateDropdown(parent, text, yPos, options, callback, defaultValue)
local DropdownFrame = Instance.new("Frame")
DropdownFrame.Parent = parent
DropdownFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 40)
DropdownFrame.BorderSizePixel = 0
DropdownFrame.Position = UDim2.new(0, 0, 0, yPos)
DropdownFrame.Size = UDim2.new(1, 0, 0, 30)
DropdownFrame.ZIndex = 3
local FrameCorner = Instance.new("UICorner")
FrameCorner.CornerRadius = UDim.new(0, 6)
FrameCorner.Parent = DropdownFrame
local Label = Instance.new("TextLabel")
Label.Parent = DropdownFrame
Label.BackgroundTransparency = 1
Label.Position = UDim2.new(0, 10, 0, 0)
Label.Size = UDim2.new(0.5, 0, 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
Label.ZIndex = 4
local DropdownButton = Instance.new("TextButton")
DropdownButton.Parent = DropdownFrame
DropdownButton.BackgroundColor3 = Color3.fromRGB(60, 60, 70)
DropdownButton.BorderSizePixel = 0
DropdownButton.Position = UDim2.new(0.5, 5, 0, 5)
DropdownButton.Size = UDim2.new(0.5, -15, 0, 20)
DropdownButton.Font = Enum.Font.SourceSans
DropdownButton.Text = defaultValue or options[1] or "เลือก"
DropdownButton.TextColor3 = Color3.fromRGB(255, 255, 255)
DropdownButton.TextSize = 10
DropdownButton.ZIndex = 4
local DropdownCorner = Instance.new("UICorner")
DropdownCorner.CornerRadius = UDim.new(0, 4)
DropdownCorner.Parent = DropdownButton
-- Simple cycling through options
local currentIndex = 1
for i, option in ipairs(options) do
if option == defaultValue then
currentIndex = i
break
end
end
DropdownButton.MouseButton1Click:Connect(function()
currentIndex = currentIndex + 1
if currentIndex > #options then
currentIndex = 1
end
local selectedValue = options[currentIndex]
DropdownButton.Text = selectedValue
if callback then callback(selectedValue) end
end)
return DropdownButton
end
-- Section: ควบคุมหลัก
local MainSection = Instance.new("TextLabel")
MainSection.Parent = ContentFrame
MainSection.BackgroundColor3 = Color3.fromRGB(45, 130, 220)
MainSection.BorderSizePixel = 0
MainSection.Position = UDim2.new(0, 0, 0, 0)
MainSection.Size = UDim2.new(1, 0, 0, 25)
MainSection.Font = Enum.Font.SourceSansBold
MainSection.Text = "⚡ ควบคุมหลัก"
MainSection.TextColor3 = Color3.fromRGB(255, 255, 255)
MainSection.TextSize = 12
MainSection.ZIndex = 3
local MainCorner = Instance.new("UICorner")
MainCorner.CornerRadius = UDim.new(0, 6)
MainCorner.Parent = MainSection
CreateToggle(ContentFrame, "🌱 ปลูกอัตโนมัติ", 35, function(value)
Settings.AutoPlant = value
print("🌱 ปลูกอัตโนมัติ: " .. (value and "เปิด" or "ปิด"))
end, Settings.AutoPlant)
CreateToggle(ContentFrame, "🚜 เก็บเกี่ยวอัตโนมัติ", 75, function(value)
Settings.AutoHarvest = value
print("🚜 เก็บเกี่ยวอัตโนมัติ: " .. (value and "เปิด" or "ปิด"))
end, Settings.AutoHarvest)
CreateToggle(ContentFrame, "💰 ขายอัตโนมัติ", 115, function(value)
Settings.AutoSell = value
print("💰 ขายอัตโนมัติ: " .. (value and "เปิด" or "ปิด"))
end, Settings.AutoSell)
CreateToggle(ContentFrame, "🚶 เดินอัตโนมัติ (เหมือนคน)", 155, function(value)
Settings.AutoWalk = value
print("🚶 เดินอัตโนมัติ: " .. (value and "เปิด" or "ปิด"))
end, Settings.AutoWalk)
-- Section: ตัวเลือกการเก็บเกี่ยว
local HarvestSection = Instance.new("TextLabel")
HarvestSection.Parent = ContentFrame
HarvestSection.BackgroundColor3 = Color3.fromRGB(45, 130, 220)
HarvestSection.BorderSizePixel = 0
HarvestSection.Position = UDim2.new(0, 0, 0, 200)
HarvestSection.Size = UDim2.new(1, 0, 0, 25)
HarvestSection.Font = Enum.Font.SourceSansBold
HarvestSection.Text = "🚜 ตัวเลือกการเก็บเกี่ยว"
HarvestSection.TextColor3 = Color3.fromRGB(255, 255, 255)
HarvestSection.TextSize = 12
HarvestSection.ZIndex = 3
local HarvestCorner = Instance.new("UICorner")
HarvestCorner.CornerRadius = UDim.new(0, 6)
HarvestCorner.Parent = HarvestSection
CreateToggle(ContentFrame, "🌍 เก็บทุกฟาร์ม", 235, function(value)
Settings.HarvestAll = value
print("🌍 เก็บทุกฟาร์ม: " .. (value and "เปิด" or "ปิด"))
end, Settings.HarvestAll)
CreateDropdown(ContentFrame, "⚡ ความเร็วการเก็บ:", 275, {"Normal", "Fast", "Ultra Fast"}, function(value)
Settings.HarvestSpeed = value
print("⚡ ความเร็วการเก็บ: " .. value)
end, "Ultra Fast")
CreateToggle(ContentFrame, "🎒 ขายเมื่อกระเป๋าเต็ม", 315, function(value)
Settings.AutoSellWhenFull = value
print("🎒 ขายเมื่อกระเป๋าเต็ม: " .. (value and "เปิด" or "ปิด"))
end, Settings.AutoSellWhenFull)
-- Section: การเดิน
local WalkSection = Instance.new("TextLabel")
WalkSection.Parent = ContentFrame
WalkSection.BackgroundColor3 = Color3.fromRGB(45, 130, 220)
WalkSection.BorderSizePixel = 0
WalkSection.Position = UDim2.new(0, 0, 0, 360)
WalkSection.Size = UDim2.new(1, 0, 0, 25)
WalkSection.Font = Enum.Font.SourceSansBold
WalkSection.Text = "🚶 ตัวเลือกการเดิน"
WalkSection.TextColor3 = Color3.fromRGB(255, 255, 255)
WalkSection.TextSize = 12
WalkSection.ZIndex = 3
local WalkCorner = Instance.new("UICorner")
WalkCorner.CornerRadius = UDim.new(0, 6)
WalkCorner.Parent = WalkSection
CreateDropdown(ContentFrame, "🚶 ความเร็วการเดิน:", 395, {"ช้า", "ปกติ", "เร็ว"}, function(value)
Settings.WalkSpeed = value
print("🚶 ความเร็วการเดิน: " .. value)
end, "ปกติ")
CreateToggle(ContentFrame, "🎲 เดินแบบสุ่ม", 435, function(value)
Settings.WalkRandomness = value
print("🎲 เดินแบบสุ่ม: " .. (value and "เปิด" or "ปิด"))
end, Settings.WalkRandomness)
-- Section: เลี้ยงสัตว์
local PetSection = Instance.new("TextLabel")
PetSection.Parent = ContentFrame
PetSection.BackgroundColor3 = Color3.fromRGB(45, 130, 220)
PetSection.BorderSizePixel = 0
PetSection.Position = UDim2.new(0, 0, 0, 480)
PetSection.Size = UDim2.new(1, 0, 0, 25)
PetSection.Font = Enum.Font.SourceSansBold
PetSection.Text = "🐾 ระบบเลี้ยงสัตว์ (ทดลอง)"
PetSection.TextColor3 = Color3.fromRGB(255, 255, 255)
PetSection.TextSize = 12
PetSection.ZIndex = 3
local PetCorner = Instance.new("UICorner")
PetCorner.CornerRadius = UDim.new(0, 6)
PetCorner.Parent = PetSection
CreateToggle(ContentFrame, "🥚 ฟักไข่อัตโนมัติ", 515, function(value)
Settings.AutoHatchEgg = value
print("🥚 ฟักไข่อัตโนมัติ: " .. (value and "เปิด" or "ปิด"))
end, Settings.AutoHatchEgg)
CreateToggle(ContentFrame, "🍼 ให้อาหารอัตโนมัติ", 555, function(value)
Settings.AutoFeedPets = value
print("🍼 ให้อาหารอัตโนมัติ: " .. (value and "เปิด" or "ปิด"))
end, Settings.AutoFeedPets)
CreateToggle(ContentFrame, "🛒 ซื้อไข่อัตโนมัติ", 595, function(value)
Settings.AutoBuyEggs = value
print("🛒 ซื้อไข่อัตโนมัติ: " .. (value and "เปิด" or "ปิด"))
end, Settings.AutoBuyEggs)
CreateDropdown(ContentFrame, "🥚 ประเภทไข่:", 635, {
"Common Egg", "Uncommon Egg", "Rare Egg", "Legendary Egg", "Mythical Egg",
"Bug Egg", "Night Egg", "Bee Egg", "Anti Bee Egg", "Common Summer Egg",
"Rare Summer Egg", "Paradise Egg", "Oasis Egg"
}, function(value)
Settings.SelectedEggType = value
local eggInfo = PetEggTypes[value]
if eggInfo then
print("🥚 ประเภทไข่: " .. value .. " (ราคา: " .. eggInfo.Price .. ", เวลาฟัก: " .. eggInfo.HatchTime .. "s)")
else
print("🥚 ประเภทไข่: " .. value)
end
end, Settings.SelectedEggType)
-- Section: ขั้นสูง
local AdvancedSection = Instance.new("TextLabel")
AdvancedSection.Parent = ContentFrame
AdvancedSection.BackgroundColor3 = Color3.fromRGB(45, 130, 220)
AdvancedSection.BorderSizePixel = 0
AdvancedSection.Position = UDim2.new(0, 0, 0, 685)
AdvancedSection.Size = UDim2.new(1, 0, 0, 25)
AdvancedSection.Font = Enum.Font.SourceSansBold
AdvancedSection.Text = "⚙️ ขั้นสูง"
AdvancedSection.TextColor3 = Color3.fromRGB(255, 255, 255)
AdvancedSection.TextSize = 12
AdvancedSection.ZIndex = 3
local AdvancedCorner = Instance.new("UICorner")
AdvancedCorner.CornerRadius = UDim.new(0, 6)
AdvancedCorner.Parent = AdvancedSection
CreateToggle(ContentFrame, "🛒 ซื้อเมล็ดอัตโนมัติ", 720, function(value)
Settings.AutoBuy = value
print("🛒 ซื้อเมล็ดอัตโนมัติ: " .. (value and "เปิด" or "ปิด"))
end, Settings.AutoBuy)
CreateToggle(ContentFrame, "🎲 ปลูกแบบสุ่ม", 760, function(value)
Settings.PlantRandom = value
print("🎲 ปลูกแบบสุ่ม: " .. (value and "เปิด" or "ปิด"))
end, Settings.PlantRandom)
CreateDropdown(ContentFrame, "🎒 ขนาดกระเป๋า:", 800, {"20", "25", "30", "35"}, function(value)
Settings.MaxInventorySlots = tonumber(value)
print("🎒 ขนาดกระเป๋า: " .. value .. " ช่อง")
end, tostring(Settings.MaxInventorySlots))
-- Status Display
local StatusFrame = Instance.new("Frame")
StatusFrame.Parent = ContentFrame
StatusFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 25)
StatusFrame.BorderSizePixel = 0
StatusFrame.Position = UDim2.new(0, 0, 0, 850)
StatusFrame.Size = UDim2.new(1, 0, 0, 80)
StatusFrame.ZIndex = 3
local StatusCorner = Instance.new("UICorner")
StatusCorner.CornerRadius = UDim.new(0, 6)
StatusCorner.Parent = StatusFrame
local StatusLabel = Instance.new("TextLabel")
StatusLabel.Parent = StatusFrame
StatusLabel.BackgroundTransparency = 1
StatusLabel.Position = UDim2.new(0, 10, 0, 5)
StatusLabel.Size = UDim2.new(1, -20, 1, -10)
StatusLabel.Font = Enum.Font.SourceSans
StatusLabel.Text = "📊 สถานะ: พร้อมใช้งาน"
StatusLabel.TextColor3 = Color3.fromRGB(180, 255, 180)
StatusLabel.TextSize = 10
StatusLabel.TextYAlignment = Enum.TextYAlignment.Top
StatusLabel.TextXAlignment = Enum.TextXAlignment.Left
StatusLabel.TextWrapped = true
StatusLabel.ZIndex = 4
-- Update canvas size (เพิ่มสำหรับ Pet Section และข้อมูลเพิ่มเติม)
ContentFrame.CanvasSize = UDim2.new(0, 0, 0, 1100)
-- Close Button Event
CloseButton.MouseButton1Click:Connect(function()
Settings.AutoPlant = false
Settings.AutoHarvest = false
Settings.AutoSell = false
Settings.AutoBuy = false
Settings.AutoWalk = false
ScreenGui:Destroy()
_G.UltimateGaGFarmLoaded = false
_G.UltimateGaGFarmUI = nil
print("🌱 ปิดระบบฟาร์มอัตโนมัติ")
end)
-- Status Update
spawn(function()
while ScreenGui.Parent do
local OwnedSeeds = GetOwnedSeeds()
local Crops = GetInvCrops()
local Plants = GetHarvestablePlants()
local Pets = GetAllPets()
local Eggs = GetAvailableEggs()
local seedCount = OwnedSeeds[Settings.SelectedSeed] and OwnedSeeds[Settings.SelectedSeed].Count or 0
Title.Text = string.format("🌱 ฟาร์มอัตโนมัติ | 🌱%d 🥕%d 🚜%d 🐾%d", seedCount, #Crops, #Plants, #Pets)
local totalItems = GetTotalInventoryCount()
local inventoryStatus = totalItems >= Settings.MaxInventorySlots and "🔴 เต็ม" or "🟢 ปกติ"
-- แสดงข้อมูล Pet/Egg รายละเอียด
local petDetails = ""
local eggDetails = ""
if #Pets > 0 then
petDetails = "\n🐾 สัตว์เลี้ยง:"
for i, pet in ipairs(Pets) do
if i <= 3 then -- แสดงแค่ 3 ตัวแรก
petDetails = petDetails .. "\n - " .. pet.Name .. " (" .. pet.Location .. ")"
end
end
if #Pets > 3 then
petDetails = petDetails .. "\n ... และอีก " .. (#Pets - 3) .. " ตัว"
end
end
if #Eggs > 0 then
eggDetails = "\n🥚 ไข่ที่มี:"
for i, egg in ipairs(Eggs) do
if i <= 3 then -- แสดงแค่ 3 ฟองแรก
eggDetails = eggDetails .. "\n - " .. egg.Name
end
end
if #Eggs > 3 then
eggDetails = eggDetails .. "\n ... และอีก " .. (#Eggs - 3) .. " ฟอง"
end
end
StatusLabel.Text = string.format(
"📊 สถานะปัจจุบัน:\n🌱 เมล็ด %s: %d\n🥕 ผลผลิต: %d (เกณฑ์: %d)\n🎒 กระเป๋า: %d/%d %s\n🚜 พืชที่เก็บได้: %d\n🐾 สัตว์เลี้ยง: %d ตัว\n🥚 ไข่ที่มี: %d ฟอง\n🚶 กำลังเดิน: %s%s%s",
Settings.SelectedSeed,
seedCount,
#Crops,
Settings.SellThreshold,
totalItems,
Settings.MaxInventorySlots,
inventoryStatus,
#Plants,
#Pets,
#Eggs,
Settings.AutoWalk and "เปิด" or "ปิด",
petDetails,
eggDetails
)
wait(2)
end
end)
print("✅ Simple UI created!")
return ScreenGui
end
-- Optimized Main Loops with Auto Walk
local function StartSmoothLoops()
print("🔄 Starting smooth loops with auto walk...")
-- Auto Walk Loop (เดินทุก 3-8 วินาที แบบสุ่ม)
spawn(function()
while _G.UltimateGaGFarmLoaded do
if Settings.AutoWalk and not IsSelling then
local success, err = pcall(AutoWalkLoop)
if not success then
print("⚠️ Walk error: " .. tostring(err))
end
end
-- สุ่มเวลาเดินให้เหมือนคน
local walkSpeed = {
["ช้า"] = {5, 12},
["ปกติ"] = {3, 8},
["เร็ว"] = {2, 5}
}
local speedRange = walkSpeed[Settings.WalkSpeed] or {3, 8}
local waitTime = math.random(speedRange[1], speedRange[2])
wait(waitTime)
end
end)
-- Auto Plant Loop
spawn(function()
while _G.UltimateGaGFarmLoaded do
if Settings.AutoPlant and not IsSelling then
local success, err = pcall(AutoPlantLoop)
if not success then
print("⚠️ Plant error: " .. tostring(err))
end
end
wait(12) -- ปลูกทุก 12 วินาที
end
end)
-- Auto Harvest Loop
spawn(function()
while _G.UltimateGaGFarmLoaded do
if Settings.AutoHarvest and not IsSelling then
local success, err = pcall(AutoHarvestLoop)
if not success then
print("⚠️ Harvest error: " .. tostring(err))
end
end
-- Dynamic wait based on speed setting
local speedDelays = {
["Normal"] = 1.5,
["Fast"] = 0.8,
["Ultra Fast"] = 0.4
}
local waitTime = speedDelays[Settings.HarvestSpeed] or 0.4
wait(waitTime)
end
end)
-- Auto Sell Loop
spawn(function()
while _G.UltimateGaGFarmLoaded do
if Settings.AutoSell then
local success, err = pcall(AutoSellLoop)
if not success then
print("⚠️ Sell error: " .. tostring(err))
end
end
wait(8) -- ขายทุก 8 วินาที
end
end)
-- Auto Hatch Egg Loop
spawn(function()
while _G.UltimateGaGFarmLoaded do
if Settings.AutoHatchEgg and not IsSelling then
local success, err = pcall(AutoHatchEggLoop)
if not success then
print("⚠️ Pet Hatch error: " .. tostring(err))
end
end
wait(30) -- ฟักไข่ทุก 30 วินาที
end
end)
-- Auto Feed Pets Loop
spawn(function()
while _G.UltimateGaGFarmLoaded do
if Settings.AutoFeedPets and not IsSelling then
local success, err = pcall(AutoFeedPetsLoop)
if not success then
print("⚠️ Pet Feed error: " .. tostring(err))
end
end
wait(60) -- ให้อาหารทุก 60 วินาที
end
end)
-- Auto Buy Eggs Loop
spawn(function()
while _G.UltimateGaGFarmLoaded do
if Settings.AutoBuyEggs and not IsSelling then
local success, err = pcall(AutoBuyEggsLoop)
if not success then
print("⚠️ Pet Buy error: " .. tostring(err))
end
end
wait(120) -- ซื้อไข่ทุก 2 นาที
end
end)
print("✅ All smooth loops with auto walk and pets started")
end
-- Initialize
print("🚀 Initializing Simple GaG Auto Farm...")
-- Wait a bit for everything to load
wait(1)
-- Create UI
CreateSimpleUI()
-- Start smooth loops
StartSmoothLoops()
-- Success notification
game:GetService("StarterGui"):SetCore("SendNotification", {
Title = "🌱 ระบบฟาร์มอัตโนมัติ",
Text = "โหลดเรียบร้อย! ฟาร์ม + เดิน + เลี้ยงสัตว์ 🚶🐾",
Duration = 3
})
-- แสดงสรุปข้อมูลการติดตั้ง
print("\n" .. string.rep("=", 50))
print("✅ โหลดระบบฟาร์มอัตโนมัติแบบ Simple สำเร็จ!")
print("🌱 ฟาร์ม: " .. MyFarm.Name)
print("📍 พื้นที่: " .. X1 .. "," .. Z1 .. " ถึง " .. X2 .. "," .. Z2)
print("🚶 ระบบเดินอัตโนมัติ: พร้อมใช้งาน")
print("🐾 ระบบเลี้ยงสัตว์: พร้อมใช้งาน (ทดลอง)")
print("⚠️ หมายเหตุ: Pet RemoteEvents อาจต้องการการค้นหาในเกม")
print("🛠️ ใช้ _G.UltimateGaGFarmDebug.ShowEvents() เพื่อดู RemoteEvents ที่พบ")
print("🐾 ใช้ _G.UltimateGaGFarmDebug.CheckPets() เพื่อดูสัตว์เลี้ยง")
print("🥚 ใช้ _G.UltimateGaGFarmDebug.CheckEggs() เพื่อดูไข่")
-- แสดงสรุปข้อมูล Debug ของ Pet System
print("\n🔍 ข้อมูล Debug ของ Pet System:")
local debugPets = GetAllPets()
local debugEggs = GetAvailableEggs()
print("🐾 สัตว์เลี้ยงที่พบ: " .. #debugPets .. " ตัว")
for i, pet in ipairs(debugPets) do
if i <= 5 then
print(" " .. i .. ". " .. pet.Name .. " (" .. pet.Location .. ", " .. pet.Indicator .. ")")
end
end
if #debugPets > 5 then
print(" ... และอีก " .. (#debugPets - 5) .. " ตัว")
end
print("🥚 ไข่ที่พบ: " .. #debugEggs .. " ฟอง")
for i, egg in ipairs(debugEggs) do
if i <= 5 then
print(" " .. i .. ". " .. egg.Name .. " (" .. egg.Indicator .. ")")
end
end
if #debugEggs > 5 then
print(" ... และอีก " .. (#debugEggs - 5) .. " ฟอง")
end
print("🔧 Pet Events ที่พบ: " .. (function() local count = 0; for _ in pairs(PetEvents) do count = count + 1 end; return count end)())
for name, event in pairs(PetEvents) do
print(" - " .. name .. " (" .. event.ClassName .. ")")
end
print("" .. string.rep("=", 50) .. "\n")
-- สร้าง Debugging Functions สำหรับ Console Commands
_G.UltimateGaGFarmDebug = {
-- ตรวจสอบ Pet
CheckPets = function()
local pets = GetAllPets()
print("🐾 พบสัตว์เลี้ยง " .. #pets .. " ตัว:")
for i, pet in ipairs(pets) do
print(" " .. i .. ". " .. pet.Name .. " (" .. pet.Location .. ", " .. pet.Indicator .. ")")
end
return pets
end,
-- ตรวจสอบ Egg
CheckEggs = function()
local eggs = GetAvailableEggs()
print("🥚 พบไข่ " .. #eggs .. " ฟอง:")
for i, egg in ipairs(eggs) do
print(" " .. i .. ". " .. egg.Name .. " (" .. egg.Indicator .. ")")
end
return eggs
end,
-- ทดสอบฟักไข่
TestHatch = function(eggName)
local eggs = GetAvailableEggs()
for _, egg in ipairs(eggs) do
if not eggName or egg.Name:lower():find(eggName:lower()) then
print("🧪 ทดสอบฟักไข่: " .. egg.Name)
return HatchEgg(egg)
end
end
print("⚠️ ไม่พบไข่: " .. (eggName or "any"))
return false
end,
-- ทดสอบให้อาหาร
TestFeed = function(petName)
local pets = GetAllPets()
for _, pet in ipairs(pets) do
if not petName or pet.Name:lower():find(petName:lower()) then
print("🍼 ทดสอบให้อาหาร: " .. pet.Name)
return FeedPet(pet)
end
end
print("⚠️ ไม่พบสัตว์เลี้ยง: " .. (petName or "any"))
return false
end,
-- ทดสอบซื้อไข่
TestBuy = function(eggType)
eggType = eggType or Settings.SelectedEggType
print("🛒 ทดสอบซื้อไข่: " .. eggType)
return BuyEgg(eggType)
end,
-- แสดง RemoteEvents
ShowEvents = function()
print("📡 Pet RemoteEvents:")
for name, event in pairs(PetEvents) do
print(" " .. name .. " -> " .. event.ClassName .. " (" .. event:GetFullName() .. ")")
end
print("\n📡 GameEvents:")
for _, event in pairs(GameEvents:GetChildren()) do
if event:IsA("RemoteEvent") or event:IsA("RemoteFunction") then
print(" " .. event.Name .. " (" .. event.ClassName .. ")")
end
end
end,
-- สถานะระบบ
Status = function()
local pets = GetAllPets()
local eggs = GetAvailableEggs()
local crops = GetInvCrops()
local plants = GetHarvestablePlants()
print("📊 สถานะระบบ:")
print("🐾 สัตว์เลี้ยง: " .. #pets .. " ตัว")
print("🥚 ไข่: " .. #eggs .. " ฟอง")
print("🥕 ผลผลิต: " .. #crops .. " ชิ้น")
print("🌱 พืชเก็บได้: " .. #plants .. " ต้น")
return {
pets = #pets,
eggs = #eggs,
crops = #crops,
plants = #plants
}
end
}
print("🚀 Debug Commands พร้อมใช้งาน! ใช้คำสั่ง:")
print(" _G.UltimateGaGFarmDebug.CheckPets()")
print(" _G.UltimateGaGFarmDebug.CheckEggs()")
print(" _G.UltimateGaGFarmDebug.TestHatch('egg name')")
print(" _G.UltimateGaGFarmDebug.TestFeed('pet name')")
print(" _G.UltimateGaGFarmDebug.TestBuy('Common Egg')")
print(" _G.UltimateGaGFarmDebug.ShowEvents()")
print(" _G.UltimateGaGFarmDebug.Status()")
return {
Settings = Settings,
UI = _G.UltimateGaGFarmUI,
MyFarm = MyFarm,
Debug = _G.UltimateGaGFarmDebug
}