Jump to content

Networking system - Help!


12p

Recommended Posts

As some of you may know, I'm making a game (see the thread here).

I'm right now working in the networking system to make able players to connect to servers and play in maps etc etc like MTA and Counter Strike do.

What I've made so far is a system that needs account logging and registering to sync the player coordinates, but I think it's not a very effective method. Now I'll describe how them work:

ACCESING TO SERVER

A client connects.

Server sends packet to client, asking for username and password.

Client gets that packet, and sends another to server with the username and password.

Server receives the packet, and checks if there is an account with the username. If the account exists and the password is right, or there was no account with the username,

Server send packets to all players but the new client.

Every client creates a new player element, with the username of the new player as an identifier variable.

And for the client who connected, send a packet per client to create as many player elements as clients are connected to server.

SYNCING COORDINATES

(note this event only ocurs every 5/60 seconds)

A client moves

Send packet to server, containing new coordinates and own username

From server, send packet to all clients but the one who moved, containing the coordinates and the username of that client

Every client check all its player elements. If the client who moved has the same username as one of those elements, then move it.

For those who wonder

The username data type is "string"

The coordinates data type is "signed short"

When I say "check all", I use a FOR statement.

The accounts are basically INI files containing the password and some little data that isn't used yet.

So, can I optimize this?

The problem I'm having is that the lag increases with time; the delay between a client and another client is WAY higher after 60 seconds than after 10.

Link to comment

Thanks, but actually I've made all that. My networking system IS WORKING, just a bit laggy.

The only thing I want is someone to tell me whether my concept of coordinates syncing is right.

(also, both are working with GM integrated mplay system, which lags a lot heavier. I'm using the 39dll GM extension)

Link to comment

It would make more sense too send the user ID only (as it's shorter than the username string), and only send the coordinates if they have changed (rather than every x frames). Also:

Server sends packet to client, asking for username and password.

Client gets that packet, and sends another to server with the username and password.

You should not be sending passwords out - they should only go one-way and be encrypted at all times.

Link to comment
GML, similar to C.

The only thing I want is someone to tell me whether my concept of coordinates syncing is right.

this is much easyer that C++ i dont use GMl but i watch some video's C++ can't draw motion etc... whit C++ you need to use directX or openGL this GMl is a game maker not a programing language

Link to comment
It would make more sense too send the user ID only (as it's shorter than the username string), and only send the coordinates if they have changed (rather than every x frames).

Here's the complex deal; the ID's aren't the same in client than in server.

The only way I found to recognize clients are via the username.

this GMl is a game maker not a programing language

WRONG. GML is a scripting language. GM is not. GML is not GM.

GML = Game Maker Language

Got it now? lol

Oh, and the other thing that John said...

Well, I only send the password once, and it's when a client tries to login into the server. So yeah, I'm doing what you say; sending it one-way. The previous packet is for asking the client to send the password.

Edited by Guest
Link to comment

I've spent around 2 months working in this, I really doubt I'm doing it again from scratch.

I would have to get some books and stuff, learn C++ from its basics, and then I could try to make something good with the knowledge.

I can't even understand how to use pointers. I know what they do but IDK how to apply them.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...