# SCRIPT::TRIGGER_SCRIPT_EVENT

- **Hash:** `0x5AE99C571D5BBE5D`
- **Namespace:** SCRIPT
- **Runtime name (Lua/JS):** `TriggerScriptEvent`
- **Side:** client (game native)
- **Name status:** official
- **Documentation:** described
- **Since game build:** 1207
- **URL:** https://natives.borderlinerp.com/natives/SCRIPT/TRIGGER_SCRIPT_EVENT

## Signature

```c
void TRIGGER_SCRIPT_EVENT(int eventGroup, Any* eventData, int eventDataSize, int scriptMetadataIndex, int* playerBits);
```

## Parameters

- `eventGroup` (`int`)
- `eventData` (`Any*`)
- `eventDataSize` (`int`)
- `scriptMetadataIndex` (`int`)
- `playerBits` (`int*`)

## Returns

`void`

## Description

eventGroup: 0 = SCRIPT_EVENT_QUEUE_AI (CEventGroupScriptAI), 1 = SCRIPT_EVENT_QUEUE_NETWORK (CEventGroupScriptNetwork), 2 = unk, 3 = unk, 4 = SCRIPT_EVENT_QUEUE_SCRIPT_ERRORS (CEventGroupScriptErrors)

Note: eventDataSize is NOT the size in bytes, it is the size determined by the SIZE_OF operator (RAGE Script operator, not C/C++ sizeof). That is, the size in bytes divided by 8 (script variables are always 8-byte aligned!).

playerBits (also known as playersToBroadcastTo) is a bitset that indicates which players this event should be sent to. In order to send the event to specific players only, use (1 << playerIndex). Set all bits if it should be broadcast to all players.

## Usage

### Lua

```lua
local eventData, playerBits = TriggerScriptEvent(eventGroup, eventDataSize, scriptMetadataIndex)

-- always available, by hash
local eventData, playerBits = Citizen.InvokeNative(0x5AE99C571D5BBE5D, eventGroup, Citizen.PointerValueInt(), eventDataSize, scriptMetadataIndex, Citizen.PointerValueInt())
```

### JavaScript

```js
const [eventData, playerBits] = TriggerScriptEvent(eventGroup, eventDataSize, scriptMetadataIndex);

// by hash
const [eventData, playerBits] = Citizen.invokeNative('0x5AE99C571D5BBE5D', eventGroup, Citizen.pointerValueInt(), eventDataSize, scriptMetadataIndex, Citizen.pointerValueInt());
```

### C#

```csharp
var eventData = new OutputArgument();
var playerBits = new OutputArgument();
Function.Call((Hash)0x5AE99C571D5BBE5D, eventGroup, eventData, eventDataSize, scriptMetadataIndex, playerBits);
// eventData.GetResult<int>()
// playerBits.GetResult<int>()
```

- Pointer (out) arguments are not passed in Lua/JS: their values are returned after the result, in order.
- `Any*` arguments are often structs. Build them with a DataView buffer and pass it with `:Buffer()` — see the examples and notes below.

*Sources: alloc8or RDR3 NativeDB.*
