Hey!
Please help me make an Authentication CloudScript with game (I mean that the players using "Repeater" are not able to CALL CloudScript unlimited times)
I have something like this:
CloudScript:
handlers.SetCodeDeposit = function(context)
{ var previousState = {};
var getPlayerInfo = server.GetUserData ({ PlayFabId: currentPlayerId, Keys: ["Code"], });
if(getPlayerInfo.Data.hasOwnProperty("Code"))
{ previousState = getPlayerInfo.Data["Code"].Value; }
if(!getPlayerInfo.Data.hasOwnProperty("Code"))
{ var setPlayerInfo = server.UpdateUserData({ PlayFabId: currentPlayerId, Data: { ["Code"]:JSON.stringify(Math.floor(Math.random() * 1000000)) } });
var getPlayerInfo = server.GetUserData ({ PlayFabId: currentPlayerId, Keys: ["Code"], });
previousState = getPlayerInfo.Data["Code"].Value; }
return(((previousState * previousState) - 1337) * 3); }
In Unity C#:
code = Math.Sqrt((double.Parse(cloudResult.FunctionResult.ToString()) / 3) + 1337).ToString();
But it doesn't work (someone hacked and get "code" and was able to set a good code during CALL)
Please help me!!!