[How do i] Setup a simple server or so

0 favourites
From the Asset Store
A set of sci-fi / cyberpunk themed platformer characters
  • 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" />

  • C2 as of this time has no robust networking api. There is also no C2 server technology yet... however there is promising hope down the road....... sometime down the road. However we currently do have

    Websocket

    Socket.io

    these paths will require you to program a server backend. As they are only client communications

    Velotjet has(http://www.scirra.com/forum/behavior-multiplayer-online-demo_topic61563_page1.html)

    Photon Cloud Behaviour

    Multiplayer plugin

    These are more robust and include more room options and you can create a game using this providing you know there isn't going to be server side logic. I'm prone to detail errors on this

  • 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...

  • SgtConti

    Try my two multiplayer plugins:

    1) MultiPlayer (NodeJS server - you need some server-side JavaScript experience if you want to adapt my server code; C2 doesn't extend to server programming).

    2) PhotonClient (Photon Cloud server - no server-side programming needed here, but it does mean that you have fewer options for management of your game).

  • 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.

  • I wouldn't say you cant do what you want, but you will need to be a little more creative. This is for Photon, I couldn't find what you would want with the multiplayer one.

    A. Create a Webplayer sprite.

    B. This sprite is never actually part of game play. maybe it's a logo in the corner to represent the player face. Maybe it's off screen. Whatever, it's not actually going to be used as a game piece. Also make it global so it does not get reset between layouts.

    C. have a Dictionary Object called Message

    D. Set all your data values for transmission in your Message.

    E. Webplayer.SendTextMessage( Message.toJSON )

    on the recieving side

    Webplayer.OnReceivedMessage

    Message.importJSON( webplayersprite.photonclient.message )

    *** cough, reverse the import

    also a tip for you Message Dictionary. You Dictionary should have two parts of a structure.

    Always include this

    Action

    Player

    Room

    follow up with what ever information you need

    figure.owner

    figure.moveto xy

    figure.action

    or

    text for chat message....

    of course you will need to do all message handling yourself. No way to get around that.

    umm. as for Rooms. Well there looks to be room(join/leave), but I saw no actions to support it. So you will need to add that to your text message handling.

    .

    .

    .

    .

    .

    Alternatively and very hesitantly. I might part with my photonclient I was toying around with. I do mean toying, as it's not meant for release and never meant to be released.

    It already supports Join/Leave rooms, and is a plugin not a behaviour.

    Data is packed into a Variadic params that "Function" uses. and is accessed by PhotonClient.Param(#) similar to Function.Param(#).

    Based on Event Registration. So your action/command is already expressed with the message.

    • On 'GAME' Startup

    -- Client.RegisterEvent(#)

    -Client OnEvent

    -- Client.CompareEvent = #

    however, I'm not sure I'm ready to part with it. It's

    A. Not done

    B. prone to a lot of terrible code(in the js)

    C. prone to errors

    D. some Events/Actions are 'in', but do nothing

    E. possible complete upheavle leaving the high possiblity that you would need to wipe all your photonclient work and re-do it.

    F. Requires you to run your own server as it does not use PhotonCloud

    G. I may and likely will drop Photon in favour of NodeJS ActionHero or Tycho.

    H. I'm not likely to support it out side of a few basic questions.

    I. No work done on RoomLists. so there is no way manage room details.

    Your probably better of using Velotjet and working around it. While overall the MP is not ideal. It is workable, just a lot of work. I'm sure Velotjet will get the ultimate networking code running sooner or later. We have a lot of network faith in his efforts :)

  • 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.

  • You could also do it with PHP, this would be much easier but you need to learn a new language.

    You could also hire me to make all this Multiplayer things for you :D

    To your problem:

    You connected to the Server ?

    You need to predefine (is this word right? :D) the key Spawned in your Dictionary. This means in Construct you need to already have this key.

  • SgtConti

    Could you please explain further:

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

    Is that another player that you can control? How would you control its actions as well as your own player's actions? Multiplayer usually means that you're just controlling your own player and its actions are reproduced on another player's display.

    jayderyu

    Thanks very much for your support and confidence!

  • 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".

  • SgtConti

    What server are you using?

    What C2 plugin are you using?

    Could you please explain what your "Enemy build soldier" message is intended to create?

    Is that another player that you can control? How would you control its actions as well as your own player's actions?

    Or is it your own player, which other connecting clients need to display?

  • 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 ;)

  • SgtConti

    Since you're using Zack0Wack0�s modded plugin, you'll get the most/best help if you post in the thread dedicated to that.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)