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:
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:
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"
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