[GPGS] Return the Value of [event.playerIds] with showSelectPlayers Function

Here is my code:
 
 
 

local function waitRoom(event)                    if event.isError then      native.showAlert(event.errorCode, event.errorMessage, {"OK"})    else        native.showAlert("PlayerIds", {event.playerId[1], event.playerId[2]}, {"OK"})    end end    gpgs.multiplayer.realtime.showSelectPlayers({minPlayers = 1, maxPlayers = 1, listener = waitRoom} )

The red line is my problem, I don’t know if I got it correctly whenever I’m trying to generate the playerIds of the participants, it’s not showing the alert box.

I do know that the function is working since I already tried replacing the event.playerIds with event.name and it returned alert box “showSelectPlayers” right after I chose players from Google Play Dialog Box and hitting “PLAY” .

Only I don’t know how to format the array of playerIds. I am trying to add 1 player in addition to my device, total of 2 players.

PS: The google play option for 

Hi @rhaineyensid,

The correct event property is playerId s (plural), not singular as you have in your code. Please see here:

https://docs.coronalabs.com/plugin/gpgs/multiplayer/realtime/event/showSelectPlayers/playerIds.html

Best regards,

Brent

hi brent, I already tried playerIds but with different syntax. so to clarify, this correction will work:

native.showAlert(“PlayerIds”, {event.playerIds[1], event.playerIds[2]}, {“OK”})
end

I just thought maybe i can try making each elements, singular that’s why.

still not working for me brent, can you provide a sample line of code with alert box displaying the playerIds (mine and other player). assuming this line of code is already within the function…(event)

Hi @rhaineyensid,

So you want the IDs to be in the “message” part of the alert box? If so, you need to make that parameter into a string as outlined in the docs:

https://docs.coronalabs.com/api/library/native/showAlert.html

So it might look like this:

[lua]

native.showAlert( “PlayerIds”, event.playerIds[1]…", "…event.playerIds[2], {“OK”} )

[/lua]

Hi @rhaineyensid,

The correct event property is playerId s (plural), not singular as you have in your code. Please see here:

https://docs.coronalabs.com/plugin/gpgs/multiplayer/realtime/event/showSelectPlayers/playerIds.html

Best regards,

Brent

hi brent, I already tried playerIds but with different syntax. so to clarify, this correction will work:

native.showAlert(“PlayerIds”, {event.playerIds[1], event.playerIds[2]}, {“OK”})
end

I just thought maybe i can try making each elements, singular that’s why.

still not working for me brent, can you provide a sample line of code with alert box displaying the playerIds (mine and other player). assuming this line of code is already within the function…(event)

Hi @rhaineyensid,

So you want the IDs to be in the “message” part of the alert box? If so, you need to make that parameter into a string as outlined in the docs:

https://docs.coronalabs.com/api/library/native/showAlert.html

So it might look like this:

[lua]

native.showAlert( “PlayerIds”, event.playerIds[1]…", "…event.playerIds[2], {“OK”} )

[/lua]