Sign In Register

How can we help you today?

Start a new topic

How to give device authen user currency?

Is there a way through test harness to give a user using device authentication currency?


I have looked through documentation and don't see any posts for it.  This seems like it would be something simple and commonly done, so I'm hoping that I am just not seeing how to do it.


There has to be someone who has ran into this same issue.  Isn't there anyone out there that has any idea how to do this?

Hi AlphaDog,


To add currency to a player who is currently logged into the test harness you can create a new log event that gives the currently logged in player some amount of currency.After you authenticate using device auth you can call this event in the test harness to award currency to the player.

//Gold is the currency short code

//500 is the amount we want to give the player

Spark.getPlayer().credit("Gold", 500);


You could also put this in the authentication response if you want a player who just authenticated to receive some currency. This can be done by checking if the auth was successful and if it was award the currency, else throw an error.


if(Spark.getData().error == null){

//authenticated successfully award money

Spark.getPlayer().credit("Gold", 500);

}else{

//there was an error log it and exit

Spark.getLog().debug("Error in auth response");
    Spark.exit();

}


Regards,

Garreth.

I should have worded it better.  I want to give 'another' player currency, not the one currently logged into.

I want to create a 'manager' app that can give out currency when needed.  What is the alternate syntax to the getPlayer() command that allows you to add gold to another user?

Hi AlphaDog,


With access to the target player's id you can do this via:


Spark.loadPlayer(playerId).credit("Gold", 500);


Regards,

Vinnie


1 person likes this

I will look into this then.  Thanks!

Login to post a comment