[Worked Out] iOS multiplayer -- how can I retrieve friend's alias when inviting a friend to play

When I start an auto-match, it’s okay not to know who might be my opponent (until another player joins in.)  Once another player joins in, this second player will receive the opponent’s alias and will know who s/he is playing against.

However, when I start a game by inviting a friend, it feels very odd that the app doesn’t know the alias of the friend.

Is there an API call I can use to retrieve the friend’s alias when inviting a friend to play?

I can retrieve the friend’s playerID via gameNetwork.participant, but the playerID would be meaningless to me even if the app tells me I’m playing against this particular playerID.  And, when I invited the friend, I’ve seen the friend’s alias on GC invite screen, so it’s natural to expect that the app would know the friend’s alias too.  

So… I’d really like to know how I may retrieve the friend’s alias along with the playerID.  (Otherwise, invite-game feels very strange.)

Naomi

You can try gamenetwork.request(“loadPlayers”).

@dchan, thank you so much for getting back to me.   The thing is, I’m not sure if I can get the friend’s playerID when I create a new game by inviting a friend.

When creating a game, I use:  gameNetwork.show(“createMatch”, { listener = roomListener, minPlayers = 2, maxPlayers = 2 })

This gives the users a chance to either start an auto-match or invite a friend to play a match.

As far as I am aware, the roomListener will return event.data.matchID and event.data.status – could it be that it also returns event.data.playerID (which, perhaps, includes all players invited to the match game?)  If it does, then I could use gamenetwork.request(“loadPlayers”) to fetch the friends’ alias, but otherwise, I wouldn’t be able to use “loadPlayer” API…

Naomi

Then in that case you would probably want to make your own screen which lists players that the player can invite or do an automatch game.

Got it.  Thanks, @dchan.  

BTW, unless I’m mistaken, the auto-match screen always provide options for inviting friends – or at least so it seems to me.  And when user chooses to invite a friend instead, I’d still not know the playerID or alias…

Is there an API call I could use that would launch an auto-match immediately without offering an option to invite a friend?

Naomi

Hi,

You can call do something like:

gameNetwork.request( “createMatch”,
{
    playerIDs = {},
    minPlayers = 2,
    maxPlayers = 3,
    listener=requestCallback
})

Since you don’t have any playerIDs in the table then it won’t try to invite anyone.

Ah, okay, thank you, @dchan.

Naomi

You can try gamenetwork.request(“loadPlayers”).

@dchan, thank you so much for getting back to me.   The thing is, I’m not sure if I can get the friend’s playerID when I create a new game by inviting a friend.

When creating a game, I use:  gameNetwork.show(“createMatch”, { listener = roomListener, minPlayers = 2, maxPlayers = 2 })

This gives the users a chance to either start an auto-match or invite a friend to play a match.

As far as I am aware, the roomListener will return event.data.matchID and event.data.status – could it be that it also returns event.data.playerID (which, perhaps, includes all players invited to the match game?)  If it does, then I could use gamenetwork.request(“loadPlayers”) to fetch the friends’ alias, but otherwise, I wouldn’t be able to use “loadPlayer” API…

Naomi

Then in that case you would probably want to make your own screen which lists players that the player can invite or do an automatch game.

Got it.  Thanks, @dchan.  

BTW, unless I’m mistaken, the auto-match screen always provide options for inviting friends – or at least so it seems to me.  And when user chooses to invite a friend instead, I’d still not know the playerID or alias…

Is there an API call I could use that would launch an auto-match immediately without offering an option to invite a friend?

Naomi

Hi,

You can call do something like:

gameNetwork.request( “createMatch”,
{
    playerIDs = {},
    minPlayers = 2,
    maxPlayers = 3,
    listener=requestCallback
})

Since you don’t have any playerIDs in the table then it won’t try to invite anyone.

Ah, okay, thank you, @dchan.

Naomi