Just add that to the player's scriptData, and before committing the user to a challenge, check against player's scriptdata value.
Yes , i said that as na idea, but i dont'k know how to add Time to ScriptData and do the check with the ServerTime in cloudCode
Google results if you are stuck, there are plenty of threads here regarding Cloud code and MongoDB dates.
Hi Flavio,
You can set a date to a users scriptData with the following.
//set date Spark.getPlayer().setScriptData("date", new Date()) //retrieve it in Cloud Code Spark.getPlayer().getScriptData("date")
Then you can get the current time in Cloud Code with the following.
//get current time var currentTime = new Date().getTime()
So you'll be able to get the date stored on the player, then get the current time and do your comparison.
Regards,
Liam
Flávio Correia
Hi there!
Is it possible to create a timer variable to be part of player ScriptData maybe.
I want my user to be marked as "unChallengeable" for a certain amount of time after receiving a challenge request.
I also want it to be triggered as a CloudCode event, once again... i dont trust clientes eheh.
I was thinking of parsing the time on a challengeTimer.ScriptData and then compare ServerTime with challengeTimer when sending a challengeRequest, but i've searched documentation and can find any exemples.
Any help?