Calling events
Events are executed by one of six functions:
FHQ_MP_localEvent: The event is only invoked on this machine
FHQ_MP_globalEvent: The event is invoked on all machines (including this one)
FHQ_MP_remoteEvent: The event is invoked on all machines but the caller
FHQ_MP_specificEvent: The event is invoked on the machine where the given object is local
FHQ_MP_serverEcvent: The event is only executed on the server
FHQ_MP_clientEvent: The event is only executed on the client matching the client ID
NOTE: _parameterArray is always passed as "_this" to code executed as event.
FHQ_MP_localEvent
This event only executes on the client it is issued on. Calling the function works like this:
.
For example, to use the example viewDistance event to set the view distance on the caller's machine to 2000, use
FHQ_MP_globalEvent
This event executes on all machines, including the server (regardless of whether it is a dedicated server, or a hosted game).
.
For example, to set the view distance on all machines to 2000, use
FHQ_MP_remoteEvent
Similar to the local and global events, just executes on all machines except the one calling the event.
.
FHQ_MP_specificEvent
Calling this event requires an additional parameter, and object that is tested for locality on every machine. The code executes on the machine that the object is local to.
.
For example, the following code executes an event on the machine that leader FHQ_playerGroup is local on and has him speak a sentence:
FHQ_MP_serverEvent
This event needs Arma 2 patch 1.62 or later. It currently does not work on Iron Front.
An event called by this function only executes on the server.
FHQ_MP_clientEvent
This event is only executed on the client specified by it's client id:
_clientId is the ID of the client, which can be obtained by different means. One simple means is the owner script command. It returns the id of the client where an object is local.
The difference to specificEvent is that the event is directly send to the specified client, and ONLY to this client. This reduces network traffic, since the locality check of specificEvent would have to be performed on each client. As such, this is currently the preferred solution to sending events. Use this instead of specificEvent on Arma 2 and Arma 3 (Iron Front does not support it).
Events are executed by one of six functions:
FHQ_MP_localEvent: The event is only invoked on this machine
FHQ_MP_globalEvent: The event is invoked on all machines (including this one)
FHQ_MP_remoteEvent: The event is invoked on all machines but the caller
FHQ_MP_specificEvent: The event is invoked on the machine where the given object is local
FHQ_MP_serverEcvent: The event is only executed on the server
FHQ_MP_clientEvent: The event is only executed on the client matching the client ID
NOTE: _parameterArray is always passed as "_this" to code executed as event.
FHQ_MP_localEvent
This event only executes on the client it is issued on. Calling the function works like this:
Code:
[_name, _parameterArray] call FHQ_MP_localEvent;
For example, to use the example viewDistance event to set the view distance on the caller's machine to 2000, use
Code:
["viewDistance", 20] call FHQ_MP_localEvent;
FHQ_MP_globalEvent
This event executes on all machines, including the server (regardless of whether it is a dedicated server, or a hosted game).
Code:
[_name, _parameterArray] call FHQ_MP_globalEvent;
For example, to set the view distance on all machines to 2000, use
Code:
["viewDistance", 20] call FHQ_MP_globalEvent;
FHQ_MP_remoteEvent
Similar to the local and global events, just executes on all machines except the one calling the event.
Code:
[_name, _parameterArray] call FHQ_MP_remoteEvent;
FHQ_MP_specificEvent
Calling this event requires an additional parameter, and object that is tested for locality on every machine. The code executes on the machine that the object is local to.
Code:
[_name, _object, _parameterArray] call FHQ_MP_specificEvent;
For example, the following code executes an event on the machine that leader FHQ_playerGroup is local on and has him speak a sentence:
Code:
["TellTo", leader FHQ_playerGroup, [leader FHQ_playerGroup, [HQ, "speech", "done1"]]] call FHQ_MP_specificEvent;
FHQ_MP_serverEvent
This event needs Arma 2 patch 1.62 or later. It currently does not work on Iron Front.
An event called by this function only executes on the server.
Code:
[_eventName, _eventParameters] call FHQ_MP_serverEvent;
FHQ_MP_clientEvent
This event is only executed on the client specified by it's client id:
Code:
[_eventName, _clientId, _eventParameters] call FHQ_MP_specificEvent;
_clientId is the ID of the client, which can be obtained by different means. One simple means is the owner script command. It returns the id of the client where an object is local.
Code:
["TellTo", owner (leader FHQ_playerGroup), [leader FHQ_playerGroup, [HQ, "speech", "done1"]]] call FHQ_MP_clientEvent;
The difference to specificEvent is that the event is directly send to the specified client, and ONLY to this client. This reduces network traffic, since the locality check of specificEvent would have to be performed on each client. As such, this is currently the preferred solution to sending events. Use this instead of specificEvent on Arma 2 and Arma 3 (Iron Front does not support it).