12p Posted February 14, 2012 Share Posted February 14, 2012 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
Cadu12 Posted February 15, 2012 Share Posted February 15, 2012 What do you use language? e.g C++ Link to comment
12p Posted February 15, 2012 Author Share Posted February 15, 2012 GML, similar to C. The only thing I want is someone to tell me whether my concept of coordinates syncing is right. Link to comment
Cadu12 Posted February 15, 2012 Share Posted February 15, 2012 I found a youtube a how to make multiplayer (I tinhk you can do login/register) for you: Link to comment
12p Posted February 15, 2012 Author Share Posted February 15, 2012 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
Cadu12 Posted February 15, 2012 Share Posted February 15, 2012 Hmmm, Better you poster in GM forum official. We aren't GM on this forum. Link to comment
12p Posted February 15, 2012 Author Share Posted February 15, 2012 Goddamn, no one knows about THE CONCEPT OF NETWORKING around here... Guess I ask some moderator to close this. Link to comment
AGENT_STEELMEAT Posted February 15, 2012 Share Posted February 15, 2012 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
bandi94 Posted February 15, 2012 Share Posted February 15, 2012 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
12p Posted February 15, 2012 Author Share Posted February 15, 2012 (edited) 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 February 15, 2012 by Guest Link to comment
AGENT_STEELMEAT Posted February 15, 2012 Share Posted February 15, 2012 Ehh, the ID should be assigned by the server, not the client. In fact, the ID should be automatically determined by MySQL (using 'id bigint unsigned NOT NULL auto_increment PRIMARY KEY'). Link to comment
12p Posted February 15, 2012 Author Share Posted February 15, 2012 lol this system doesn't use a database. If I want to use one, I need to rewrite a lot of stuff, get the database, another DLL extension, a HUGE messup. Link to comment
AGENT_STEELMEAT Posted February 15, 2012 Share Posted February 15, 2012 Emm, well, that's kinda fail. In that case, just allocate IDs that are not necessarily linked to an account, but to the player entities. Link to comment
12p Posted February 15, 2012 Author Share Posted February 15, 2012 Like an array? Sounds good. Link to comment
Cadu12 Posted February 16, 2012 Share Posted February 16, 2012 Benxamix2, OpenGL is better, whatever you can do when if you want, but its hard to do. I can give you a tutorial list: http://www.winprog.org/tutorial/start.html http://www.marek-knows.com/downloads.php5?vmk=gameEng (200 mb left) http://nehe.gamedev.net/ C++: http://www.cplusplus.com/doc/tutorial/ http://www.cprogramming.com/tutorial.html Link to comment
12p Posted February 16, 2012 Author Share Posted February 16, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now