Thread Tools Display Modes
08-20-09, 04:41 AM   #1
mentalnutsy
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 47
Creating first addon got problem with mass spam

I'm trying to an announcement addon, i have come across a problem with one of the spells it does a mass aoe effect and last for 6 seconds.
What i want to happen is the addon announce when i use the spell and when the spell fades.

The problem im getting is it announces just fine apart from the fact it spamms like mad say the aoe hit 5 targets ill get 5 messages how do i limit it to 2 messages one message when spell is cast and one message when spell effect has finished on all mobs incase one mob dies.

if e == "SPELL_AURA_APPLIED" then
id = select(9, ...)
if id == 1161 and source == UnitGUID("player") then
local spew = format(ms, GetSpellInfo(id), "Used ALL MOBS ON ME FOR 6 SECONDS")
if (GetNumRaidMembers() > 0) then
SendChatMessage(spew, "RAID")
elseif (GetNumPartyMembers() > 0) then
SendChatMessage(spew, "PARTY")
else
SendChatMessage(spew, "SAY")
end
end
elseif e == "SPELL_AURA_REMOVED" then
id = select(9, ...)
if id == 1161 and source == UnitGUID("player") then
local spew = format(ms, GetSpellInfo(id), "Finished")
if (GetNumRaidMembers() > 0) then
SendChatMessage(spew, "RAID")
elseif (GetNumPartyMembers() > 0) then
SendChatMessage(spew, "PARTY")
else
SendChatMessage(spew, "SAY")
end
end
end

Thank you for any help you may be able to give me Like i said im new to codeing and only working on the basics atm but this is *%%*^ me off lol

Last edited by mentalnutsy : 08-20-09 at 04:44 AM.
  Reply With Quote
08-20-09, 07:06 AM   #2
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
You're using the event for when an aura is applied/removed. That's why it's triggering for each mob it hits. Use the SPELL_CAST_SUCCESS event to only make it trigger once when the spell is used.
  Reply With Quote
08-20-09, 07:13 AM   #3
mentalnutsy
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 47
Ok ty for the info thats done ill use that and delete the SPELL_AURA_REMOVED. Thanks for yer time.
  Reply With Quote
08-20-09, 07:52 AM   #4
mentalnutsy
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 47
Ok iv changed the code to see below. SPELL_CAST_SUCCESS works like a dream, but i suspect ill get spam if the spell fails e.g resist/immune for every mob that is immune or resists it, is there any possible way around this. Thanks for youre time and patients.

if e == "SPELL_CAST_SUCCESS" then
id = select(9, ...)
if id == 1161 and source == UnitGUID("player") then
local spew = format(ms, GetSpellInfo(id), "Used ALL MOBS ON ME FOR 6 SECONDS")
if (GetNumRaidMembers() > 0) then
SendChatMessage(spew, "RAID")
elseif (GetNumPartyMembers() > 0) then
SendChatMessage(spew, "PARTY")
else
SendChatMessage(spew, "SAY")
end
end
elseif e == "SPELL_MISSED" then
missType = select(12, ...)
if id == 1161 and source == UnitGUID("player") then
local spew = format(msg, GetSpellInfo(id), "FAILED on", missType)
if (GetNumRaidMembers() > 0) then
SendChatMessage(spew, "RAID")
elseif (GetNumPartyMembers() > 0) then
SendChatMessage(spew, "PARTY")
else
SendChatMessage(spew, "SAY")
end
end
end
  Reply With Quote
08-20-09, 09:19 AM   #5
zero-kill
A Firelord
 
zero-kill's Avatar
Join Date: Aug 2009
Posts: 497
Couldn't you whisper yourself?
  Reply With Quote
08-20-09, 09:34 AM   #6
mentalnutsy
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 47
Originally Posted by zero-kill View Post
Couldn't you whisper yourself?
that is an options but wouldent solve the problem as i would get spammed with /w
  Reply With Quote
08-20-09, 10:58 AM   #7
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
Throttle your message.

Code:
local lastAnnounce

...

-- 1 second throttle
if not lastAnnounce or lastAnnounce + 1 < GetTime() then
     -- Announce here
     lastAnnounce = GetTime()
end
  Reply With Quote
08-20-09, 11:11 AM   #8
mentalnutsy
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 47
Originally Posted by Waverian View Post
Throttle your message.

Code:
local lastAnnounce

...

-- 1 second throttle
if not lastAnnounce or lastAnnounce + 1 < GetTime() then
     -- Announce here
     lastAnnounce = GetTime()
end
Sadly i couldent get the above code to work

Last edited by mentalnutsy : 08-22-09 at 11:03 AM.
  Reply With Quote
08-22-09, 11:36 AM   #9
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
What didn't work about it? Include the code snippet with the stuff that didn't work. I can't find any reference to the throttle in the code you PM'd me.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Creating first addon got problem with mass spam


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off