-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSaySapped.lua
More file actions
52 lines (45 loc) · 1.51 KB
/
SaySapped.lua
File metadata and controls
52 lines (45 loc) · 1.51 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
--[[
SaySapped: Says "Sapped!" when you get sapped allowing you to notify nearby players about it.
Also works for many other CCs.
Author: Coax - Nostalrius PvP
Original idea: Bitbyte of Icecrown
--]]
-- Check if sapped
function SaySapped_FilterDebuffs(spell)
if string.find(spell, " Sap.") and SaySappedConfig then
SendChatMessage("Sapped!","SAY")
DEFAULT_CHAT_FRAME:AddMessage("Sapped!")
end
end
-- Check if the player is entering the world and create the config file if it is not yet created.
-- if the event is a debuff on you, filter it.
function SaySapped_OnEvent(event)
if event == "PLAYER_ENTERING_WORLD" then
this:UnregisterEvent("PLAYER_ENTERING_WORLD")
if not SaySappedConfig then
SaySappedConfig = true
end
elseif event == "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE" then
if string.find(arg1, "You are") then
SaySapped_FilterDebuffs(arg1)
end
end
end
-- Slash Command
SlashCmdList["SAYSAPPED"] = SaySapped_SlashCmdHandler
SLASH_SAYSAPPED1 = "/saysapped"
function SaySapped_SlashCmdHandler(msg)
if SaySappedConfig then
SaySappedConfig = false
DEFAULT_CHAT_FRAME:AddMessage("SaySapped disabled!")
else
SaySappedConfig = true
DEFAULT_CHAT_FRAME:AddMessage("SaySapped enabled!")
end
end
-- Start registering events and print the loading message.
function SaySapped_OnLoad()
SaySapped:RegisterEvent("PLAYER_ENTERING_WORLD")
SaySapped:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE")
DEFAULT_CHAT_FRAME:AddMessage("SaySapped loaded, type /saysapped to toggle on and off. Made by Coax.")
end