Advertisement
hammercoolness

Untitled

Jun 18th, 2024 (edited)
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  3. local HttpService = game:GetService("HttpService")
  4. local TextChatService = game:GetService("TextChatService")
  5.  
  6. local LocalPlayer = Players.LocalPlayer
  7. local TradeWindow = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("TradeWindow")
  8. local Message = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("Message")
  9. local Status = TradeWindow.Frame.PlayerItems.Status
  10.  
  11. local TradingCommands = require(ReplicatedStorage:WaitForChild("Library"):WaitForChild("Client"):WaitForChild("TradingCmds"))
  12.  
  13. local TradeUser = nil
  14. local GoNext = true
  15.  
  16. -- Initializing
  17. print("[OMGKOREA Trade Bot] Initializing...")
  18.  
  19. -- Functions
  20. print("[OMGKOREA Trade Bot] Initializing functions...")
  21.  
  22. -- Gets all new trade requests
  23. local function GetTrades()
  24. local trades = {}
  25. local functionTrades = TradingCommands.GetAllRequests()
  26.  
  27. for player, trade in pairs(functionTrades) do
  28. if trade[LocalPlayer] then
  29. table.insert(trades, player)
  30. end
  31. end
  32.  
  33. return trades
  34. end
  35.  
  36. -- Accept trade request
  37. local function AcceptTradeRequest(player)
  38. return TradingCommands.Request(player)
  39. end
  40.  
  41. -- Reject trade request
  42. local function RejectTradeRequest(player)
  43. return TradingCommands.Reject(player)
  44. end
  45.  
  46. -- Ready the actual trade
  47. local function ReadyTrade()
  48. return TradingCommands.SetReady(true)
  49. end
  50.  
  51. -- Confirm the trade
  52. local function Confirmed()
  53. return TradingCommands.SetConfirmed(true) -- Hypothetical function to confirm trade
  54. end
  55.  
  56. -- Decline the actual trade
  57. local function DeclineTrade()
  58. return TradingCommands.Decline()
  59. end
  60.  
  61. -- Add pet to trade
  62. local function AddPet(uuid)
  63. return TradingCommands.SetItem("Pet", uuid, 1)
  64. end
  65.  
  66. -- Send chat message
  67. local function SendMessage(message)
  68. pcall(function()
  69. TextChatService.TextChannels.RBXGeneral:SendAsync(message)
  70. end)
  71. pcall(function()
  72. task.wait(0.1)
  73. TradingCommands.Message(message)
  74. end)
  75. return true
  76. end
  77.  
  78. -- Connection Functions
  79. print("[OMGKOREA Trade Bot] Initializing connects...")
  80.  
  81. -- Detect acceptance or decline of the trade
  82. local function ConnectMessage()
  83. local messageConnection
  84. messageConnection = Message:GetPropertyChangedSignal("Enabled"):Connect(function()
  85. if Message.Enabled then
  86. local text = Message.Frame.Contents.Desc.Text
  87.  
  88. if text == "✅ Trade successfully completed!" then
  89. SendMessage("Trade Completed!")
  90. print("Trade complete")
  91. messageConnection:Disconnect()
  92. GoNext = true
  93. elseif string.find(text, "cancelled the trade!") then
  94. SendMessage("Trade Declined")
  95. messageConnection:Disconnect()
  96. GoNext = true
  97. elseif string.find(text, "left the game") then
  98. SendMessage("Trade Declined")
  99. messageConnection:Disconnect()
  100. GoNext = true
  101. end
  102. else
  103. GoNext = true
  104. messageConnection:Disconnect()
  105. end
  106. end)
  107. end
  108.  
  109. -- Detect when user accepts, make various checks, and accept the trade
  110. local function ConnectStatus(localId)
  111. local statusConnection
  112. statusConnection = Status:GetPropertyChangedSignal("Visible"):Connect(function()
  113. if Status.Visible then
  114. ReadyTrade()
  115. else
  116. statusConnection:Disconnect()
  117. Confirmed() -- Change this line to call your new function
  118. end
  119. end)
  120. end
  121.  
  122. -- Main Script
  123. print("[OMGKOREA Trade Bot] Initializing main script...")
  124.  
  125. spawn(function()
  126. while wait(1) do
  127. local incomingTrades = GetTrades()
  128.  
  129. if #incomingTrades > 0 and GoNext then
  130. local trade = incomingTrades[1]
  131. local username = trade.Name
  132. TradeUser = Players:GetUserIdFromNameAsync(username)
  133.  
  134. local accepted = AcceptTradeRequest(trade)
  135.  
  136. if not accepted then
  137. pcall(function()
  138. RejectTradeRequest(trade)
  139. end)
  140. else
  141. SendMessage("Trade with: " .. username .. " accepted, Method: Deposit")
  142.  
  143. ConnectMessage()
  144. ConnectStatus(TradeUser)
  145. GoNext = false
  146. end
  147. end
  148. end
  149. end)
  150.  
  151. print("[OMGKOREA Trade Bot] Script loaded")
  152.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement