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

661 lines
22 KiB
Lua

-- Smooth Pet System
-- ระบบเลี้ยงสัตว์แบบ Smooth
print("🐾 Loading Smooth Pet 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")
-- Smooth Pet Settings
local PetSettings = {
-- Pet Management
AutoHatchEgg = true,
AutoFeedPets = true,
AutoBuyEggs = true,
AutoEquipPets = true,
AutoSellBadPets = false,
-- Egg Settings
SelectedEggType = "Common Egg",
MaxPetsToHatch = 10,
HatchInterval = 30, -- ฟักไข่ทุก 30 วินาที
-- Feed Settings
FeedInterval = 60, -- ให้อาหารทุก 60 วินาที
FeedWhenHungry = true,
FeedAllPets = true,
-- Buy Settings
BuyInterval = 120, -- ซื้อไข่ทุก 2 นาที
MaxEggsToBuy = 5,
-- Performance Settings
UseSmoothAnimations = true,
AnimationDuration = 0.5,
UseThreading = true,
MaxThreads = 4,
-- Smart Settings
SmartPetManagement = true,
PrioritizeRarePets = true,
AutoEquipBestPets = true
}
-- 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" },
["Bug Egg"] = { HatchTime = 28800, Price = 25000, Rarity = "Special" },
["Night Egg"] = { HatchTime = 15000, Price = 15000, Rarity = "Special" },
["Bee Egg"] = { HatchTime = 14400, Price = 20000, Rarity = "Special" },
["Anti Bee Egg"] = { HatchTime = 15000, Price = 30000, Rarity = "Special" }
}
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" }
}
-- Performance Variables
local PetEvents = {}
local IsProcessingPets = false
local LastHatchTime = 0
local LastFeedTime = 0
local LastBuyTime = 0
-- Game Objects
local GameEvents = ReplicatedStorage:WaitForChild("GameEvents")
-- 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
-- Fallback to GameEvents
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()
-- Smooth 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",
"fox", "wolf", "bear", "deer", "monkey", "squirrel", "owl", "eagle"
}
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,
DataObject = tool:FindFirstChild(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,
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
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,
DataObject = tool:FindFirstChild(indicator)
})
end
end
end
CollectFromParent(Backpack)
if Character then
CollectFromParent(Character)
end
return eggs
end
-- Smooth Hatch Egg
local function SmoothHatchEgg(eggData)
if not eggData or not eggData.Tool then
print("⚠️ ไม่มี Egg Tool")
return false
end
local eggTool = eggData.Tool
print("🥚 กำลังฟักไข่: " .. eggTool.Name)
-- Smooth animation
if PetSettings.UseSmoothAnimations then
local Character = LocalPlayer.Character
if Character and Character:FindFirstChild("Humanoid") then
local Humanoid = Character:FindFirstChild("Humanoid")
Humanoid.WalkSpeed = 0 -- หยุดเดิน
wait(PetSettings.AnimationDuration)
Humanoid.WalkSpeed = 16 -- กลับมาเดินปกติ
end
end
-- Try multiple methods
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
print("❌ ไม่สามารถฟักไข่ได้: " .. eggTool.Name)
return false
end
-- Smooth Feed Pet
local function SmoothFeedPet(petData)
if not petData or not petData.Tool then
print("⚠️ ไม่มี Pet Tool")
return false
end
local petTool = petData.Tool
print("🍼 กำลังให้อาหาร: " .. petTool.Name)
-- Smooth animation
if PetSettings.UseSmoothAnimations then
local Character = LocalPlayer.Character
if Character and Character:FindFirstChild("Humanoid") then
local Humanoid = Character:FindFirstChild("Humanoid")
Humanoid.WalkSpeed = 0 -- หยุดเดิน
wait(PetSettings.AnimationDuration)
Humanoid.WalkSpeed = 16 -- กลับมาเดินปกติ
end
end
-- Try multiple methods
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
print("❌ ไม่สามารถให้อาหารได้: " .. petTool.Name)
return false
end
-- Smooth Buy Egg
local function SmoothBuyEgg(eggType)
if not PetEggTypes[eggType] then
print("⚠️ ไม่มีไข่ประเภท: " .. eggType)
return false
end
print("🛒 กำลังซื้อไข่: " .. eggType)
-- Smooth animation
if PetSettings.UseSmoothAnimations then
local Character = LocalPlayer.Character
if Character and Character:FindFirstChild("Humanoid") then
local Humanoid = Character:FindFirstChild("Humanoid")
Humanoid.WalkSpeed = 0 -- หยุดเดิน
wait(PetSettings.AnimationDuration)
Humanoid.WalkSpeed = 16 -- กลับมาเดินปกติ
end
end
-- Try multiple methods
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
print("❌ ไม่สามารถซื้อไข่ได้: " .. eggType)
return false
end
-- Smooth Pet Loops
local function SmoothHatchEggLoop()
if not PetSettings.AutoHatchEgg or IsProcessingPets then return end
local currentTime = tick()
if (currentTime - LastHatchTime) < PetSettings.HatchInterval then return end
local eggs = GetAvailableEggs()
if #eggs == 0 then
print("📝 ไม่มีไข่ให้ฟัก")
return
end
print("🥚 พบไข่ทั้งหมด " .. #eggs .. " ฟอง")
IsProcessingPets = true
local hatchedCount = 0
for _, eggData in pairs(eggs) do
if hatchedCount >= PetSettings.MaxPetsToHatch then
print("⏹️ ถึงจำนวนสูงสุดแล้ว (" .. PetSettings.MaxPetsToHatch .. ")")
break
end
if not PetSettings.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 PetSettings.AutoFeedPets or IsProcessingPets then return end
local currentTime = tick()
if (currentTime - LastFeedTime) < PetSettings.FeedInterval then return end
local pets = GetAllPets()
if #pets == 0 then
print("📝 ไม่มีสัตว์เลี้ยงให้ให้อาหาร")
return
end
print("🐾 พบสัตว์เลี้ยงทั้งหมด " .. #pets .. " ตัว")
IsProcessingPets = true
local fedCount = 0
for _, petData in pairs(pets) do
if not PetSettings.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 PetSettings.AutoBuyEggs or IsProcessingPets then return end
local currentTime = tick()
if (currentTime - LastBuyTime) < PetSettings.BuyInterval then return end
local eggs = GetAvailableEggs()
if #eggs >= PetSettings.MaxEggsToBuy then
print("📝 มีไข่เพียงพอแล้ว (" .. #eggs .. "/" .. PetSettings.MaxEggsToBuy .. ")")
return
end
local eggType = PetSettings.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
-- Main Loops
local function StartSmoothPetLoops()
print("🐾 Starting Smooth Pet Loops...")
-- Smooth Hatch Egg Loop
spawn(function()
while true do
local success, err = pcall(SmoothHatchEggLoop)
if not success then
print("⚠️ Smooth Hatch error: " .. tostring(err))
end
wait(PetSettings.HatchInterval)
end
end)
-- Smooth Feed Pets Loop
spawn(function()
while true do
local success, err = pcall(SmoothFeedPetsLoop)
if not success then
print("⚠️ Smooth Feed error: " .. tostring(err))
end
wait(PetSettings.FeedInterval)
end
end)
-- Smooth Buy Eggs Loop
spawn(function()
while true do
local success, err = pcall(SmoothBuyEggsLoop)
if not success then
print("⚠️ Smooth Buy error: " .. tostring(err))
end
wait(PetSettings.BuyInterval)
end
end)
print("✅ Smooth Pet Loops started")
end
-- Simple UI
local function CreateSmoothPetUI()
print("🎨 Creating Smooth Pet UI...")
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "SmoothPetUI"
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, 700, 0, 50)
MainFrame.Size = UDim2.new(0, 250, 0, 250)
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, 255)
Stroke.Thickness = 2
-- Title
local Title = Instance.new("TextLabel")
Title.Parent = MainFrame
Title.BackgroundColor3 = Color3.fromRGB(255, 100, 255)
Title.BorderSizePixel = 0
Title.Size = UDim2.new(1, 0, 0, 40)
Title.Font = Enum.Font.SourceSansBold
Title.Text = "🐾 Smooth Pet 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
-- 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, 150)
StatsLabel.Font = Enum.Font.SourceSans
StatsLabel.Text = "สถิติ:\n- ฟักไข่: " .. PetSettings.HatchInterval .. " วินาที\n- ให้อาหาร: " .. PetSettings.FeedInterval .. " วินาที\n- ซื้อไข่: " .. PetSettings.BuyInterval .. " วินาที\n- จำนวนสูงสุด: " .. PetSettings.MaxPetsToHatch .. " ตัว\n- ไข่ที่เลือก: " .. PetSettings.SelectedEggType
StatsLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
StatsLabel.TextSize = 10
StatsLabel.TextXAlignment = Enum.TextXAlignment.Left
StatsLabel.TextYAlignment = Enum.TextYAlignment.Top
print("✅ Smooth Pet UI created")
end
-- Initialize
print("🐾 Initializing Smooth Pet System...")
wait(1)
CreateSmoothPetUI()
StartSmoothPetLoops()
game:GetService("StarterGui"):SetCore("SendNotification", {
Title = "🐾 Smooth Pet System",
Text = "ระบบเลี้ยงสัตว์แบบ Smooth พร้อมใช้งาน!",
Duration = 3
})
print("🐾 " .. string.rep("=", 50))
print("✅ Smooth Pet System พร้อมใช้งาน!")
print("🐾 ฟักไข่: " .. PetSettings.HatchInterval .. " วินาที")
print("🐾 ให้อาหาร: " .. PetSettings.FeedInterval .. " วินาที")
print("🐾 ซื้อไข่: " .. PetSettings.BuyInterval .. " วินาที")
print("🐾 " .. string.rep("=", 50))
return {
Settings = PetSettings,
UI = ScreenGui
}