proc_local(ENTITY*,void *function)
proc_client(ENTITY*,void *function)
Assigns a client-side function to the given entity. Proc_local starts
the given function on all clients, proc_client
starts the function only on the client that has created the
given entity or it's creator entity. Client-side entity functions can
be used for detecting local mouse events, for starting local sound or
particle effects, or for local entity animation.
This can save a lot of bandwidth in a multiplayer system.
Parameters:
ENTITY* |
Entity to assign the function to. |
function |
Function pointer to be run on the clients. |
Remarks:
-
A7 Outdated; replaced by dplay_localfunction. Do not use these functions in new projects.
- These instructions can only be executed on the server in
a multiplayer game. The function does not run on the server,
only on the clients. The entity must also exist on the clients, and will
become the my entity for the local functions.
- Proc_local and proc_client can be started
one frame after entity creation the earliest - therefore, insert a wait()
before.
- The last proc_local instruction of each entity is stored. If a new
client connects, it is started again on this client. Therefore local
functions will even run on clients that connect after the proc_local
execution on the server. For using this mechanism, do not start more
than one proc_local instruction per entity.
- The dplay_localfunction variable can be used alternatively
to make all entity functions local. By evaluating the connection variable,
the function can then do different things dependent on whether it's running
on the server, on a client, or on both.
Example
(lite-C:
// the following function sets the my entity invisible only on its creator client
function hide_me() { set(me,INVISIBLE); }
...
proc_client(me,hide_me);
...
See also:
connection, dplay_localfunction
► latest
version online