Hi!
I wrote two cloudscript functions and I'm trying to call one function inside the other. But Cloudscript throws an error saying the function is not defined:
ERROR { "FunctionResult": null, "Logs": [], "ExecutionTimeSeconds": 0.0005269, "MemoryConsumedBytes": 5200, "APIRequestsIssued": 0, "HttpRequestsIssued": 0, "Error": { "Error": "JavascriptException", "Message": "JavascriptException", "StackTrace": "ReferenceError: getPlayerDataLastStatsUpdate is not defined\n at handlers.UpdateStatisticsDecay (15C82-main.js:172:16)\n at Object.invokeFunction (Script:116:33)" } }
But the function is definitely defined, just a bit further up:
handlers.getPlayerDataLastStatsUpdate = function () { var getPlayerInfo = server.GetUserData ({ PlayFabId: currentPlayerId, Keys: ["lastStatsUpdate"], }); if (getPlayerInfo.Data.lastStatsUpdate == null) { var now = (Date.now()/1000).toString(); var data = JSON.parse('{"lastStatsUpdate":"'+now+'"}'); UpdateUserData(data); var lastUpdate = now; } else { var lastUpdate = getPlayerInfo.Data.lastStatsUpdate.Value; } return lastUpdate; }
And I call it like this:
var then = getPlayerDataLastStatsUpdate();
What am I doing wrong to get the error?