send_var(void* addr)
send_var_to (ENTITY*,void* addr)
send_var_id (var client_id,void* addr)
Updates a
global
variable or a struct from a client script to the server script,
or from the server script to all clients (send_var), to a client that has created
a certain entity (send_var_to), or LC to a client with a certain id number
(send_var_id). The on_server or on_client
event function is triggered on each PC which has received the variable, and
the old content of the variable or struct is replaced by the new value.
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 (
see atypes.h).
addr - address of the variable or struct to
be sent.
Remarks:
- On the server the function sends the
variable only to the client with the given client_id resp. the client
that has created the given entity. If NULL is given for the entity
pointer, the sever sends the variable to all clients.
- When executed
on the client, the variable is sent to the server and NULL must
be given for the client_id or entity pointer.
-
All global variables
as well as user-defined global structs can be sent;
local variables, allocated variables, predefined system
variables, arrays, pointers, engine objects, parts of a struct or single variables from inside a struct can not be sent through this function.
- LC The event function on
the receiving PC receives the address of the variable or struct
as its first argument.
-
This function synchronizes scripts and thus can not be used in external languages such as C++ or C#,
or in unprotected sessions. Use send_data_to instead.
Edition:
C
Example:
var x;
...
send_var_to(NULL,x); // send the current value of x to all clients
See also:
send_string_to, send_data_to, session_connect,
on_server, on_client
► latest
version online