//Other classes should access any of these methods with the Try version of that method #region Character Creation public void TryCreateNewCharacter(string name, string playfabID, ushort clientID) { GrantCharacterToUserRequest grantCharacterToUserRequest = new GrantCharacterToUserRequest { CharacterName = name, CharacterType = "Basic", PlayFabId = playfabID }; PlayFabServerAPI.GrantCharacterToUser(grantCharacterToUserRequest, result => { PlayFabCharacterData newCharacterInitialData = CreateNewCharacterInitialData(playfabID, result.CharacterId, name); TrySaveCharacterData(newCharacterInitialData); }, error => { Debug.Log($"Error: Unable To Set Initial Character Data"); Debug.Log($"Error: {error.ErrorMessage}"); ServerManager.Instance.SendToClient(clientID, Tags.RegisterNewCharacterResponse, new RegisterNewCharacterResponseData(false)); }); }
private void GrantHeroToUser(string heroId, string heroName) { makingPlayFabRequest = true; GrantCharacterToUserRequest grantCharacterToUserRequest = new GrantCharacterToUserRequest() { CharacterName = heroName, ItemId = heroId }; PlayFabClientAPI.GrantCharacterToUser(grantCharacterToUserRequest, (result) => { Debug.Log("Granted Character (" + heroId + ") to player with the folloing details: "); Debug.Log("result.CharacterId: " + result.CharacterId); Debug.Log("result.CharacterType: " + result.CharacterType); if (result.CustomData != null) { Debug.Log("result.CustomData.ToString: " + result.CustomData.ToString()); } makingPlayFabRequest = false; }, (error) => { Debug.Log("Error adding character to player's charaxcter list (" + heroId + "): " + error.ErrorMessage); makingPlayFabRequest = false; }); }