Login | Register

Autoselect host

July 18, 2006, 13:42 by Calle
[loading]
-->
For testing purposes and other purposes as well, you might want to skip unnecessary menus – such as the menu join/host in a multiplayer game. I often try my games either on one and the same computer or over LAN, this way I can try it out fast and I always like to try my games fast, so that I can fix the errors. This is the code I use:

<div style="clear: both;">mplay_init_tcpip(get_string("Please enter your IP:","";))
if (mplay_session_find()>0) {
mplay_session_join(0,"client";);
global.host = false
room_goto(room1);
}
else {
mplay_session_create("game",2,"host";);
global.host = true
room_goto(room1);
}
</div>

I usually don’t want to put it in the create event, because when the code is executed is take a while to get through it, and the draw event won’t be executed before all of the create events are executed and therefore I will be shown only a black screen. If I put it in an alarm event instead, set to anything but one, I will be able to draw something on the screen before, such as “Please wait…”

This do not only need to be an option during the testing procedure though, those who want may use it as the LAN option of their full game – and the user will probably find it very handy.

Comments

Loading comments... [loading]
.
Users logged in:

game maker articles, game maker examples, game maker tutorials, gmtutorials, game maker questions and answers, game maker crash course, how to create games