Hi,
I've met a issue trying to make an entity group for guild system in Unity.
I've seen and used this script as my starting point.
https://api.playfab.com/docs/tutorials/entities/entity-groups
And I've read this data being similar to my issue.
https://community.playfab.com/questions/19351/problem-creating-entity-group-for-clan-system.html.
But this doesn't seem like correct resolution for my case, so I want your great help.
When clicking the CreateRoom Button, I'm gonna store user entity key but I fail now.
... using PlayFab.ClientModels; ... public void OnClickCreateRoom() { ... PlayFab.GroupsModels.EntityKey enkey = new PlayFab.GroupsModels.EntityKey { Id = "123" + RoomCreate.Instance.roomName.GetComponent<TMP_InputField>().text.Trim(), Type = "group" }; GuildController.CreateGroup(RoomCreate.Instance.roomName.GetComponent<TMP_InputField>().text.Trim(), enkey); } ...
Follow script is GuildController script that I modified my starting point script.
using PlayFab.GroupsModels; using System; using System.Collections.Generic; using UnityEngine; [Serializable] public class GuildController { public static readonly HashSet<KeyValuePair<string, string>> EntityGroupPairs = new HashSet<KeyValuePair<string, string>>(); public static readonly Dictionary<string, string> GroupNameById = new Dictionary<string, string>(); public static EntityKey EntityKeyMaker(string entityId) { return new EntityKey { Id = entityId, Type = "title_player_account" }; } private static void OnSharedError(PlayFab.PlayFabError error) { Debug.LogError(error.GenerateErrorReport()); } public void ListGroups(EntityKey entityKey) { var request = new ListMembershipRequest { Entity = entityKey }; PlayFab.PlayFabGroupsAPI.ListMembership(request, OnListGroups, OnSharedError); } private void OnListGroups(ListMembershipResponse result) { var prevRequest = (ListMembershipRequest)result.Request; foreach (var pair in result.Groups) { GroupNameById[pair.Group.Id] = pair.GroupName; EntityGroupPairs.Add(new KeyValuePair<string, string>(prevRequest.Entity.Id, pair.Group.Id)); } } public static void CreateGroup(string groupName, EntityKey entityKey) { // A player-controlled entity creates a new group var request = new CreateGroupRequest { GroupName = groupName, Entity = entityKey }; PlayFab.PlayFabGroupsAPI.CreateGroup(request, OnCreateGroup, OnSharedError); } private static void OnCreateGroup(CreateGroupResponse result) { Debug.Log("Group Created: " + result.GroupName + " - " + result.Group.Id); var prevRequest = (CreateGroupRequest)result.Request; EntityGroupPairs.Add(new KeyValuePair<string, string>(prevRequest.Entity.Id, result.Group.Id)); GroupNameById[result.Group.Id] = result.GroupName; } public void DeleteGroup(string groupId) { var request = new DeleteGroupRequest { Group = EntityKeyMaker(groupId) }; PlayFab.PlayFabGroupsAPI.DeleteGroup(request, OnDeleteGroup, OnSharedError); } private void OnDeleteGroup(EmptyResponse result) { var prevRequest = (DeleteGroupRequest)result.Request; Debug.Log("Group Deleted: " + prevRequest.Group.Id); var temp = new HashSet<KeyValuePair<string, string>>(); foreach (var each in EntityGroupPairs) if (each.Value != prevRequest.Group.Id) temp.Add(each); EntityGroupPairs.IntersectWith(temp); GroupNameById.Remove(prevRequest.Group.Id); } public void InviteToGroup(string groupId, EntityKey entityKey) { // A player-controlled entity invites another player-controlled entity to an existing group var request = new InviteToGroupRequest { Group = EntityKeyMaker(groupId), Entity = entityKey }; PlayFab.PlayFabGroupsAPI.InviteToGroup(request, OnInvite, OnSharedError); } public void OnInvite(InviteToGroupResponse result) { var prevRequest = (InviteToGroupRequest)result.Request; var request = new AcceptGroupInvitationRequest { Group = EntityKeyMaker(prevRequest.Group.Id), Entity = prevRequest.Entity }; PlayFab.PlayFabGroupsAPI.AcceptGroupInvitation(request, OnAcceptInvite, OnSharedError); } public void OnAcceptInvite(EmptyResponse result) { var prevRequest = (AcceptGroupInvitationRequest)result.Request; Debug.Log("Entity Added to Group: " + prevRequest.Entity.Id + " to " + prevRequest.Group.Id); EntityGroupPairs.Add(new KeyValuePair<string, string>(prevRequest.Entity.Id, prevRequest.Group.Id)); } public void ApplyToGroup(string groupId, EntityKey entityKey) { var request = new ApplyToGroupRequest { Group = EntityKeyMaker(groupId), Entity = entityKey }; PlayFab.PlayFabGroupsAPI.ApplyToGroup(request, OnApply, OnSharedError); } public void OnApply(ApplyToGroupResponse result) { var prevRequest = (ApplyToGroupRequest)result.Request; var request = new AcceptGroupApplicationRequest { Group = prevRequest.Group, Entity = prevRequest.Entity }; PlayFab.PlayFabGroupsAPI.AcceptGroupApplication(request, OnAcceptApplication, OnSharedError); } public void OnAcceptApplication(EmptyResponse result) { var prevRequest = (AcceptGroupApplicationRequest)result.Request; Debug.Log("Entity Added to Group: " + prevRequest.Entity.Id + " to " + prevRequest.Group.Id); } public void KickMember(string groupId, EntityKey entityKey) { var request = new RemoveMembersRequest { Group = EntityKeyMaker(groupId), Members = new List<EntityKey> { entityKey } }; PlayFab.PlayFabGroupsAPI.RemoveMembers(request, OnKickMembers, OnSharedError); } private void OnKickMembers(EmptyResponse result) { var prevRequest = (RemoveMembersRequest)result.Request; Debug.Log("Entity kicked from Group: " + prevRequest.Members[0].Id + " to " + prevRequest.Group.Id); EntityGroupPairs.Remove(new KeyValuePair<string, string>(prevRequest.Members[0].Id, prevRequest.Group.Id)); } }
But this error occurs like follow.
/Group/CreateGroup: No group profile found at 123wer
I want your help. Thanks.