question

Terry Papamarkou avatar image
Terry Papamarkou asked

problem creating Entity group for clan system

Hi,

Just getting started with PlayFab and I've hit a problem trying to make an entity group for clan system in Unity. I've used this script as a starting point.

https://api.playfab.com/docs/tutorials/entities/entity-groups

When the user logs in I store their EntityKey

public static EntityKey entityKey;

and

private void OnLoginSuccess(LoginResult result)

    {


        PlayFabManager.entityKey = result.EntityToken.Entity;

I then try to create the group with this:

ClanManager.Instance.CreateGroup(clanNameInputField.text.Trim(), ClanManager.EntityKeyMaker(PlayFabManager.entityKey.Id));

but it throws this error

/Group/CreateGroup: No group profile found at DA1A084981581BD0

ClanManager:OnSharedError(PlayFabError)

I'm guessing it has something to do with using a PlayFab.ClientModels.EntityKey instead of a PlayFab.EntityModels.EntityKey but I'm really not sure.

Thanks in advance

entities
1 comment
10 |1200

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

Aniket Anil Bhosale avatar image Aniket Anil Bhosale commented ·

hello if u find the solution plz revert bank

0 Likes 0 ·

1 Answer

·
pfnathan avatar image
pfnathan answered

It seems like you are recreating the entity key as a group but you need to change few codes to work, you need to pass the User’s Entity Key:

On this part:

ClanManager.Instance.CreateGroup(clanNameInputField.text.Trim(), ClanManager.EntityKeyMaker(PlayFabManager.entityKey.Id));

Should be

ClanManager.Instance.CreateGroup(clanNameInputField.text.Trim(), PlayFabManager.entityKey);

What's happening is that you are taking an entity key like

{Type: title_player_account, Id: 12345} 

and making a new one that's

{Type: group, Id: 12345} 

and trying to use that as the admin of the group which is not going to work. So, if you are trying to create the group with the admin as the current logged in user

You can just pass null for the admin, by this way it'll use whoever is logged in if there is no value present

so you just need:

ClanManager.Instance.CreateGroup(clanNameInputField.text.Trim(), null);
4 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.

Terry Papamarkou avatar image Terry Papamarkou commented ·

Thanks pfnathan. However

ClanManager.Instance.CreateGroup(clanNameInputField.text.Trim(), PlayFabManager.entityKey);  

was the first thing I tried. It throws this error in Unity.

Argument `#2' cannot convert `PlayFab.ClientModels.EntityKey' expression to type `PlayFab.EntityModels.EntityKey'

I then tried

ClanManager.Instance.CreateGroup(clanNameInputField.text.Trim(), (PlayFab.EntityModels.EntityKey)PlayFabManager.entityKey);  

but that just threw much the same error.

Cannot convert type `PlayFab.ClientModels.EntityKey' to `PlayFab.EntityModels.EntityKey'

I'll try passing null now but I'd love to know why this isn't working.

Thanks

0 Likes 0 ·
pfnathan avatar image pfnathan ♦ commented ·

The client code returns an object called EntityKey, and it's namespaced as ClientModels.EntityKey. The Entity system accepts an object called EntityModels.EntityKey. They have identical fields, but they are not the same object according to C#. You have to copy the internal bits manually for now.

There was a post about discussing similar issue: https://community.playfab.com/questions/18867/using-entity-api.html

https://community.playfab.com/questions/18427/entities-and-groups-best-practice-for-obtaining-a.html

0 Likes 0 ·
Terry Papamarkou avatar image Terry Papamarkou pfnathan ♦ commented ·

Ok thanks again. Recreating the entity key seems to be working fine. I have some more questions but I'll do it as a new post.

0 Likes 0 ·
pfnathan avatar image pfnathan ♦ Terry Papamarkou commented ·

Thanks for the update.

0 Likes 0 ·

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.