SgtConti's Forum Posts

  • var io = require('socket.io').listen(1337);

    // usernames which are currently connected to the chat

    var usernames = {};

    var rooms = {};

    io.sockets.on('connection', function (socket) {

         // when the client emits 'adduser', this listens and executes

         socket.on('adduser', function(username){

              // we store the username in the socket session for this client

              socket.username = username;

              // add the client's username to the global list

              usernames[username] = username;

              // echo to client they've connected

              socket.emit('updatechat', 'SERVER', 'you have connected');

              // echo globally (all clients) that a person has connected

              socket.broadcast.emit('updatechat', 'SERVER', username + ' has connected');

              // update the list of users in chat, client-side

              io.sockets.emit('updateusers', usernames);

         });

         // when the user disconnects.. perform this

         socket.on('disconnect', function(){

              // remove the username from global usernames list

              delete usernames[socket.username];

              // update list of users in chat, client-side

              io.sockets.emit('updateusers', usernames);

              // echo globally that this client has left

              socket.broadcast.emit('updatechat', 'SERVER', socket.username + ' has disconnected');

         socket.on('getrooms', function(){

              //

              //

              io.sockets.emit('updaterooms', rooms);

              //

              socket.broadcast.emit(socket.rooms);

         });

         });

    });

    that would be my server (just example), my problem is i cant connect.

    Construct 2 client side i say: Socket.io connect to "localhost" port 1337

  • Well unfortunately it doesnt show anything on how to use it.

    Maybe im just stupid and dont get it...

    I really need to know from the basics, how you should script something, how it all works.

  • Sry for the lack of explanation.

    Server: Node.js but im open for better options

    C2 Plugin: Zack0Wack0�s modded plugin

    The Message should create a enemy soldier on the other players screen.

    No, you only can control one player, the message is only there to say to the other client, that my player builld a soldier, and that it should make that on his screen.

    So, its my own player wich others need to display ;)

  • hello i didnt wrote anything in the last tome, but now its changing:

    example explanation:

    I press the "Build Soldier" button, it builds a soldier on my screen and sends the data: "Enemy build soldier" to the other client.

    Its a RTS. the server should be like, a Multiroom Autojoin server.

    I have problems understand the servside scripting, and communication between the clients, sending the "messages".

  • Bad thing we cant use it to export our projects if using file:///

    the images should be packaged inside the Exe exported with Node-Webkit

  • Thank you, now i got an idea how it all works.

    Im thinking about using Socket.io to send dictionary values.

    But it wont work, always if i say send: Dictionary.Get(Spawned)

    It say Unkown Expression. Sry for the question but im total noob with Construct 2, before i used to use Cpp.

  • i looked at those, but they don�t seem to fit what im planning to do.

    I a good tutorial(would be best) on how to do this,

    something that describes how i could realize this:

    If button pressed: build soldier and send "build enemy Soldier" to Client2

    ---and:---

    If Multiplayerbutton pressed: Connect server, find room(max 2 players) if no room, create room.

    Something like that ^^ should be done with socket.io i just dont know how.

  • thank you, i think i did forget to mention that i decided to use Socket.io but if there better options, let me know ;)

    and well, i have no problem with programming a backend server, i just dont know how :/

    And like i said, i actually want in the actual game only client to client.

    Its going to be hard, i know. Especially if its a multiplayer for a RTS...

  • Firstly, i searched and read through many pages of tutorials and posts. But i cant get it all together, my head is almost exploding, safety first, i decided to ask befor anything happens <img src="smileys/smiley2.gif" border="0" align="middle" />

    how do i setup a simple server(best would be with a gui made in c2)

    make the client connecting, asking if there exists any rooms,

    if yes, connect into it. if not, create one.

    And then if start the game, disconnect from the main server and proceed Client-to-Client multiplayer.

    i just dont get it with the rooms and everything, that should firstly be done here, if i got done that above im going to proceed with my question, so its not all, yet. <img src="smileys/smiley17.gif" border="0" align="middle" />

  • Ashley, i know, but i use zack0wack0�s plugin for this, therefor i need a node.js server, so indirect its Contruct 2 question. Lets say its a greyzone ;)

    Johnny thanks, now i got it. it finally works :D

  • thanks, but it still wont work, my file is as simple as this now:

    console.log("Hello World");

    console.log('Server running at http://127.0.0.1:80/');

    and still just ...

    i tried it the was you wrote, still just ...

  • Please someone know it?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hello,

    im trying to start a node.js server,

    but i cant, when i say: node app.js

    it just sais: ...

    where should i place the file? No one ever said, where i should place the file.

  • Awesome :D thank you very much :)

    Im going to read through the tutorials.

  • Use the browser object to set fullscreen?

    Sry i dont understand, im pretty new to Construct 2, where do i find the option?

    Sry if its a totally n00b question.