Advertisement
asgargg

los

Jun 8th, 2019
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. local library = loadstring(game:HttpGet("https://pastebin.com/raw/7Z6TzFnv", true))()
  2. local plr = game.Players.LocalPlayer
  3. local openCrystalRemote = game.ReplicatedStorage.rEvents:FindFirstChild("openCrystalRemote")
  4. local sellTrailEvent = game.ReplicatedStorage.rEvents:FindFirstChild("sellTrailEvent")
  5. local sellPetEvent = game.ReplicatedStorage.rEvents:FindFirstChild("sellPetEvent")
  6.  
  7. local rarityId = {
  8. Basic = 1,
  9. Advanced = 2,
  10. Rare = 3,
  11. Epic = 4,
  12. Unique = 5
  13. }
  14.  
  15. function GetAvailableCrystals()
  16. local Tab = workspace.mapCrystalsFolder:GetChildren()
  17. local crystals = {}
  18. for Index = 1, #Tab do
  19. crystals[Index] = Tab[Index].Name
  20. end
  21. return crystals
  22. end
  23.  
  24. function BuyCrystal(name, amount, minrarity)
  25. local minrarity = rarityId[minrarity] or rarityId["Basic"]
  26. local crystal = workspace.mapCrystalsFolder:FindFirstChild(name)
  27. if crystal then
  28. for i = 1, amount do
  29. local itemName, itemRarity = openCrystalRemote:InvokeServer("openCrystal", name)
  30. if itemName then
  31. local itemRarity = itemRarity or "Unknown"
  32. warn("Opened ".. name .. ", got ".. itemName .. " (" .. itemRarity.. ")")
  33. if rarityId[itemRarity] < minrarity then
  34. sellTrailEvent:FireServer("sellTrail", plr.trailsFolder[itemRarity][itemName])
  35. end
  36. else
  37. warn("Inventory full!")
  38. return
  39. end
  40. end
  41. else
  42. error("Crystal not found")
  43. end
  44. end
  45.  
  46. function SellAll(rarity)
  47. for _,Folder in next, plr.trailsFolder:GetChildren() do
  48. if rarityId[Folder.Name] <= rarityId[rarity] then
  49. for _,trail in next, Folder:GetChildren() do
  50. sellTrailEvent:FireServer("sellTrail", trail)
  51. warn("Sold trail " .. trail.Name .." (" .. trail.Parent.Name .. ")")
  52. end
  53. end
  54. end
  55.  
  56. for _,Folder in next, plr.petsFolder:GetChildren() do
  57. if rarityId[Folder.Name] <= rarityId[rarity] then
  58. for _,pet in next, Folder:GetChildren() do
  59. sellPetEvent:FireServer("sellPet", pet)
  60. warn("Sold pet " .. pet.Name .." (" .. pet.Parent.Name .. ")")
  61. end
  62. end
  63. end
  64. end
  65.  
  66. local mainwindow = library:CreateWindow({
  67. text = "Buy Window"
  68. })
  69.  
  70. mainwindow:AddDropdown(GetAvailableCrystals(), function(choice)
  71. _G.name = choice
  72. end)
  73.  
  74. mainwindow:AddBox("Amount", function(obj, enter)
  75. if enter then
  76. local s, val = pcall(tonumber, obj.Text)
  77. if s then
  78. _G.amount = val
  79. end
  80. end
  81. end)
  82.  
  83. mainwindow:AddButton("Buy crystals", function()
  84. if _G.amount and _G.name then
  85. BuyCrystal(_G.name, _G.amount)
  86. end
  87. end)
  88.  
  89.  
  90. local sellwindow = library:CreateWindow({
  91. text = "Sell Window"
  92. })
  93.  
  94. sellwindow:AddDropdown({"Basic", "Advanced", "Rare", "Epic", "Unique"}, function(choice)
  95. _G.sr = choice
  96. end)
  97.  
  98. sellwindow:AddButton("Sell items with <= set rarity", function()
  99. if _G.sr then
  100. SellAll(_G.sr)
  101. end
  102. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement