FANDOM


Buffers are used to deliver data through web hosts on GameMaker. Those were used to create online games on GameMaker.

Buffer types:

buffer_u8 1

An unsigned, 8bit integer. This is a positive value from 0 to 255.

buffer_s8 1

A signed, 8bit integer. This can be a positive or negative value from -128 to 127 (0 is classed as positive).

buffer_u16 2

An unsigned, 16bit integer. This is a positive value from 0 - 65,535.

buffer_s16 2

A signed, 16bit integer. This can be a positive or negative value from -32,768 to 32,767 (0 is classed as positive).

buffer_u32 4

An unsigned, 32bit integer. This is a positive value from 0 to 4,294,967,295.

buffer_s32 4

A signed, 32bit integer. This can be a positive or negative value from -2,147,483,648 to 2,147,483,647 (0 is classed as positive).

buffer_f16 2

A 16bit floating point number. This can be a positive or negative value within the range of +/- 65504. (Not currently supported!)

buffer_f32 4

A 32bit floating point number. This can be a positive or negative value within the range of +/-16777216.

buffer_f64 8

A 64bit floating point number. This can be a positive or negative value from -(252) to 252 - 1.

buffer_bool 1

A boolean value. Can only be either 1 or 0 (true or false)

buffer_string N/A

This is a UTF-8 null terminated (0x00) string. Basically a GameMaker string is dumped in the buffer, and a 0 is put at the end.

Writing and handling buffers:

Writing: (Client Side)

So, say you have created a buffer and you want to write information to it, then you would use something like the following code:

buffer_write(buff, buffer_bool, global.Sound); buffer_write(buff, buffer_bool, global.Music); buffer_write(buff, buffer_s16, obj_Player.x); buffer_write(buff, buffer_s16, obj_Player.y); buffer_write(buff, buffer_string, global.Player_Name);

looking at the example above you can see that you can write different types of data to a buffer (you are only limited to a specific data type when using the fast buffer type), and this data will be added into the buffer consecutively (although its actual position in the buffer will depend on its byte alignment, explained below). This is the same for reading information from the buffer too, and in the case of the example given above, you would read from the buffer in the same order that you wrote the data, checking for the same data type, eg:

global.Sound = buffer_read(buff, buffer_bool); global.Music = buffer_read(buff, buffer_bool); obj_Player.x = buffer_read(buff, buffer_s16); obj_Player.y = buffer_read(buff, buffer_s16); global.Player_Name = buffer_read(buff, buffer_string);

Handling: (Server side)

buffer_read(buffer, type)

Argument Description
buffer The index of the buffer to read from.
type The type of data that is to be read from the buffer (see the list of constants below).

Example: Edit

var cmd = buffer_read(buff, buffer_S16 );

The above code reads from the buffer with the id stored in the variable "buff" a signed 16bit value into the local variable "cmd". 

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.