Hand-written core event/command externs not covered by the natives generated from the FiveM natives database (see generate.py). Kept separate from fivem.shared.natives.* so regeneration never overwrites it.

These are raw externs. For an ergonomic, typed layer on top — with automatic net-event registration and unsubscribe handles — use fivem.shared.core.Events.

Note that triggerClientEvent only exists on the server and triggerServerEvent only on the client; both are declared here because the externs themselves cost nothing, but calling the wrong one for your environment fails at runtime, not at compile time.

Static methods

@:native("AddEventHandler")staticaddEventHandler(eventName:String, handler:Function):Dynamic

Adds an event handler for the specified event.

Parameters:

eventName

The name of the event to listen for.

handler

The callback function executed when the event triggers.

Returns:

An opaque handle accepted by removeEventHandler.

@:native("RegisterCommand")staticregisterCommand(commandName:String, handler:(source:Int, args:Table<Int, String>, rawCommand:String) ‑> Void, restricted:Bool):Void

Registers a command that can be executed from the client/server console or chat.

args arrives as a raw, 1-based Lua table, not a Haxe Array — Haxe arrays on the Lua target are 0-based and carry their own length field, so indexing this directly with args[0] yields nil. Convert it with lua.Table.toArray(args), or use fivem.shared.core.Commands.register, which hands you a real Array<String>.

Parameters:

commandName

The name of the command to register.

handler

The function to execute when the command is run.

restricted

If true, requires ACE permissions to execute.

@:native("RegisterNetEvent")staticregisterNetEvent(eventName:String):Void

Registers a network event so it can be triggered from clients.

Parameters:

eventName

The name of the event to register.

@:native("RemoveEventHandler")staticremoveEventHandler(handle:Dynamic):Void

Detaches a handler previously returned by addEventHandler.

@:native("TriggerClientEvent")statictriggerClientEvent(eventName:String, targetSource:Dynamic, args:Rest<Dynamic>):Void

Triggers a client event for a specific player. Server-side only.

Parameters:

targetSource

The player to send to, or -1 to broadcast to everyone.

@:native("TriggerEvent")statictriggerEvent(eventName:String, args:Rest<Dynamic>):Void

Triggers an event locally, within this resource and any other resource listening for it. Does not cross the network.

@:native("TriggerLatentClientEvent")statictriggerLatentClientEvent(eventName:String, targetSource:Dynamic, bytesPerSecond:Int, args:Rest<Dynamic>):Void

Like triggerClientEvent, but streams the payload at bytesPerSecond instead of sending it in one packet. Use for anything large enough to stall the network — bulk inventory syncs, map data — so it doesn't block ordinary events. Server-side only.

@:native("TriggerLatentServerEvent")statictriggerLatentServerEvent(eventName:String, bytesPerSecond:Int, args:Rest<Dynamic>):Void

Like triggerServerEvent, but rate-limited to bytesPerSecond. Client-side only.

@:native("TriggerServerEvent")statictriggerServerEvent(eventName:String, args:Rest<Dynamic>):Void

Triggers a server event from the client.

Parameters:

eventName

The name of the event to trigger.