Hello,
I'm trying to add an Economy v2 item to a player inventory when the player is created. For testing purposes I set up a PlayerStream rule to execute the function when a com.playfab.player_logged_in event occur and I'm getting a ProfileDoesNotExist error message. The player profile definitely exists, so I guess the message is not really about the player profile.
This is the code for the function: public static class setupPlayer { [FunctionName("setupPlayer")] public static async Task<dynamic> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { PlayerPlayStreamFunctionExecutionContext<dynamic> context = JsonConvert.DeserializeObject<PlayerPlayStreamFunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync());
PlayFabSettings.staticSettings.TitleId = "my-title-id";
PlayFabSettings.staticSettings.DeveloperSecretKey = "my-secret-key";
var titleEntityResponse = await PlayFabAuthenticationAPI.GetEntityTokenAsync(new GetEntityTokenRequest());
if (titleEntityResponse.Result != null)
{
var addItemResponse = await PlayFabEconomyAPI.AddInventoryItemsAsync(new AddInventoryItemsRequest() {
Entity = new PlayFab.EconomyModels.EntityKey() {
Type = "title_player_account",
Id = context.PlayerProfile.PlayerId
},
Amount = 100,
Item = new InventoryItemReference() {
Id = "my-economy-v2-item-id"
}
});
if(addItemResponse.Result != null) {
log.LogInformation("addPawsResponse Result is not null");
} else {
log.LogInformation("addPawsResponse Result is null");
log.LogInformation(addItemResponse.Error.ErrorMessage);
}
}
var message = $"Hello {context.PlayerProfile.PlayerId}!";
log.LogInformation(message);
return new { messageValue = message };
}
}
I'm currently stuck, any help is welcome! Thank you.