Execute script when new user is registered
-
Hi,
I'd like to create a script that is executed when a new user is registered, to assign a random player name if one is not present (something like player12243534) but am struggling with the docs to see where / how I can do this?
Thanks
-
@JasonL Thanks, I ended up with this cloudCode:
isForceCreate = String(data.callingMessage.forceCreate) == "true"; isNewUser = String(data.message.newUser) == "true"; var response = {}; response.status = 200; response.data = data.message; if (isForceCreate && isNewUser) { var min = 10000000, max = 999999999 prefix = ["player", "user", "member"] const num = Math.floor(Math.random() * (max - min + 1)) + min; const pre = prefix[Math.floor(Math.random() * prefix.length)]; var defaultPlayerName = pre + String(num); var playerStateProxy = bridge.getPlayerStateServiceProxy(); // We are changing the player name on the server. playerStateProxy.updatePlayerName(defaultPlayerName); // And in this API Call's return data. response.data.playerName = pre + String(num); } response; //return the object
This works just the way I need