question

software1103 avatar image
software1103 asked

How to get the number of members in group

Hello, everyone.

I want to get the number of existing members in group, for this reason I use ListMembers().

But I don't get what I want to know.

So I want for you to teach me the resolution.

Here is my code.

    {	

	...

	ListMembers(joinedGroupID);
	
	...
    }

public void ListMembers(string groupId)
    {
        PlayFab.PlayFabGroupsAPI.ListGroupMembers(new ListGroupMembersRequest()
        {
            Group = EntityKeyMaker(groupId)
        },
        result =>
        {
            // this reflect the number of existing members in group.
            remainPlayer = result.Members.Count;
            Debug.Log("existing player number is " + remainPlayer);
        },
        error =>
        {
            Debug.Log(" In List Members() call the error is occured. ");
        });
    }

I want your help. Thanks.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
JayZuo avatar image
JayZuo answered

If you look at ListGroupMembers, you will find that Members is a list of EntityMemberRole. So when you use result.Members.Count you are actually getting the count of roles in the group. To get the number of existing players in the group, you can use the following code:

result =>
{
    var remainPlayer = 0;

    foreach (var role in result.Members)
    {
        remainPlayer += role.Members.Count;
    }

    Debug.Log("existing player number is " + remainPlayer);
},
16 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

software1103 avatar image software1103 commented ·

Hi, @JayZuo

Thank you very and very much for your attention.

Anyway you are the uppermost for me. I really appreciate your kind and help.

But I have now issue, great issue. I don't know why my unity does not interact with the playfab title. Yesterday, this worked very well. But now, this does not work.

Would you say the reason to me?

I am sorry to ask only questions continuously.

Thanks.

0 Likes 0 ·
software1103 avatar image software1103 software1103 commented ·

In addition, would you say the method to delete the my titles in detail?

In former, I used to click the gear icon to delete the title, but now some titles don't show the gear icons. I don't know how these titles are able to be deleted.

thanks @JayZuo

0 Likes 0 ·
JayZuo avatar image JayZuo ♦ software1103 commented ·

What do you mean "unity does not interact with the playfab title"? What's the error you are getting? Besides, I'd suggest using Unity Editor Extensions in Unity.

0 Likes 0 ·
software1103 avatar image software1103 JayZuo ♦ commented ·

Thanks for your quick reply, but I am late. I am sorry about that.

What I mean is that new user registered by the client side(this is made by unity) isn't being displayed on users table of "player" window in game manager of playfab.

I don't know where the user being registered newly is stored in.

I think this is strange. This is the first time for me.

In this step, there isn't the special error, so I don't know the reason of my problem.

Help me, Mr @JayZuo. Thanks.

0 Likes 0 ·
Show more comments
Show more comments
JayZuo avatar image JayZuo ♦ software1103 commented ·

Please share your error details and make sure you are giving the right groupId.

0 Likes 0 ·
software1103 avatar image software1103 JayZuo ♦ commented ·
 In List Members() call the error is occured. 
UnityEngine.Debug:Log(Object)
RoomGroupManager:<ListMembers>m__1(PlayFabError) (at Assets/Scripts/PlayfabScripts/RoomGroupManager.cs:77)
PlayFab.Internal.<MakeApiCall>c__AnonStorey2:<>m__0(String) (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabWWW.cs:187)
PlayFab.Internal.<PostPlayFabApiCall>c__Iterator1:MoveNext() (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabWWW.cs:250)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

****
RoomGroupManager.cs:77: Debug.Log(" In List Members() call the error is occured. ");

The correct group ID is inserted into "string groupId". I make sure this.

But this error like above occurs continuously. Would you say the reason to me?

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.