Hello everyone,
I am new to cloudscripting, and I just want to ask a basic question to learn most things. I put comment lines starting with "QUESTION" in the code. If someone can fill those gaps, I think, I can learn the most basic things.
Here's what I am trying to do: I will get an integer and a string value from the client. On the server side, I will increase the integer value and change the string value. Afterwards, I will return the new values to the client. The code doesn't make any sense; however, it will help me a lot if I can fill these gaps.
Unity C# code:
public void APICallExample() { int i = 5; string s = "How are you?"; ExecuteCloudScriptRequest request = new ExecuteCloudScriptRequest() { FunctionName = "Example", FunctionParameter = // QUESTION: How can I send those 2 parameters (i and s) to the server? }; PlayFabClientAPI.ExecuteCloudScript(request, OnSuccess, OnFail); } public void OnSuccess(ExecuteCloudScriptResult result) { // QUESTION: How can I read the parameters from the result? } public void OnFail(PlayFabError error) { // Print message }
Cloudscript:
handlers.Example = function (args) { // QUESTION: Is this correct way to check if the parameters "i" and "s" are null? if(args && args.i && args.s) { // QUESTION: How can I return constant int value and string value (0 and "WrongParameter") ? // return 0 and "WrongParameter" ? } // QUESTION: Is this correct way to read parameters? var i = args.i; ++i; var s = args.s; if(s == "How are you?") { s = "I'm fine"; } else { s = "What do you mean?"; } // QUESTION: How can I return i and s ? // return i and s ? };<br>