question

helloza123 avatar image
helloza123 asked

Is there any ways to get entity id from cloud scripts?

Hello, I've tried to create a guild system but want to do it mostly from server side instead of from client API but I encountered a problem that when I tried to create a group in server side, it keep adding title entity instead, so I need to specify the entity type to title_player_account with its id. However, it seems that I need to use entity id of the specific player in this as well and as I know in the docs

https://docs.microsoft.com/en-us/gaming/playfab/features/data/entities/available-built-in-entity-types

It said I can get entity id via LoginResult.EntityToken.Entity.Id or GetEntityTokenResponse.Entity.Id so the question is can I get entity id from cloud script directly.

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

·
Xiao Zha avatar image
Xiao Zha answered

Entity API CreateGroup can designate the group creator manually via defining the Entity field. You can refer to the API references and the following code. And you should using ExcuteEntityCloudScripts API instead of ExcuteCloudScripts API on client, which will pass though caller entity profile information to the function context.

handlers.createGroup=function(args,context){ 
var entityProfile = context.currentEntity;
var result= entity.CreateGroup({          
	Entity:entityProfile.Entity,       
	GroupName: "Test0"
});
}
10 |1200

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

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.