-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTradeTimeoutMonitor.lua
More file actions
59 lines (48 loc) · 1.81 KB
/
Copy pathTradeTimeoutMonitor.lua
File metadata and controls
59 lines (48 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
------------------------------------------
-- Trade Timeout Monitor
------------------------------------------
-- This module monitors trade timeouts and handles the logic for blacklisting players
-- who do not complete their trades within a specified time limit.
-- It uses the C_Timer API to create a timer that checks for trade completion.
local MageService = MAGESERVICE
local Blacklist = MageService.Blacklist
local Trade = MageService.Trade
------------------------------------------
-- Create the module
------------------------------------------
local TradeTimeoutMonitor = {}
------------------------------------------
-- Configuration
------------------------------------------
-- Trade timeout configuration
local TRADE_TIMEOUT_SECONDS = 60
local tradeTimeoutTimer = nil
------------------------------------------
-- Core Functions
------------------------------------------
-- Function to start the trade timeout monitoring
function TradeTimeoutMonitor.Start(player)
-- Start the trade timeout timer
if tradeTimeoutTimer then
tradeTimeoutTimer:Cancel()
end
tradeTimeoutTimer = C_Timer.NewTimer(TRADE_TIMEOUT_SECONDS, function()
print("Trade with " .. player .. " timed out.")
-- Reset the trade status and blacklist the player
Trade.SetPlayerPortalPurchaseStatus(player, nil)
Blacklist.AddPlayer(player)
-- Cancel the trade and notify the player
CancelTrade()
end)
end
-- Function to stop the trade timeout monitoring
function TradeTimeoutMonitor.Stop()
if tradeTimeoutTimer then
tradeTimeoutTimer:Cancel()
tradeTimeoutTimer = nil
end
end
------------------------------------------
-- Register the module in the addon namespace
------------------------------------------
MageService.TradeTimeoutMonitor = TradeTimeoutMonitor