TriggerClientEvent

From GT-MP
Jump to: navigation, search
TriggerClientEvent
Server-Side Function
Utilities-terminal.png Server-Side Csharp.png C#

Triggers a client-side script event call from server-side to a Player. For the inverse method of this (client to server), see triggerServerEvent.

This method triggers the client-side onServerEventTrigger event.

Warning: This function should not be called under client connection events. (onPlayerConnected or onPlayerBeginConnect) - It will not be triggered. Instead, you should wait for onPlayerFinishedDownload.

Note: If you intend to use this to send big chunks of custom data to clients, you should be aware that you can also use downloadData and onCustomDataReceived to transfer this custom data.

Syntax

API.triggerClientEvent(Client player, string eventName, params object[] args);

Required Arguments

  • player: parameter input should be in Client type.
  • eventName: parameter input should be in string type.
  • args: parameter input should be in object type. See the Synchronized Types for which types of objects you can pass here.

Usage example

   API.triggerClientEvent(player, "FinishGame", 1, 2, 5, "Now");

References