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
.
playerId
The playerId of the target client.eventName
The event name.option
The event option.payload
The event payload.
void YaEventAPI.FireToAllClients(string eventName, EventOption option, EventPayload payload)¶
SERVER ONLY
The server sends the event to all clients.
eventName
The event name.option
The event option.payload
The event payload.
void YaEventAPI.FireToServer(string eventName, EventOption option, EventPayload payload)¶
CLIENT ONLY
The client sends the event to the server.
eventName
The event name.option
The event option.payload
The event payload.
void YaEventAPI.FireToLocal(string eventName, EventOption option, EventPayload payload)¶
Sends the event to the local handlers.
eventName
The event name.option
The event option.payload
The 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.
eventName
The event name.option
The event option.handler
The event handler.payload
The 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.
eventName
The event name.option
The event option.handler
The event handler.payload
The 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.
eventName
The event name.option
The event option.handler
The event handler.payload
The event payload.
void YaEventAPI.ReleaseEventsByBoundEntityId(number entityId)¶
Removes all event handlers bounded by entityId.
entityId
An entity id.