|
/*
Writing and reading messages to/from the messages buffer is easily done using the functions:
STATE_multiplayer_message_read_buffer()
STATE_multiplayer_message_write_buffer()
However, in some languages such as Visual Basic,
one cannot pass a buffer as an argument to a function.
Therefor, the functions below were written mainly for the Visual Basic programmers.
(Although if a C programmer feels more comfortable with them he can use them as well)
As you can see, for each type of entry we use a different function, if it is textual entry we use :
STATE3dWorld1.Multiplayer_message_write_string("hello guys");
If we want to send our location, which is a floating point variable we use
STATE3dWorld1.Multiplayer_message_write_double (my_location.x);
If it’s some integer, we use
STATE3dWorld1.Multiplayer_message_write_long (123456789);
And if we just need to send a byte (short) variable, we use
STATE3dWorld1.Multiplayer_message_write_byte('A');
*************************************************************************
IMPORTANT!!!
The entries are appended to the message buffer in the same order in which
they were inserted, so when a user receives that message he should extract
the entries from the message in the same order in which they were written.
***************************************************************************
For example :
Writing ...
STATE_multiplayer_write_string("John Smith");
STATE_multiplayer_write_double(location[0]);
STATE_multiplayer_write_double(location[1]);
STATE_multiplayer_write_double(location[2]);
Reading...
char playerName[100];
double location[3]={0,0,0};
STATE_multiplayer_read_string(playerName);
STATE_multiplayer_read_double(&location[0]);
STATE_multiplayer_read_double(&location[1]);
STATE_multiplayer_read_double(&location[2]);
|