Thread Tools Display Modes
01/02/15, 07:43 AM   #1
Sonar
Join Date: May 2014
Posts: 9
Is there event notification when I join a group?

Hi, I tried to write a simple addon which would have a function to callback when I join a new group. The callback function would check all the members of the group and report if any of them is on my Ignore list.

I tried this, but it wasn't called back when I joined the group:

Code:
local function CheckGroupMemberJoined(eventCode, memberName)

	d("dbg: EVENT_GROUP_MEMBER_JOINED: " .. memberName)

	if IsIgnored(memberName) then
		d("Warning: Group member " .. memberName " is on Ignored list.")
	end
end

EVENT_MANAGER:RegisterForEvent("AvoidIgnored", EVENT_GROUP_MEMBER_JOINED, CheckGroupMemberJoined)
How would you go about it? Thank you.
  Reply With Quote
01/02/15, 08:06 AM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
I'd use event EVENT_UNIT_CREATED:

Lua Code:
  1. local function OnUnitCreated(_, unitTag)
  2.     if ZO_Group_IsGroupUnitTag(unitTag) and IsUnitIgnored(unitTag) then
  3.         d(zo_strformat("Warning: Group member <<C:1>> is on Ignored list.", GetUnitName(unitTag)))
  4.     end
  5. end
  6.  
  7. EVENT_MANAGER:RegisterForEvent("AvoidIgnored", EVENT_UNIT_CREATED, OnUnitCreated)

Last edited by Garkin : 01/02/15 at 08:10 AM.
  Reply With Quote
01/02/15, 08:23 AM   #3
Sonar
Join Date: May 2014
Posts: 9
Thanks - it works!
  Reply With Quote
01/02/15, 08:30 AM   #4
Sonar
Join Date: May 2014
Posts: 9
Smile

And as the "OnUnitCreated" function is completely undocumented, and you obviously know it, may I ask you:

Is this event triggered when *I* join AND when a new player joins the group? Or just one of those? Thanks!
  Reply With Quote
01/02/15, 09:37 AM   #5
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Sonar View Post
And as the "OnUnitCreated" function is completely undocumented, and you obviously know it, may I ask you:

Is this event triggered when *I* join AND when a new player joins the group? Or just one of those? Thanks!
You have to test it, but I believe that it is triggered every time when there is a new unitTag available.

When you join the group, there will be new unitTag for each group member, so event will be triggered. And when new player joins the group, there will be new unitTag available for him, so this event should be triggered too.
  Reply With Quote
01/02/15, 12:04 PM   #6
Sonar
Join Date: May 2014
Posts: 9
Thanks a lot!
  Reply With Quote
01/02/15, 07:12 PM   #7
BornDownUnder
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 59
Post

Originally Posted by Sonar View Post
And as the "OnUnitCreated" function is completely undocumented, and you obviously know it, may I ask you:

Is this event triggered when *I* join AND when a new player joins the group? Or just one of those? Thanks!
It appears to be triggered every group unit creation, not specific to you or another group member, or group size.
  Reply With Quote
01/03/15, 05:18 PM   #8
Sonar
Join Date: May 2014
Posts: 9
I verified that it works for both cases. Thanks again!
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Is there event notification when I join a group?


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