when populating a leaderboard with a GetLeaderboardDataRequest, i also check if the opponents in the leaderboard are online.
To do so i created an event which contain the following custom code:
//set the player id (sent with request by client) var playerId = Spark.getData().playerid; //will return true or false var player = Spark.loadPlayer(playerId) var online = player.isOnline(); //var state = Spark.getData().scriptData[online];
but i get the following response error message:
cannot read property "false" of undefined
False(or True) is the correct value i am expecting but i am not sure how to pass it as a bool value and then have a response without errors.
I don't see a boolean here that would be run except in online. What line is the debugger complaining about ? Step through it.
I solved changing:
var state = Spark.getData().scriptData[online];
I can now do a GetBoolean("isonline") and check its status in unity and the result is simply TRUE or FALSE.
Is this the right approach?
Yes, that is correct.