Yet-another Multiplayer Demo (with capx)

Show us your completed creations made in Construct 2

Post » Fri Aug 24, 2012 10:55 pm

sorry for not being able to answer before. Thank JohnnySheffield @ @ Juantar and for answering my post. I could not move on I want to do with the game for different reasons. but I still have the idea, I'm looking @ JohnnySheffield cravings what you're doing, in any event upon termination and complete what I want to do and get on some host I have seen some there, to visit it and give me your opinion .
B
16
S
3
G
3
Posts: 15
Reputation: 2,813

Post » Sat Aug 25, 2012 12:07 pm

[QUOTE=juantar] @LimonSpace : There is one event in the sample file that says "every 0.07", in the sample file it sends the position of the managed player to the server. What actions do you have there?[/QUOTE]

i've the same your's.
B
11
S
5
G
1
Posts: 53
Reputation: 1,633

Post » Sat Aug 25, 2012 3:34 pm

[QUOTE=rtcarroll07] Use the socket.on disconnect function to broadcast it.[/QUOTE]

I see how to do it, but I have no idea what to enter in after that.

example_server.js

socket.on (disconnect) {

??

}

B
18
S
9
G
5
Posts: 77
Reputation: 4,946

Post » Sat Aug 25, 2012 5:16 pm

@lonehangman

First, when a player connects, server must give him his unique number, or a client must notify server what is his number, and store that number on server somehow (you can make your own list of numbers, or use a socket.id number or you can use constructs sprite ID, or etc. but clients and server must know what that number is).

So, when connects, client can do something like:

On connect
     Socket send message ("PLAYER, MYID") // in this case client notifys server what his number is


Depending on what kind of arhitecture you want, you must code this part yourself, you can do something like this maybe (code is a mess, just for a general idea)


myNumber = 0;
var Me = [];

io.sockets.on("connection", function (socket) {
     
    socket.on("message", function (data) {
        var new_data = data.split(',');
       
        if (new_data[0] == 'PLAYER') {
              
          var myNumber = count++;    
          Me[0]='player'
          Me[1]=new_data[1];
}

socket.on('disconnect', function (data) {
          socket.broadcast.emit("message",'D,'+ Me[1]);
          //remove player from the list here somehow; Me[1]=null
               }




So, when a player disconnects, you can notify all connected games that a specific player is (D)ead, and what is his ID, so that client can:

On Message "D"
       Pick instance(ID)
           Destroy

sorry for the messy post, i'm in a hurry but that's how i'd do it. There is probably much more smarter way for this.

Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Sat Aug 25, 2012 5:21 pm

[QUOTE=lonehangman] [QUOTE=rtcarroll07] Use the socket.on disconnect function to broadcast it.[/QUOTE]

I see how to do it, but I have no idea what to enter in after that.

example_server.js

socket.on (disconnect) {

??

}

[/QUOTE]

solved thanks
B
11
S
5
G
1
Posts: 53
Reputation: 1,633

Post » Wed Aug 29, 2012 12:20 pm

@LimonSpace

How did you do it. I can't for the life of me figure it out according to the post above that some one wrote (Thanks for that btw, it got me thinking)
B
18
S
9
G
5
Posts: 77
Reputation: 4,946

Post » Wed Aug 29, 2012 1:25 pm

@lonehangman
it's even easier than that wall of text i wrote:

To juantar's example server just add at the right place:

socket.on('disconnect', function (data) {
     
      socket.broadcast.emit("message",'D,' + mySelf[0] );
      entities[myNumber] = null;
     
});


To capx just add (as sub-event of "is data available?" event):

http://imgur.com/2YZR6
Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,652

Post » Wed Aug 29, 2012 1:28 pm

@JohnnySheffield

Ok then, just disregard that message I sent you then :P

Edit: It works! Thank you very much.

Thanks!lonehangman2012-08-29 14:13:13
B
18
S
9
G
5
Posts: 77
Reputation: 4,946

Post » Mon Sep 03, 2012 9:06 pm

hi all,
i've a problem i make a simple star's game with this tut and now i only wanna put this project online but when i try to connect to my game by internet he don't connect to my server what i can do?
i put the client on apache in my pc and the people can visit the home of the game (made in construct) but don't connect on my server (always in my pc) i just do port forwarding and exections in firewall ecc but nothing.
i try with your example but     the same thing how can i solve? thanks simone


PS with construct the connection is ok LimonSpace2012-09-03 21:28:55
B
11
S
5
G
1
Posts: 53
Reputation: 1,633

Post » Mon Sep 03, 2012 9:27 pm

[QUOTE=lonehangman] @LimonSpace

How did you do it. I can't for the life of me figure it out according to the post above that some one wrote (Thanks for that btw, it got me thinking)[/QUOTE]

I simply wrong to quote sorry
B
11
S
5
G
1
Posts: 53
Reputation: 1,633

PreviousNext

Return to Completed Creations

Who is online

Users browsing this forum: No registered users and 3 guests