1. #1
    Deleted

    Help with lua code (broadcast)

    Well, my addon broadcasts interrupts both in raid and party chat when in raid group. How can i make it announce only to raid and not in party?
    Here's the code
    Code:
    		if (eventType == "SPELL_INTERRUPT") and sourceName == UnitName("player") then
    			intmsg = ("Interrupted");
    			if(INStarget == true) then
    				intmsg = (intmsg.." "..destName)
    			end
    
    			if(INSspell == true) then
    				if(INStarget == true) then
    					intmsg = (intmsg.."'s "..GetSpellLink(extraskillID))
    				else
    					intmsg = (intmsg.." "..GetSpellLink(extraskillID))
    				end
    			end
    
    			if UnitInRaid("player") and (INSraid == true) then
    				SendChatMessage(intmsg, "RAID")
    			end
    			if UnitInParty("player") and (INSparty == true) and (numParty > 0) then
    				SendChatMessage(intmsg, "PARTY")
    			end
    			if (INSyell == true) then
    				SendChatMessage(intmsg, "YELL")
    			end
    			if (INSsay == true) then
    				SendChatMessage(intmsg, "SAY")
    			end
    			if (INSself == true) then
    				print(intmsg)
    			end
    		end

  2. #2
    Don't remember if there's a function for that.

    But you could check if there are more than 5 players in party.

    Edit: Found!
    Use this:
    UnitInRaid("unit") - Returns 1 if unit is in your raid, nil if not.
    So for you it would be like this:
    Code:
    if UnitInRaid("player") then
      -- post in raid
    else
     -- post in party
    end
    Found at: WoWWiki: Raid Functions
    Last edited by Illonis; 2011-04-13 at 04:39 PM.

  3. #3
    Deleted
    Code:
    if UnitInParty("player") and (INSparty == true) and (numParty > 0) then
    				SendChatMessage(intmsg, "PARTY")
    			end
    Remove this.

  4. #4
    Quote Originally Posted by Treeston View Post
    Code:
    if UnitInParty("player") and (INSparty == true) and (numParty > 0) then
    				SendChatMessage(intmsg, "PARTY")
    			end
    Remove this.
    I think he just wanted to say that if he's in raid, the addon posts both, in raid and party. But it should post in either raid or party.

  5. #5
    Deleted
    Ah, I'm stupid.
    Code:
    			if UnitInParty("player") and (not UnitInRaid("player")) and (INSparty == true) and (numParty > 0) then
    				SendChatMessage(intmsg, "PARTY")
    			end


    ---------- Post added 2011-04-13 at 07:11 PM ----------

    Or, more efficiently:
    Code:
    			if UnitInRaid("player") and (INSraid == true) then
    				SendChatMessage(intmsg, "RAID")
    			elseif UnitInParty("player") and (INSparty == true) and (numParty > 0) then
    				SendChatMessage(intmsg, "PARTY")
    			end

  6. #6
    Instead of this:

    Code:
    			if UnitInRaid("player") and (INSraid == true) then
    				SendChatMessage(intmsg, "RAID")
    			end
    			if UnitInParty("player") and (INSparty == true) and (numParty > 0) then
    				SendChatMessage(intmsg, "PARTY")
    			end
    Try this:

    Code:
    			if UnitInParty("player") and (INSparty == true) and (numParty > 0) then
    				if UnitInRaid("player") and (INSraid == true) then
    					SendChatMessage(intmsg, "RAID")
    				end
    			elseif
    				SendChatMessage(intmsg, "PARTY")
    			end

  7. #7
    Deleted
    Thanks mate! Awesome (used Treeston 2nd code btw, thanks all though)

  8. #8
    Just so you know that code will not fire if you are in 5-man party and not a raid. Just be aware of that.

    That's why I reversed the checks to check for party first and then raid, if raid announce raid, if no raid announce party, otherwise it does nothing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •