What I'm trying to do is create a new character in playfab ! I created a cloud script in Azure called CreateCharacter and if i calle it directly by code it works fine ! Then i create a Cloud script in Playfab called CreateCharacter, type HTTP and connected with the link to the Azure one.
This is the Azure Script :
module.exports = async function (context, req) {
// Checks if characterName and PlayFabId parameters are present in the request
if ((req.query.characterName || (req.body && req.body.characterName)) && (req.query.playFabId || (req.body && req.body.playFabId))) {
// Extract the characterName and PlayFabId values from the request
const characterName = req.query.characterName || (req.body && req.body.characterName);
const playFabId = req.query.playFabId || (req.body && req.body.playFabId);
// After successfully creating the character, return a successful response
context.res = {
status: 200,
body: { success: `Personaggio ${characterName} successfully created for PlayFabId ${playFabId}.` }
};
} else {
// If the characterName and playFabId parameters are not provided, return an error response
context.res = {
status: 400,
body: { error: 'Parameters characterName e playFabId missing. Be sure to provide a character name and your PlayFabId.' }
};
}
};
Now that's my client side code :
createCharacterButton.GetComponent<Button>().onClick.AddListener(() => CreateNewCharacter(characterName, playFabId));
private void CreateNewCharacter(string characterName, string playFabId)
{
if (PlayFabClientAPI.IsClientLoggedIn())
{
CreateCharacterParameters functionParameters = new CreateCharacterParameters
{
characterName = nomepersonaggio,
playFabId = MyPlayFabID
// these parameters work well so far
};
PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
{
FunctionName = "CreateCharacter",
FunctionParameter = functionParameters,
},
OnCharacterCreation, OnCharacterCreationError);
}
else
{
// manage unauthenticated player
Debug.LogError("unauthenticated player.");
}
}
private void OnCharacterCreation(ExecuteCloudScriptResult result)
{
if (result.Error != null)
{
Debug.LogError("Error character creation " + result.Error.Message);
}
the error falls in the first if (if (result.Error != null)) No function named CreateCharacter was found to execute. Actually i'm using only using PlayFab.ClientModels; but no using PlayFab.CloudScriptModels; Could this be the reason for the error?