YaEventAPI¶
YaEventAPI enables users send events to an event handler.
The following code shows how to register an event handler, issue an event and remove an event handler.
The output may be:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
1 2 3 | |
Functions¶
void YaEventAPI.FireToClient(number playerId, string eventName, EventOption option, EventPayload payload)¶
SERVER ONLY
The server sends the event to the client identified by
playerId.
playerIdThe playerId of the target client.eventNameThe event name.optionThe event option.payloadThe event payload.
void YaEventAPI.FireToAllClients(string eventName, EventOption option, EventPayload payload)¶
SERVER ONLY
The server sends the event to all clients.
eventNameThe event name.optionThe event option.payloadThe event payload.
void YaEventAPI.FireToServer(string eventName, EventOption option, EventPayload payload)¶
CLIENT ONLY
The client sends the event to the server.
eventNameThe event name.optionThe event option.payloadThe event payload.
void YaEventAPI.FireToLocal(string eventName, EventOption option, EventPayload payload)¶
Sends the event to the local handlers.
eventNameThe event name.optionThe event option.payloadThe event payload.
EventDisconnector YaEventAPI.OnEventFromServer(string eventName, EventOption option, function handler<EventPayload>)¶
CLIENT ONLY
ReturnsAn instance of EventDisconnector.
Registers an event handler to handle events sent from the server.
eventNameThe event name.optionThe event option.handlerThe event handler.payloadThe event payload.
EventDisconnector YaEventAPI.OnEventFromClient(string eventName, EventOption option, function handler<EventPayload>)¶
SERVER ONLY
ReturnsAn instance of EventDisconnector.
Registers an event handler to handle events sent from the client.
eventNameThe event name.optionThe event option.handlerThe event handler.payloadThe event payload.
EventDisconnector YaEventAPI.OnEventFromLocal(string eventName, EventOption option, function handler<EventPayload>)¶
ReturnsAn instance of EventDisconnector.
Registers an event handler to handle events sent from the local scripts.
eventNameThe event name.optionThe event option.handlerThe event handler.payloadThe event payload.
void YaEventAPI.ReleaseEventsByBoundEntityId(number entityId)¶
Removes all event handlers bounded by entityId.
entityIdAn entity id.