Quantcast
Send addon message based on GUID? - WoWInterface
Thread Tools Display Modes
01-10-22, 04:23 PM   #1
Chr0nicxHack3r
A Deviate Faerie Dragon
 
Chr0nicxHack3r's Avatar
Join Date: Jan 2021
Posts: 11
Send addon message based on GUID?

Hello everyone! I am currently working on yet another call out addon. The problem I am having is that with my addon who ever in the raid/group has it and the settings on will make the call out. I am looking to make it so only 1 person does this call out.

I am new to all of this and would love some help! The process I am thinking that I can get it work would be like:
1. Get GUID of raid/group members
2. Determine lowest or highest GUID
3. Determined GUID makes call out

The biggest issue is this is far out of what I am capable of and been cracking at this for weeks. Would love some help in the right direction or some pointers to really get me going. I use Wowpedia for a reference on mostly what I am trying to do.

If easier I am more than happy to try an identify one person by something else if GUID is complicated, Such as taking that character name and using it alphabetically?

Last edited by Chr0nicxHack3r : 01-10-22 at 11:50 PM.
  Reply With Quote
01-10-22, 04:46 PM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,306
Assuming addon should respect individual player options, ie if the player has disabled announces or has them routed to their local chatframe as an example they shouldn't announce.

What I'd do is.
1. Monitor GROUP_JOINED GROUP_FORMED and GROUP_LEFT events.
2. When your addon detects that you joined a group (check with IsInGroup) it sends a single SendAddonMessage with distribution RAID (this will automatically go to PARTY if you are in a 5man) that essentially says "hey I have calloutAddon with announces on" C_ChatInfo.SendAddonMessage("calloutPrefix", "yourversion;announcestatus", "RAID")
3. You also send this message if you are in a group and you changed your announce option from ON to OFF or vice versa)
4. You also register your prefix to receive messages from other instances of your addon. Any time you receive a message from another player in your group, you update a table with players having your addon with announce "on".
5. You sort that table alphabetically. Any instance of the addon does a simple check "am I the player that's first on the list?" If yes > call out. If not > mute.
6. Each instance of the addon also monitors for players leaving the group. If it was one of those in the group announce list, they get removed.

That would limit addon messages significantly, while still letting each instance of the addon decide on its own if it should call out or not, without constant traffic.
  Reply With Quote
01-10-22, 04:56 PM   #3
Chr0nicxHack3r
A Deviate Faerie Dragon
 
Chr0nicxHack3r's Avatar
Join Date: Jan 2021
Posts: 11
Originally Posted by Dridzt View Post
Assuming addon should respect individual player options, ie if the player has disabled announces or has them routed to their local chatframe as an example they shouldn't announce.

What I'd do is.
1. Monitor GROUP_JOINED GROUP_FORMED and GROUP_LEFT events.
2. When your addon detects that you joined a group (check with IsInGroup) it sends a single SendAddonMessage with distribution RAID (this will automatically go to PARTY if you are in a 5man) that essentially says "hey I have calloutAddon with announces on" C_ChatInfo.SendAddonMessage("calloutPrefix", "yourversion;announcestatus", "RAID")
3. You also send this message if you are in a group and you changed your announce option from ON to OFF or vice versa)
4. You also register your prefix to receive messages from other instances of your addon. Any time you receive a message from another player in your group, you update a table with players having your addon with announce "on".
5. You sort that table alphabetically. Any instance of the addon does a simple check "am I the player that's first on the list?" If yes > call out. If not > mute.
6. Each instance of the addon also monitors for players leaving the group. If it was one of those in the group announce list, they get removed.

That would limit addon messages significantly, while still letting each instance of the addon decide on its own if it should call out or not, without constant traffic.

Thank you so much for the quick response. I will do some digging and play around more with this info!!!

Last edited by Chr0nicxHack3r : 01-10-22 at 11:42 PM.
  Reply With Quote
01-11-22, 05:04 AM   #4
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,306
If you are very new to programming / writing addons this might be too complex a project to be your first one.

Doesn't mean you can't do it but you'd need to familiarize with basic addon concepts, .toc and file structure, registering for and responding to game events etc.

Perhaps this https://wowpedia.fandom.com/wiki/HOWTOs could be a starting point.
  Reply With Quote
01-11-22, 07:01 AM   #5
Chr0nicxHack3r
A Deviate Faerie Dragon
 
Chr0nicxHack3r's Avatar
Join Date: Jan 2021
Posts: 11
Originally Posted by Dridzt View Post
If you are very new to programming / writing addons this might be too complex a project to be your first one.

Doesn't mean you can't do it but you'd need to familiarize with basic addon concepts, .toc and file structure, registering for and responding to game events etc.

Perhaps this https://wowpedia.fandom.com/wiki/HOWTOs could be a starting point.
Awesome thank you so much! I have managed to get most of it done except creating the table, sorting it and then updating it. I am sure I will get there eventually but this was definitely a big step in the right direction!
  Reply With Quote
01-13-22, 06:34 PM   #6
Chr0nicxHack3r
A Deviate Faerie Dragon
 
Chr0nicxHack3r's Avatar
Join Date: Jan 2021
Posts: 11
I have been making some great progress thank you so much Dridzt for getting me going in the right direction! Being new with tables, how would I go about searching the table list that was generated to see who is first found? Or if I identify a certain setting and then find first in the list with said setting enabled? I would think it would be something like

Lua Code:
  1. if "saidsetting" == true and (first person in table with setting) then
  2. --code here
  3. end

Or I just thought, would it be easier to rework it and have the table build with only people that have said settings on and then just take the top person?

Last edited by Chr0nicxHack3r : 01-13-22 at 08:01 PM.
  Reply With Quote
01-14-22, 10:10 AM   #7
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,306
That would indeed be the simplest way.

Lua tables come in 2 varieties, array style tables where you have a sequential list of values with an implicit numeric key (these can be easily sorted using table.sort) and hash style tables where keys are arbitrary (don't have to be sequential numbers)

Both have their uses and are better to use in different scenarios.

An array style table has the form of
Code:
{"oranges", "apples", "kiwis"}
which is equivalent to
Code:
{[1]="oranges", [2]="apples", [3]="kiwis"}
where we've done nothing more than show the implicit key part of the [key]=value pairs of the table.

The downside of an array style table is that while it is very easy to add new items simply
Code:
table.insert(mytable,item)
and it is also very easy to sort them in-place simply
Code:
table.sort(mytable)
you need to write code that traverses the whole table to find if an item is already present and its key or index if you wanted to remove said item with
Code:
table.remove(mytable, index)
What you would likely want to do is write some code that finds and returns the index of a specific item (player name in your case) in your table so you do not add duplicates and more importantly you can remove players that left the group (or turned their announcing option OFF)

Then when you get a message from a player that joined the group or turned their announce ON you'd simply.
1. Check they're not already in your table.
2. Add them with table.insert
3. Sort the table alphabetically with table.sort
4. Pick mytable[1] (the first element) as the one that announces.

Since your table only contains players with the addon and announce option ON there's no further communication needed (inter-addon messages) each instance of the addon in the group can decide who should announce and do it or mute itself.

You do the opposite if a player leaves or turns their announce to OFF (and sends other instances of the addon in the group a message saying so)
1. Check if they were already in your table with your function that returns their index.
2. Remove them with table.remove(mytable, index)
3. Resort the remaining entries.
4. Pick mytable[1] again as the announcer.

Last edited by Dridzt : 01-14-22 at 04:33 PM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Send addon message based on GUID?

Thread Tools
Display Modes

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