How do I kick a peer?

Get help using Construct 2

Post » Wed Jun 15, 2016 3:19 pm

I am having trouble kicking peers off my multiplayer server. When i click the kick button (I type the name and reason) he doesn't go away.
I am testing my project in my browser and it supports multiplayer. Am i doing something wrong?
B
9
S
3
Posts: 26
Reputation: 677

Post » Wed Jun 15, 2016 4:50 pm

Maybe, and probably. No one can really answer without seeing how your kick button and multiplayer are set up.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Wed Jun 15, 2016 8:14 pm

Here is a link to a picture i took: http://imgur.com/nWR3kDX
B
9
S
3
Posts: 26
Reputation: 677

Post » Wed Jun 15, 2016 8:51 pm

You say you type the name. What name are you typing? It looks like you're kicking based on a selection in a list box. How are you populating that list box?

You'll need the peerID of the peer you are trying to kick. For example, try creating an event On any click - Kick peer PeerIDAt(PeerCount). This should kick the last joined peer. See if that works first.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Wed Jun 15, 2016 9:29 pm

PeerIDAt(PeerCount) has an unknown expression. PeerIDAt is unknown.

And the selected box in the list is the username of the player.
B
9
S
3
Posts: 26
Reputation: 677

Post » Wed Jun 15, 2016 9:48 pm

That is your problem, the kick action works with peerID, not username. You'll need a system to keep track of the peerIDs and use that to kick peers.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Wed Jun 15, 2016 9:51 pm

Is the first person to join to be id 0, then the second to have id 1, ect?
B
9
S
3
Posts: 26
Reputation: 677

Post » Wed Jun 15, 2016 10:18 pm

The peerID is a random string assigned by the signalling server upon joining a game.

You can use PeerIDAt(index) to get the ID of each peer in order of joining.

https://www.scirra.com/manual/174/multiplayer
PeerAliasAt(index)
PeerIDAt(index)
The alias and ID of the nth peer in the current room, up to PeerCount.


If you are unfamiliar with PeerIDs, I highly recommend reading and going through the steps of making the Multiplayer Tutorials https://www.scirra.com/tutorials/892/mu ... 1-concepts. PeerID is a core concept and you won't get very far without understanding and working with them.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Casimir, pwrtoppl, resdesign and 9 guests