Sign In Register

How can we help you today?

Start a new topic
Answered

Set display name of another player

Hi,


I need to fill 'player' collection with bots. So I wrote an event script, which generates a set of players-bots. I run it from Test Harness.


Also I need to generate a specific display name for every bot. I used to apply ChangeUserDetailsRequest, and it worked fine if the real player was logging in.


But in case of 'programmatically' created bots, it doesn't work, because this request changes the display name of the currently signed in user, which is Test Harness user (the one I run GenerateBots() script from). So Test Harness user's name is changed every time new bot is created. Not bot's.


May I ask your advice how I can overcome this issue?


Best Answer

Hi Aleksey,


You can send requests as another player in cloud code provided you can access their playerId:


var req = new SparkRequests.AccountDetailsRequest();

var res = req.sendAs(anotherPlayerId);


Try this out and let us know how it works for you.


Regards,

Vinnie


Are you executing the ChangeUserDetailsRequest via SendAs function?


 

var req = new SparkRequests.ChangeUserDetailsRequest();

req.displayName = "newDisplayName";

req.SendAs("playerId")

 

As long as you pass in the playerId, you can execute requests on their behalf.


Hope this helps,

Omar

Answer

Hi Aleksey,


You can send requests as another player in cloud code provided you can access their playerId:


var req = new SparkRequests.AccountDetailsRequest();

var res = req.sendAs(anotherPlayerId);


Try this out and let us know how it works for you.


Regards,

Vinnie

I knew that must be be simple. I never used SendAs before and somehow forgot about its existence. Thank you!
Login to post a comment