send_data_to (ENTITY*, void* data,var size)

send_data_id (var client_id, void* data,var size)

Sends unspecified data from a client to the server, or from a server to a certain client or to all clients. The on_server or on_client event function is triggered on each PC which has received the data. This function can be used for transferring data packets between server and clients.

Parameters:

ENTITY* - entity pointer, or NULL for sending to all clients.
client_id - client number as received by the join event or stored in the struct of a client-created entity.
data - pointer to a buffer that contains the data to be sent.
size - size of the buffer in bytes.

Remarks:

Edition:

 C   LC 

Example:

typedef struct MYDATA {
  int x;
  char c[20];
} MYDATA;
... 
MYDATA* mydata = { x = 1; c = "Test!"; }
 
// sending data
send_data_to(NULL,mydata,sizeof(MYDATA));
 
//receiving data
function on_client_event(void* buffer) 
{
  if (event_type == EVENT_DATA)
    memcpy(mydata,buffer,sizeof(MYDATA));
}

See also:

send_var_to, send_string_to, on_server, on_client

► latest version online