X
XirmiX
Guest
So, I've been following this tutorial (and the previous videos) about how to set up a multiplayer connection, registration and login and so forth. I have made certain things different for myself, however... first of all, the client holds onto all of the registrations and login details, the server doesn't hold onto it. Secondly, I'm aiming to have the server listed for all the clients, before joining. There not being a master server of any sorts, the servers being something that players can host and then when while they are up, players can select them and join them. Here's part 4 of the set of tutorials I followed:
Question is, how do I do that? I would guess I need to have, inside the obj_controller's networking event (I have most of what is featured in the previous videos as is in the tutorials, except for parts on where the player account information is stored and how it's handled. Some of the information from the 4th tutorial, the one I posted above, is also in my code, but it's indented for now, so I don't get any glitches or errors while I'm trying to get this through) for both client and server something so that the client would receive information from created servers and for the server to send to the client "yeap, I exist! You can join" and then for the client to have a bar pop up in a room, which then can be clicked to join the server. If I understood buffers and how they work and such, I could probably write this myself, but for the moment, I'm not at that skill as of yet (but might be soon).
Here's the networking data in my Client
And my Server:
I know I need something to add to these two, but what? And of course, the room and the pop-up button that should show up in a server list... which, too needs creation, man, there's a lot of stuff that needs making for setting up multiplayer!
EDIT: While waiting for answers, I looked up on the manual about ds_lists and buffers... yeah, I cannot comprehend how to use them, buffers especially.
Question is, how do I do that? I would guess I need to have, inside the obj_controller's networking event (I have most of what is featured in the previous videos as is in the tutorials, except for parts on where the player account information is stored and how it's handled. Some of the information from the 4th tutorial, the one I posted above, is also in my code, but it's indented for now, so I don't get any glitches or errors while I'm trying to get this through) for both client and server something so that the client would receive information from created servers and for the server to send to the client "yeap, I exist! You can join" and then for the client to have a bar pop up in a room, which then can be clicked to join the server. If I understood buffers and how they work and such, I could probably write this myself, but for the moment, I'm not at that skill as of yet (but might be soon).
Here's the networking data in my Client
Code:
///Check for server and data
{
var eventType = ds_map_find_value(async_load, "type");
switch(eventType)
{
//Transfer data between the client and the server
case network_type_data:
var buffer = ds_map_find_value(async_load, "buffer");
buffer_seek(buffer, buffer_seek_start, 0);
scr_handleIncomingPackets(buffer);
break;
}
}
And my Server:
Code:
{
var eventType = ds_map_find_value(async_load, "type");
switch(eventType)
{
case network_type_connect:
//Add the client to the socket list
var socket = ds_map_find_value(async_load, "socket");
ds_list_add(global.players, socket)
//send player id
buffer_seek(global.buffer, buffer_seek_start, 0);
buffer_write(global.buffer, buffer_u8, 2);
network_send_packet(socket, global.buffer, buffer_tell(global.buffer));
scr_showNotification("a new player has joined");
break;
//Remove the client from the socket list
case network_type_disconnect:
var socket = ds_map_find_value(async_load, "socket");
var index = ds_list_find_index(global.players, socket);
if (index >= 0)
{
ds_list_delete(global.players, index);
}
//Player leaving
var playerLeavingId = 0;
with(obj_player)
{
if (playerSocket == socket)
{
playerLeavingId = playerIdentifier;
}
}
scr_showNotification("a new player has left");
break;
//Transfer data between the client and the server
case network_type_data:
var buffer = ds_map_find_value(async_load, "buffer");
var socket = ds_map_find_value(async_load, "id");
buffer_seek(buffer, buffer_seek_start, 0);
scr_handleIncomingPackets(buffer, socket);
break;
}
EDIT: While waiting for answers, I looked up on the manual about ds_lists and buffers... yeah, I cannot comprehend how to use them, buffers especially.
Last edited by a moderator: