Sign In Register

How can we help you today?

Start a new topic
Answered

How will I send multiple script msgs to my game?

 Hi suppose I have game which is published, now I want to create new messages , send it to user and in this process I want to create new ScriptMesgExtension and not want to sue existing one.


How will I do it ? Is it possible to send to end user?


Best Answer

Hi Rd,

If you want to send this new event from Unity, you will need to re-publish.

Otherwise you can set it up to run in cloud code.

Regards,

Oisin.


Hi Rd,

The ScriptMessage Extension allows you to create as many custom message templates as you wish.

In the GameSparks portal select Messages ,

 

then click on the ScriptMessage Extensions Tab.

 

Click the plus icon to add an extension. 


Now you can fill out your message template as per your requirements. This example is a simple new year’s gift for your users.

 

Now that our first custom template is ready, we can edit, delete or click the plus again to create an additional template.


Using this method you can create as many custom messages as you wish without the need to use existing ones.


The message can be triggered by through cloud code like:

    

Spark.sendMessageExt({"message" : "Happy new year "+ username},  //This overwrites your template message.
"add100Coins", //This is your custom script message extension.
Spark.loadPlayer(playerIdToSendTo); //This is the player you are sending it to.

 

Regards,

Oisin.

Hi Oisin,

Thanks for explaning in detail.Really appreciated.

Although,I do get the part of creating as much as Extension.

I am not geting my head on ,how we are suppose to call it in code (local) once the new extension gets created? Do I need to edit my local code too??

I have created on extension and called that event on my Unity.

Now for second extension what am I suppose to do? New event will get it done but I want same event to fetch new and old both extensions .Is that possible?

 

Hi Rd,

If I follow you correctly, I believe you want to locally filter separate messages in Unity so that they can be called from within a single event.

If this is the case you could use an if statement to filter between separate ExtCodes:


using GameSparks.Api.Messages;
 
public class MessageListen : MonoBehaviour
{
 
        public void Start()
        {
                GameSparks.Api.Messages.ScriptMessage.Listener += GetMessages;
        }
 
        public void GetMessages(ScriptMessage message)
        {
                if (message.ExtCode == "FirstScriptMessage")
                {
                        //Do some stuff
                }
 
                if (message.ExtCode == "SecondScriptMessage")
                {
                        //Do some other stuff
                }
        }
}

 
If you have have any further issues perhaps you could post the code you are working with or even mail me directly at: oisin.bourke@gamesparks.com

Thanks,

Oisin.

Hi,

Allow me to explaining you again.

here is what I am stuck at.

>I created ScriptExten
>Linked it with cloud code and local code
>Getting the script message properly in my game.

All okay?

I took that code ,publish the game.
Suppose Now I want to send script message.
I will go to Script msg and change the msg to whatever I want right? My users will get the msg as expected.

Now Suppose,game is publish ,I want to add new script msg and send it to my users.
How could this be done?
I do not want to change existing ScriptExtention.

Is that possible or I need to use first script Extention only to send new msg ?

You get my problem??

 

Hello there?

 

Answer

Hi Rd,

If you want to send this new event from Unity, you will need to re-publish.

Otherwise you can set it up to run in cloud code.

Regards,

Oisin.

Okay thanks...Appreciated...

 

@OiSin


 

Spark.sendMessageExt({"message" : "Happy new year "+ username},  //This overwrites your template message.
"add100Coins", //This is your custom script message extension.
Spark.loadPlayer(playerIdToSendTo); //This is the player you are sending it to.

 This doesn't seem to be true. Could you please confirm this?


{"message" : "Happy new year "+ username}  - >  this is NOT overwriting the message in the script message.