The Daily Click ::. Forums ::. Klik Coding Help ::. Making an online game with unlimited amount of players [mooclick/mmf2]
 

Post Reply  Post Oekaki 
 

Posted By Message

EleXor



Registered
  21/01/2003
Points
  269
23rd June, 2008 at 09:40:30 -

Hey! I currently have made an online game with maximum of 4 players online at the same time. I have a made first a server program which takes messages from the client programs and communicates with them. This is what my server program looks at the moment:
Image
So the whole deal is this, the client makes a set of requests before joining to the game:
1. Version check, if wrong the application terminates and starts the autopatcher
2. Server capacity, if it's full the application terminates
3. Login/create account
4. On join it sends your name+coordinates to other players and you'll receive theirs aswell.

This is how I send the coordinates:
+Right arrow pressed
+Det right is not overlapping group player (monsters, other players)
+Det right is not overlapping an obstacle
-Send "coords"+"§"+"slotnumber"+"§"+"playerx+32"+"§"+"playery" to server through sub channel x

And then the server handles it and sends it to all players, but I won't explain here how the message is handled because is pretty simply of course.

So the problem here is, I have currently slots 0-3 and one slot is assigned for each player. On the client program there are 4 active objects (players) and each have a group of events, and depending on your slot you will control one of them. If I wanted to make it to 5 players max, I'd have to clone one more active object and clone all the events to him and alter the server program aswell.

So, anyone has a tip how to make a working system with unlimited amount of players? I tried this messing with alterable values and such, but it was rather messy.
I've already searched around here and read the articles but it didn't help me much.


PS. Here is the picture of the client program, incase it helps:
Image

Image Edited by the Author.

 
n/a

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
23rd June, 2008 at 13:50:50 -

You only need to use one active object.

Simple.

On [Player Join]
= Create object "Character"
+ "Character": Set Alterable Value A to Player ID

This should (in theory) create a new player character, and give the character the ID of the player.

Then any movement and what nots just run a fastloop to find the character with the corresponding alterable value A, and use that character.

The active object you use should be the object you use to make all movements and collisions currently, except you only need 1, instead of constantly cloning for each new character you want.

Then all you need is a simple event at the top:
Start of Level:
Destroy "Character"

 
My signature is never too big!!!

EleXor



Registered
  21/01/2003
Points
  269
23rd June, 2008 at 17:04:36 -

Hmm, I think I've tried that before in the past but I quess I messed up something. I'll give it a try. Just curious to see how it works with all my current "code" about positioning players / saving stats / receiving stats et cetera.

Well I planned it like this:

+On join
-set character alt string to name (defined earlier)

+right arrow pressed
+no obstacles/players to right
+name=character alt string
-move to right
-send info about movement

Would that work?

Image Edited by the Author.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click