Sign In Register

How can we help you today?

Start a new topic
Answered

Sending Message Help

Hi there,


I've tried various solutions from the forum, but have a question...


I set up "ScriptMessage Extensions" test message.  I then put the following in a sendTest message cloud script...


Spark.sendMessageExt({"test" : "test"},

    "test", 

    "1");


where "1" is the username I'm sending it to.


Here is what I have on the receiving end in c#...


void Start () {

        // time to hook in the Gamesparks message listener

        GameSparks.Api.Messages.ScriptMessage.Listener += GetMessages;

}


public void GetMessages(GameSparks.Api.Messages.ScriptMessage message)

    {

        if (message.ExtCode == "test")

        {

            Debug.Log("Got message " + message.Title);

        }

    }


When I go into the test harness, I log in as another user, then run the logEvent script.  Each time I do, it pops up a windows showing the cloud code and telling me it isn't working.


Any ideas?


Best Answer

Hi Phillip,


The 'sendMessageExt' function doesn't take a username as it's third parameter, it needs either a SparkPlayer or an array of SparkPlayers. You can obtain these using the target player's id - var player = Spark.loadPlayer(playerId)


What error are you seeing in the Test Harness debugger?


Regards,

Vinnie

1 Comment

Answer

Hi Phillip,


The 'sendMessageExt' function doesn't take a username as it's third parameter, it needs either a SparkPlayer or an array of SparkPlayers. You can obtain these using the target player's id - var player = Spark.loadPlayer(playerId)


What error are you seeing in the Test Harness debugger?


Regards,

Vinnie

Login to post a comment