October 02, 2022, 01:23:50 am

The Gang Garrison 2 Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

NOTICE: Due to a rise in bot activity, new posters need to be approved before posting.

Join the community Discord server!

Pages: [1]

Author Topic: [Client-side for servers] lobbyfile.gml  (Read 696 times)

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12701
  • Another one --
[Client-side for servers] lobbyfile.gml
« on: May 13, 2017, 06:44:06 pm »

For VPSs with versions of wine where sending UDP is broken (mine). Pair with netcat and an infinite loop in bash on a timer.

Code: [Select]
myObject = object_add();
object_set_persistent(myObject, true);

object_event_add(myObject, ev_step, ev_step_end, '
    if(instance_exists(GameServer))
    {
        if(t <= 0)
        {
            t = 30*15;
           
            var noOfPlayers;
            noOfPlayers = ds_list_size(global.players);
            if(global.dedicatedMode)
                noOfPlayers -= 1;

            var lobbyBuffer;
            lobbyBuffer = buffer_create();
            set_little_endian(lobbyBuffer, false);

            parseUuid("b5dae2e8-424f-9ed0-0fcb-8c21c7ca1352", lobbyBuffer); // Message Type "register"
            write_buffer(lobbyBuffer, GameServer.serverId);
            write_buffer(lobbyBuffer, global.gg2lobbyId);
            write_ubyte(lobbyBuffer, 0); // TCP
            write_ushort(lobbyBuffer, global.hostingPort);
            write_ushort(lobbyBuffer, global.playerLimit);
            write_ushort(lobbyBuffer, noOfPlayers);
            write_ushort(lobbyBuffer, 0); // Number of bots
            if(global.serverPassword != "")
                write_ushort(lobbyBuffer, 1);
            else
                write_ushort(lobbyBuffer, 0);

            write_ushort(lobbyBuffer, 7); // Number of Key/Value pairs that follow
            writeKeyValue(lobbyBuffer, "name", global.serverName);
            writeKeyValue(lobbyBuffer, "game", GAME_NAME_STRING);
            writeKeyValue(lobbyBuffer, "game_short", "gg2");
            writeKeyValue(lobbyBuffer, "game_ver", GAME_VERSION_STRING);
            writeKeyValue(lobbyBuffer, "game_url", GAME_URL_STRING);
            writeKeyValue(lobbyBuffer, "map", global.currentMap);
            write_ubyte(lobbyBuffer, string_length("protocol_id"));
            write_string(lobbyBuffer, "protocol_id");
            write_ushort(lobbyBuffer, 16);
            write_buffer(lobbyBuffer, global.protocolUuid);

            f = file_text_open_write("lobbydata");
            while(buffer_bytes_left(lobbyBuffer) > 0)
            {
                val = read_ubyte(lobbyBuffer);
                //upper = floor(val/16);
                //lower = val mod 16;
                //file_text_write_string(f, chr(48+upper));
                //file_text_write_string(f, chr(48+lower));
                file_text_write_string(f, chr(val));
            }
            file_text_close(f);
           
            buffer_destroy(lobbyBuffer);
           
        }
        t -= global.delta_factor;
    }
');

o = instance_create(0, 0, myObject);
o.t = 0;

//
« Last Edit: May 13, 2017, 06:50:49 pm by Phantom Brave »
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters
Pages: [1]
 

Page created in 0.033 seconds with 37 queries.