utilize UnitIsAFK

This commit is contained in:
Brues
2026-07-06 17:07:41 -05:00
parent f6683b31af
commit 80b677a6f8
2 changed files with 11 additions and 14 deletions
+5 -7
View File
@@ -1,5 +1,4 @@
pfUI:RegisterModule("afkcam", function () pfUI:RegisterModule("afkcam", function ()
local MARKED_AFK_CAPTURE = SanitizePattern(MARKED_AFK_MESSAGE)
local social_chats = { local social_chats = {
"CHAT_MSG_SAY", "CHAT_MSG_SAY",
"CHAT_MSG_WHISPER", "CHAT_MSG_WHISPER",
@@ -165,11 +164,10 @@ pfUI:RegisterModule("afkcam", function ()
end) end)
afkcam:SetScript("OnEvent", function() afkcam:SetScript("OnEvent", function()
if event == "CHAT_MSG_SYSTEM" then if event == "PLAYER_FLAGS_CHANGED" then
if (arg1 == _G.MARKED_AFK) or strfind(arg1, MARKED_AFK_CAPTURE) then local isAFK = UnitIsAFK('player')
delay:Show() delay:SetShown(isAFK)
elseif (arg1 == _G.CLEARED_AFK) then if not isAFK then
delay:Hide()
this:stop() this:stop()
end end
else else
@@ -180,7 +178,7 @@ pfUI:RegisterModule("afkcam", function ()
end end
end) end)
afkcam:RegisterEvent("CHAT_MSG_SYSTEM") afkcam:RegisterEvent("PLAYER_FLAGS_CHANGED")
afkcam:RegisterEvent("PLAYER_REGEN_DISABLED") afkcam:RegisterEvent("PLAYER_REGEN_DISABLED")
afkcam:RegisterEvent("PLAYER_LEAVING_WORLD") -- reseting cvars on PLAYER_LOGOUT crashes the client ¯\_(ツ)_/¯ afkcam:RegisterEvent("PLAYER_LEAVING_WORLD") -- reseting cvars on PLAYER_LOGOUT crashes the client ¯\_(ツ)_/¯
end) end)
+6 -7
View File
@@ -8,9 +8,9 @@ pfUI:RegisterModule("easteregg", function ()
local pvpking = CreateFrame("Frame", "pfPvPKing", UIParent) local pvpking = CreateFrame("Frame", "pfPvPKing", UIParent)
pvpking:Hide() pvpking:Hide()
pvpking:RegisterEvent("CHAT_MSG_SYSTEM") pvpking:RegisterEvent("PLAYER_FLAGS_CHANGED")
pvpking:SetScript("OnEvent", function() pvpking:SetScript("OnEvent", function()
if strfind(arg1, "You are now", 1) and strfind(arg1, "(AFK)", 1) then if UnitIsAFK('player') then
_G.CHAT_FLAG_AFK = title .. " " _G.CHAT_FLAG_AFK = title .. " "
this.time = GetTime() this.time = GetTime()
this:Show() this:Show()
@@ -61,14 +61,13 @@ pfUI:RegisterModule("easteregg", function ()
end) end)
-- trigger fireworks when being AFK -- trigger fireworks when being AFK
fireworks:RegisterEvent("CHAT_MSG_SYSTEM") fireworks:RegisterEvent("PLAYER_FLAGS_CHANGED")
fireworks:SetScript("OnEvent", function() fireworks:SetScript("OnEvent", function()
if strfind(arg1, _G.MARKED_AFK) or strfind(arg1, _G.MARKED_AFK_MESSAGE) then local isAFK = UnitIsAFK('player')
if isAFK then
this:SetAlpha(0) this:SetAlpha(0)
this:Show()
elseif strfind(arg1, _G.CLEARED_AFK) then
this:Hide()
end end
this:SetShown(isAFK)
end) end)
-- basic explosion animation -- basic explosion animation