So I'm trying to update character data after a player creates a character, but because it's server api I didn't wanna run it off the client since it's not secure. I wanted the cloudscript to set the new character's level upon creation and using the following code;
handlers.SetupNewChar = function(args, context) { var dat = {}; dat["Level"] = "1"; var request = new UpdateCharacterDataRequest() { PlayFabId = currentPlayerId, CharacterId = args.CHID, Data = dat }; var err = new PlayFabError(); var res = new UpdateCharacterDataResult(); server.GrantCharacterToUser(request, res, err); log.info("Creating Character: " + args.CHID + " for " + currentPlayerId); };
But every-time it runs it fails and I'm not sure what it is that's incorrect. At first I wasn't passing the details correctly and I realized I had to put a .5 second delay via yield in my code to await a response, not sure if I'm supposed to do it that way, but it's the only way I could get 2 requests to work back-to-back. Even after I see the char ID this is still failing, is it a syntax thing?