Skip to content

Latest commit

 

History

History
77 lines (74 loc) · 2.19 KB

start.md

File metadata and controls

77 lines (74 loc) · 2.19 KB

Welcome to NetGM2!

An advanced networking extension for Gamemaker

Table of contents

Getting started

Notes for later

The _reliable parameter in a function means whether it is okay to miss packets (false) and save up resending or if it is imperative that the packet arrives (true)

Functions that start with two underscores are not meant to be used and are internal functions

Initialization

Prelude

Add the obj_net_web object to your game's startup room

Call the net_init function.

Get a NetGM2 application key and analytics page

Interlude

Whenever you want to create a connection to a server, use

net_connect(_ip, _port)

Before that, you need to configure netgm2, call net_set_config, it goes like so:

net_set_config({
  timeout: number, /* of milliseconds until we time out */
  p2p_handler: function, /* Gets called whenever you receive a p2p message, arguments being: callback(_recipient_id, _data) */
  uses_accounts: bool, /* Does the server use an account system? */
  discord: DiscordStruct {
    app_id: string,
    custom_presence: bool /* Whether you want to use the built in NetGM2 presence or want to use your own code, needs _NekoPresence_ */
  }
})
/*
  Make sure to set the player's name!
*/
net_set_name("...")
/*
  Set a password if you use the account system
*/
net_set_password("...")

If you use the MultiClient extension

// Call this
net_multiclient()

How can I see what NetGM2's state is?

enum NET_STATE 
{
	CONNECTING,
	CONNECTED,
	REGISTERED,
	DISCONNECTED,
}

function net_get_state() -> NET_STATE

How can I get the server's name?

function net_get_server_name() -> string