question

Josh Hughes avatar image
Josh Hughes asked

GetUserInternalData response not comparing correctly

I've managed to store + retrieve data to the Player's internal data store ['LastTimeStamp']

However when I try to do a simple comparison from a value passed in via args (args.timestamp which is the DateTime.UTCNow.Ticks from Unity) it always returns false.

I print out the value of lastTimeStamp, but it appears to be of a USerDataRecord object (IE with the 'Value' etc) not sure if that would affect hte comparison?

For instance;

    var lastTimestamp = 0;
    if(!lastTimestampData.Data.hasOwnProperty("LastUpdateTimeStamp"))
    {
        log.debug("Did not find last time stamp in internal data.", {internalData:lastTimestampData});
            return { "Response":"400", "Message":"Could not get internal data." };
    }
    else
    {
        lastTimestamp  =  lastTimestampData.Data.LastUpdateTimeStamp;
    }

    if(lastTimestamp != null)
    {
        log.debug("Last Time Stamp found.", { ServerLastTimeStamp:lastTimestamp, newTimeStamp:timestamp});


	// FAILS HERE ALWAYS
	// Example of a comparison my last execution ran is:
	//	if(63754182047230.64 > 63754174910060.11)
	
        if(lastTimestamp > timestamp)
        {
	}
    }

CloudScript
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Josh Hughes avatar image Josh Hughes commented ·

To clarify, I also have a log inside the final If statement that is not being called. I've also changed the '>' to '!=' and that works, but the greater than comparison does not work

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Josh Hughes commented ·

Will you print out the variable types of lastTimestamp and timestamp? Are you implementing this feature in Azure Function?

0 Likes 0 ·

1 Answer

·
Josh Hughes avatar image
Josh Hughes answered

I had to cast it to a 'Number()' type and also access the 'Value' property on the object itself

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.