Sign In Register

How can we help you today?

Start a new topic
Answered

Cloud script Spark.sendMessage deprecated.

When player has done something (call cloud script), other players should know what happen. So I use ScriptMessage.Listener. As you can see on the documentation, it said "See the Spark.sendMessage function...". So I found Spark.sendMessage documentation, it said "DEPRECATED use Spark.message(extCode)".


Previously, I can send back the json data to players via Spark.sendMessage() but now it deprecated. Spark.message() receive only exit code. So where should I put the json data.


My point is please update documentation. When new feature(s) release, please do update documentation.


Best Answer

 There was another API update. The current API call for sending messages is this...

var mess = Spark.message("messageShortCode");
mess.setPlayerIds(Spark.getPlayer().getPlayerId())
mess.send();


1 person has this question

Hey Nirut,

We are very sorry about this, and we are aware our documentation is lackin in certain areas. We are currently in the process of overhauling all our documentation, so please bear with us.

You can try using the following example for sending messages...

myPlayers= [];
myPlayers.push(Spark.getPlayer());
Spark.sendMessageExt({"one" : 1, "two": 2, "three": 3}, "myScriptMessage", myPlayers);

This example is for a script-message, but you should be able to adapt that for your own scipt-message, or sending another message by id the same way.

Thanks,
Sean

 

Hi Sean,


Thanks for your kind response. May I know why you suggest me to use deprecated function? or it will be not deprecated in the future?


Thanks,

Nirut

So does "sendMessageExt" still work?

Hey Nirut,

Sorry, i misunderstood. I thought your original question was where to put JSON data in the depreciated call.
My advice was just to show you that sendMessageExt does still work, and you can use this also.
Our API needs to be backwards compatible to older games, but unfortunately we have not updated that part of our documentation as of yet.
Thanks for pointing this out.

Sean

 

Answer

 There was another API update. The current API call for sending messages is this...

var mess = Spark.message("messageShortCode");
mess.setPlayerIds(Spark.getPlayer().getPlayerId())
mess.send();

Login to post a comment