Multi-player Help

Get help using Construct 2

Post » Mon Mar 13, 2017 7:25 pm

Hello Good people.

I want to create a multi playergame with pre-registered users on my site. The game should pair users based on unique rooms.
e.g. 2 Players (PlayerA and PlayerB) will be matched together not automatically but because their urls share the same room (Room120a)

http://game-url/?room=Room120a&user=101&nick=JohnD
http://game-url/?room=Room120a&user=102&nick=KenS

How do I read this extensions on a sent URL?
B
14
S
3
Posts: 22
Reputation: 1,220

Post » Mon Mar 13, 2017 7:53 pm

The Browser object has a URL expression that will return the current URL. You can then parse out the room number with tokenat, and use that to join a room.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,699
Reputation: 64,446

Post » Tue Mar 14, 2017 2:57 am

oosyrag wrote:The Browser object has a URL expression that will return the current URL. You can then parse out the room number with tokenat, and use that to join a room.


Is it possible to pass a string like this "http://game-url/?room=Room120a&user=101&nick=JohnD" when launching a game from a web page?
B
14
S
3
Posts: 22
Reputation: 1,220

Post » Tue Mar 14, 2017 3:27 am

Yes. Add the browser object, and get the URL via the browser.URL expression.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,699
Reputation: 64,446

Post » Wed Mar 15, 2017 11:59 am

oosyrag wrote:Yes. Add the browser object, and get the URL via the browser.URL expression.


Thanks.

It worked.

My problem is now security. In case someone decides to type the string into the browser address bar without registration on the sight first.
B
14
S
3
Posts: 22
Reputation: 1,220

Post » Wed Mar 15, 2017 5:13 pm

I heard somewhere that it was possible to use PHP via the Ajax Object.
So you could send an request through the Ajax Object to your Webspace and it will check who you are through a PHP Script. The Script can then return a Session ID or other Data(PlayerNames, etc.) which you could try to associate to the current Browser the Player is using. You would have to set a cookie, maybe through Local Storage? That might be the Thing what you are looking for.

But I don't know anything about PHP at the moment so that is all I can do for help. ^^'
When you just begin learning this Stuff, don't make big things. Start Small.
B
9
S
2
G
1
Posts: 29
Reputation: 1,077

Post » Wed Mar 15, 2017 8:04 pm

You would need some sort of verification system, which would be outside of the scope of the base functionality of C2, although there are many free third party plugins that allow for communication with other API's. An AJAX request to your webserver could be the most straightfoward solution, but it really depends on the method you want to use to verify the user.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,699
Reputation: 64,446

Post » Fri Mar 17, 2017 6:34 pm

My method may be crude, but I am writing a log file to the server anytime I call the game through the URL using the Room, ID and NickNames. I read the log file from my server with AJAX from within C2. If they match, game plays.

:D
B
14
S
3
Posts: 22
Reputation: 1,220


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests

cron