Advertisement
HHLExploits

Farmtown

May 28th, 2019
1,101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.46 KB | None | 0 0
  1. _G.farming = true --Set this to false if you wanna buy seed or do other stuff
  2. _G.seed = "Hay" --Which seed you want to plant
  3. _G.OutBox = false --Set this to true if you have an outbox
  4.  
  5. --Dunt mess dis down here >:C
  6.  
  7. --// VARS //--
  8. local PlayerData = require(game.ReplicatedStorage:WaitForChild("PlayerData"))
  9. local plr = game:GetService("Players").LocalPlayer
  10. local selling = false
  11.  
  12. --// FUNCTIONS //--
  13. local function fS(func, ...)
  14. assert(type(func) == "function")
  15. local args = {...}
  16. local bindable = Instance.new("BindableEvent")
  17. bindable.Event:Connect(
  18. function()
  19. func(unpack(args))
  20. end
  21. )
  22. bindable:Fire()
  23. bindable:Destroy()
  24. end
  25.  
  26. local function isInTable(table, toFind)
  27. assert(type(table) == "table")
  28. assert(type(toFind) == "string")
  29. local found = false
  30. for _, v in pairs(table) do
  31. if v == toFind then
  32. found = true
  33. break
  34. end
  35. end
  36. return found
  37. end
  38.  
  39. local function sellCrops()
  40. local data = PlayerData.get()
  41. if data.weight > 0 then
  42. selling = not selling
  43. if not _G.OutBox then
  44. plr.Character:MoveTo(Vector3.new(52, 5, -453))
  45. wait(3)
  46. end
  47. for crop, _ in pairs(_G.crops) do
  48. local cropType = crop
  49. local quantity = 0
  50. if cropType and cropType ~= "none" then
  51. quantity = data.crops[cropType]
  52. end
  53. game.ReplicatedStorage.UseMarket:FireServer("SellCrop", cropType, quantity, _G.OutBox)
  54. game.ReplicatedStorage.CropSold:Fire(cropType, quantity, _G.OutBox)
  55. end
  56. selling = not selling
  57. end
  58. end
  59.  
  60. local function useWell()
  61. if selling then
  62. return
  63. end
  64.  
  65. local well = _G.farm:FindFirstChild("Well")
  66.  
  67. local wellPos = well.PrimaryPart.Position
  68. local plrPos = plr.Character.PrimaryPart.Position
  69.  
  70. local distance = (plrPos - wellPos).magnitude
  71.  
  72. if distance >= 14 then
  73. plr.Character:MoveTo(wellPos)
  74. wait(.6)
  75. end
  76. end
  77.  
  78. local function createFarmPlots()
  79. _G.plots = {}
  80. _G.farm = nil
  81. _G.plotSize = 0
  82.  
  83. for i = 1, 8 do
  84. if
  85. workspace:FindFirstChild("Farm" .. i) and workspace["Farm" .. i]:FindFirstChild("Owner") and
  86. workspace["Farm" .. i].Owner.Value == plr
  87. then
  88. _G.farm = workspace["Farm" .. i]
  89.  
  90. end
  91. end
  92.  
  93. for i = 1, 6 do
  94. if _G.farm:FindFirstChild("Plot" .. i) then
  95. table.insert(_G.plots, _G.farm["Plot" .. i])
  96. _G.plotSize = _G.plotSize + #_G.farm["Plot" .. i]:GetChildren()
  97. end
  98. end
  99.  
  100. _G.farm.ChildAdded:Connect(function©
  101. _G.plots = {}
  102.  
  103. for i = 1, 6 do
  104. if _G.farm:FindFirstChild("Plot" .. i) then
  105. table.insert(_G.plots, _G.farm["Plot" .. i])
  106. _G.plotSize = _G.plotSize + #_G.farm["Plot" .. i]:GetChildren()
  107. end
  108. end
  109. end)
  110. end
  111.  
  112. local function harvest(v)
  113. local data = PlayerData.get()
  114. local type = v.CropType.Value
  115. local stage = v.CropStage.Value
  116. local reqStage = _G.crops[type]
  117.  
  118. if type == "Corn" and reqStage - 1 == stage and data.seeds[type] < _G.plotSize then
  119. game.ReplicatedStorage.ManipulateCrop:FireServer(v, "Harvest")
  120. elseif reqStage == stage then
  121. game.ReplicatedStorage.ManipulateCrop:FireServer(v, "Harvest")
  122. end
  123. end
  124.  
  125. local function plant(v)
  126. local data = PlayerData.get()
  127. if data.seeds[_G.seed] then
  128. game.ReplicatedStorage.ManipulateCrop:FireServer(v, "PlantSeed", _G.seed)
  129. end
  130. end
  131.  
  132. local function water(v)
  133. game.ReplicatedStorage.ManipulateCrop:FireServer(v, "Water")
  134. useWell()
  135. game.ReplicatedStorage.UseItem:FireServer(_G.farm:FindFirstChild("Well"))
  136. end
  137.  
  138. local function plotFarm(plot)
  139. assert(typeof(plot) == "Instance")
  140. for _, v in pairs(plot:GetChildren()) do
  141. if v.Name ~= "Camera1" and v.Name ~= "Camera2" and v.Name ~= "Plot" and v.Name ~= "HasGreenhouse" then
  142. if v.CropType.Value ~= "none" then
  143. harvest(v)
  144. else
  145. plant(v)
  146. end
  147. if v.WaterContent.Value <= 2 then
  148. water(v)
  149. end
  150. end
  151. end
  152. end
  153.  
  154. local function autoFarm()
  155. while _G.KillSwitch do
  156. wait(5)
  157. if _G.farming then
  158. for _, plot in pairs(_G.plots) do
  159. fS(sellCrops)
  160. fS(plotFarm, plot)
  161. end
  162. end
  163. end
  164. end
  165.  
  166. if _G.farm == nil then
  167. createFarmPlots()
  168. end
  169.  
  170. if not _G.crops or not isInTable(_G.crops, "Hay") then
  171. _G.crops = {}
  172. for _, v in pairs(game:GetService("ReplicatedStorage").Assets.Farming.Crops:GetChildren()) do
  173. _G.crops[v.Name] = #v:GetChildren()
  174. end
  175. end
  176.  
  177. --// INIT //--
  178. _G.KillSwitch = false -- Just in case if someone execute everything
  179. wait(6)
  180. _G.KillSwitch = true -- instead of just changing the _G vars up there
  181.  
  182. autoFarm()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement