Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Services
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local TextChatService = game:GetService("TextChatService")
- local Player = Players.LocalPlayer
- local PlayerGui = Player.PlayerGui
- -- Configuration
- local COOLDOWN_TIME = 30
- local ENABLE_CHAT_MESSAGES = true
- -- Chat Message Function
- local function sendChatMessage(message)
- if ENABLE_CHAT_MESSAGES then
- local player = Players.LocalPlayer
- if player then
- local textChannel = TextChatService.TextChannels.RBXGeneral
- if textChannel then
- pcall(function()
- textChannel:SendAsync(message)
- end)
- else
- warn("Text channel not found")
- end
- else
- warn("Player not found")
- end
- end
- end
- -- Function to handle trade acceptance
- local function onTradeAccepted()
- sendChatMessage("Trade completed")
- end
- -- Connect to the trade acceptance event
- ReplicatedStorage.Trade.AcceptTrade.OnClientEvent:Connect(onTradeAccepted)
- -- Main Loop
- while true do
- wait()
- if PlayerGui.MainGUI.Game.Leaderboard.Container.TradeRequest.ReceivingRequest.Visible and PlayerGui.MainGUI.Game.Leaderboard.Container.TradeRequest.Visible then
- wait()
- local sr = PlayerGui.MainGUI.Game.Leaderboard.Container.TradeRequest.ReceivingRequest.Username.Text
- local sender = game.Players:FindFirstChild(sr)
- if sender then
- sendChatMessage("Trade with " .. sender.Name .. " started, mode: deposit")
- end
- ReplicatedStorage.Trade.AcceptRequest:FireServer()
- local Cooldown = 0
- while wait(1) do
- Cooldown = Cooldown + 1
- local s = PlayerGui.TradeGUI.Container.Trade.TheirOffer.Username.Text
- s = string.sub(s, 2, string.len(s) - 1)
- local receiver = game.Players:FindFirstChild(s)
- if not PlayerGui.TradeGUI.Enabled then
- break
- end
- if PlayerGui.TradeGUI.Container.Trade.TheirOffer.Accepted.Visible then
- -- The trade acceptance is now handled by the OnClientEvent, so no need to call it directly
- wait()
- break
- end
- if Cooldown > COOLDOWN_TIME then
- ReplicatedStorage.Trade.DeclineTrade:FireServer()
- sendChatMessage("Trade declined due to timeout.")
- break
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement