I know this has been discussed before but i still don't get it.
I have a usercollection that stores displaynames...
If the player changes his displayname with ChangeUserDetailsRequest.
That works fine as expected and the displayname gets updated to the new name.
The trouble is updating the usercollection that stores the displaynames too.
I know this should be a simple task but i can't get it to work.
Here is my cloudcode event:
// ====================================================================================================
//
// Cloud Code for change_name, write your code here to customise the GameSparks platform.
//
// For details of the GameSparks Cloud Code API see https://portal.gamesparks.net/docs.htm
//
// ====================================================================================================
//load the displayNames collection
var displayNameCol = Spark.runtimeCollection("playerList")
// we get the new displayname input from Unity
var playerName = Spark.getData()._name;
// we get the old displayname input from Unity
var playerNameOld = Spark.getData()._oldname;
//find the old displaname...
var displayNameCheck = displayNameCol.findOne({"displayName":playerNameOld})
//if it's not the collection, proceed as normal
if(displayNameCheck === null){
// do nothing
}
else{
displayNameCheck = playerName;
Spark.runtimeCollection("playerList").update({"displayName":playerName}, {"$set":displayNameCheck}, true, false);
// this is most likely wrong
}
ward dewaele
I know this has been discussed before but i still don't get it.
I have a usercollection that stores displaynames...
If the player changes his displayname with ChangeUserDetailsRequest.
That works fine as expected and the displayname gets updated to the new name.
The trouble is updating the usercollection that stores the displaynames too.
I know this should be a simple task but i can't get it to work.
Here is my cloudcode event:
Help is appriciated.