Hi,
I have developed Clan System in my game and I have coded everything on server-side to make it more secure and I have used ListMembership function in which Title is the admin and using this function I am listing all the available or created groups to my players.
here's my server side code:
handlers.getAllGroupsList = function(args,context){ var groupMembersList = entity.ListMembership({ Entity:{ Id: args.Id, Type: "title", TypeString: "title" } }); return groupMembersList; }; handlers.checkIfGroupMember = function(args,context){ var checkMemberRequest = { "Group": { "Id": args.groupID }, "Entity":{ "Id": args.userID, "Type": "title_player_account", "TypeString": "title_player_account" } }; var response = entity.IsMember(checkMemberRequest); return response; };
The next step I am doing is to show the users if they are part of the group or not? So I used IsMember function and it returns the value on which I modify my UI/UX
Now when I am doing this on client side using a loop in which I call my function against each groupID and check if the current player is the member or not.
here's my client side code:
public void ShowAvailableClans() { ObjectUtilities.Instance.DeleteAllInstantiatedObjects(clanPrefabList); StartCoroutine(ShowClanAsync()); } private IEnumerator ShowClanAsync() { Home.Instance.BlurCanvasForBlocking(true); PlayfabClan.Instance.GetAllGroupsList(); yield return new WaitUntil(() => PlayfabClan.Instance.requestCompleted == true); for(int i = 0; i < PlayfabClan.Instance.myGroups.Groups.Count; i++) { int index = i; GameObject temp = Instantiate(joinClanPrefab, joinClanParent); clanPrefabList.Add(temp); temp.transform.GetChild(0).GetComponent<Text>().text = PlayfabClan.Instance.myGroups.Groups[index].GroupName; PlayfabClan.Instance.CheckGroupMembership(PlayfabClan.Instance.myGroups.Groups[index].Group.Id); yield return new WaitUntil(() => PlayfabClan.Instance.requestCompleted == true); if (PlayfabClan.Instance.groupMemberInfo.IsMember) { temp.transform.GetChild(1).GetComponentInChildren<Text>().text = "Leave"; Button button = temp.GetComponentInChildren<Button>(); button.onClick.RemoveAllListeners(); button.onClick.AddListener(() => LeaveGroup(PlayfabClan.Instance.myGroups.Groups[index].Group.Id)); } else { temp.transform.GetChild(1).GetComponentInChildren<Text>().text = "Join"; Button button = temp.GetComponentInChildren<Button>(); button.onClick.RemoveAllListeners(); button.onClick.AddListener(() => JoinGroup(PlayfabClan.Instance.myGroups.Groups[index].Group.Id)); } } Home.Instance.BlurCanvasForBlocking(false); StopCoroutine(ShowClanAsync()); }
Now it is a time taking process and I want to do something in which I send the list of groupID and it returns me the list of booleans indicating my player's membership in each group.