Sign In Register

How can we help you today?

Start a new topic

Timer Variable in ChallengeRequests

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?

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

You can assign cloud code Date() directly to the field.

 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


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.



Login to post a comment