Hey Everyone,
I am new to cloudscripting and i am in need of some assistance.
All of my Users get an playerdata with: "Key : Role" and it's value either (adventure, host, admin).
My idea is to have an cloudscript function "ChangeRole" that takes in 2 arguments, 1 playfabId and 1 newRole.
I want the script to check if the caller of this function has an role of admin, if it has, keep going and set the target playfabId with the new role... But i can't get an grip of why the cloudscript ain't returning the keyvalue...
handlers.ChangeRole = function (args, context) { // Cloud Script handles authenticating the player automatically. var UserRole; // here we are fetching the "SaveState" key from PlayFab, var playerData = playerData({"Role" : UserRole}); //var dataValue = GetUserReadOnlyDataResponse.Data["Role"].Value; if (playerData == "Admin") { log.info("Current player is an admin"); //Recieve target var inputTarget = null; if (args && args.hasOwnProperty("inputTarget")) inputTarget = args.inputTarget; //recieve targets new role var inputRole = null; if (args && args.hasOwnProperty("inputRole")) inputRole = args.inputRole; //var message = "Current user is an admin, change target: "; //log.debug("helloWorld:", { input: inputValue }); var result = server.UpdateUserReadOnlyData({"PlayFabId" : inputTarget, "Role" : inputRole, "Permission":"Public" }); } else { //var message = "Current user role is: "; log.info("Current player i not an admin!"); } return { messageValue: message }; };
I tried this to many time and now i ain't even recieving back an message to the unity editer...
I think the error is in the playerdata, as i don't fetch the value of the key "Role"....
Hope anyone can assist me in getting this to work.
Best regards an new hopeful PlayFab user