Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local HttpService = game:GetService("HttpService")
- local TextChatService = game:GetService("TextChatService")
- local LocalPlayer = Players.LocalPlayer
- local TradeWindow = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("TradeWindow")
- local Message = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("Message")
- local Status = TradeWindow.Frame.PlayerItems.Status
- local TradingCommands = require(ReplicatedStorage:WaitForChild("Library"):WaitForChild("Client"):WaitForChild("TradingCmds"))
- local TradeUser = nil
- local GoNext = true
- -- Initializing
- print("[OMGKOREA Trade Bot] Initializing...")
- -- Functions
- print("[OMGKOREA Trade Bot] Initializing functions...")
- -- Gets all new trade requests
- local function GetTrades()
- local trades = {}
- local functionTrades = TradingCommands.GetAllRequests()
- for player, trade in pairs(functionTrades) do
- if trade[LocalPlayer] then
- table.insert(trades, player)
- end
- end
- return trades
- end
- -- Accept trade request
- local function AcceptTradeRequest(player)
- return TradingCommands.Request(player)
- end
- -- Reject trade request
- local function RejectTradeRequest(player)
- return TradingCommands.Reject(player)
- end
- -- Ready the actual trade
- local function ReadyTrade()
- return TradingCommands.SetReady(true)
- end
- -- Confirm the trade
- local function Confirmed()
- return TradingCommands.SetConfirmed(true) -- Hypothetical function to confirm trade
- end
- -- Decline the actual trade
- local function DeclineTrade()
- return TradingCommands.Decline()
- end
- -- Add pet to trade
- local function AddPet(uuid)
- return TradingCommands.SetItem("Pet", uuid, 1)
- end
- -- Send chat message
- local function SendMessage(message)
- pcall(function()
- TextChatService.TextChannels.RBXGeneral:SendAsync(message)
- end)
- pcall(function()
- task.wait(0.1)
- TradingCommands.Message(message)
- end)
- return true
- end
- -- Connection Functions
- print("[OMGKOREA Trade Bot] Initializing connects...")
- -- Detect acceptance or decline of the trade
- local function ConnectMessage()
- local messageConnection
- messageConnection = Message:GetPropertyChangedSignal("Enabled"):Connect(function()
- if Message.Enabled then
- local text = Message.Frame.Contents.Desc.Text
- if text == "✅ Trade successfully completed!" then
- SendMessage("Trade Completed!")
- print("Trade complete")
- messageConnection:Disconnect()
- GoNext = true
- elseif string.find(text, "cancelled the trade!") then
- SendMessage("Trade Declined")
- messageConnection:Disconnect()
- GoNext = true
- elseif string.find(text, "left the game") then
- SendMessage("Trade Declined")
- messageConnection:Disconnect()
- GoNext = true
- end
- else
- GoNext = true
- messageConnection:Disconnect()
- end
- end)
- end
- -- Detect when user accepts, make various checks, and accept the trade
- local function ConnectStatus(localId)
- local statusConnection
- statusConnection = Status:GetPropertyChangedSignal("Visible"):Connect(function()
- if Status.Visible then
- ReadyTrade()
- else
- statusConnection:Disconnect()
- Confirmed() -- Change this line to call your new function
- end
- end)
- end
- -- Main Script
- print("[OMGKOREA Trade Bot] Initializing main script...")
- spawn(function()
- while wait(1) do
- local incomingTrades = GetTrades()
- if #incomingTrades > 0 and GoNext then
- local trade = incomingTrades[1]
- local username = trade.Name
- TradeUser = Players:GetUserIdFromNameAsync(username)
- local accepted = AcceptTradeRequest(trade)
- if not accepted then
- pcall(function()
- RejectTradeRequest(trade)
- end)
- else
- SendMessage("Trade with: " .. username .. " accepted, Method: Deposit")
- ConnectMessage()
- ConnectStatus(TradeUser)
- GoNext = false
- end
- end
- end
- end)
- print("[OMGKOREA Trade Bot] Script loaded")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement