Global Functions
HELIX provides a library of globally available utility functions that can be called from any Lua script context. These cover world management, player queries, pawn queries, vehicle management, entity manipulation, and distance calculations.
World Functions
| Function | Parameters | Return Type | Description |
|---|---|---|---|
SetHUDVisibility | Aspects: table | void | Sets the visibility of HUD aspects. The table can include keys: Healthbar, Inventory, Speedometer, WeaponState, Shortcuts (all boolean). |
Player Functions
| Function | Parameters | Return Type | Description |
|---|---|---|---|
GetAllPlayers | -- | APlayerController[] | Returns a table of all player controllers currently in the world. |
GetPlayerPawn | Player?: APlayerController | APawn | Returns the pawn controlled by a player controller. If no player is specified, returns the local player's pawn. |
GetLocalPlayer | -- | APlayerController | Returns the local player controller. |
GetPlayersInArea | Coords: Vector, Radius?: number | APlayerController[] | Returns all players within a specified radius of the given coordinates. |
GetClosestPlayer | Coords: Vector, Radius?: number | APlayerController, number | Returns the nearest player controller and the distance to them, or nil if none found. |
Pawn Functions
| Function | Parameters | Return Type | Description |
|---|---|---|---|
GetAllPawns | -- | table | Returns an array of all character pawns currently in the world. |
GetPawnsInArea | Coords: Vector, Radius?: number | table | Returns all pawns within a specified radius. |
GetClosestPawn | Coords: Vector, Radius?: number | APawn, number | Returns the nearest pawn and distance, or nil if none found. |
IsPedInAnyVehicle | Pawn: APawn | boolean | Returns true if the pawn is currently inside a vehicle. |
GetVehiclePedIsIn | Pawn: APawn | AVehicle or nil | Returns the vehicle the pawn is in, or nil if not in a vehicle. |
Vehicle Functions
| Function | Parameters | Return Type | Description |
|---|---|---|---|
GetAllVehicles | -- | HVehicle[] | Returns an array of all vehicles currently in the world. |
GetVehiclesInArea | Coords: Vector, Radius?: number | HVehicle[] | Returns all vehicles within a specified radius. |
GetClosestVehicle | Coords: Vector, Radius?: number | HVehicle, number | Returns the nearest vehicle and distance, or nil if none found. |
ClearAreaOfVehicles | Coords: Vector, Radius?: number | void | Destroys all vehicles within a specified radius. |
IsAreaClearOfVehicles | Coords: Vector, Radius?: number | boolean | Returns true if no vehicles are in the area. |
DeleteVehicle | Vehicle: HVehicle | boolean | Destroys a specific vehicle. Returns true on success. |
Entity Functions
| Function | Parameters | Return Type | Description |
|---|---|---|---|
GetEntityCoords | Entity: AActor | Vector | Returns the world location of an entity. |
GetEntityRotation | Entity: AActor | Rotator | Returns the world rotation of an entity. |
GetEntityHeading | Entity: AActor | number | Returns the yaw rotation (heading) of an entity in degrees. |
SetEntityCoords | Entity: AActor, Coords: Vector | void | Teleports an entity to the specified world location. |
SetEntityRotation | Entity: AActor, Rotation: Rotator | void | Sets the world rotation of an entity. |
SetEntityHeading | Entity: AActor, Heading: number | void | Sets the yaw rotation (heading) of an entity in degrees. |
DeleteEntity | Entity: AActor | void | Destroys an entity, removing it from the world. |
DoesEntityExist | Entity: AActor | boolean | Returns true if the entity is valid and exists in the world. |
AttachActorToActor | Actor: AActor, TargetActor: AActor, Location?: Vector, Rotation?: Rotator, Socket?: string, AttachmentRules?: table, bDisableCollision?: boolean | boolean | Attaches an actor to another actor, optionally at a named socket. |
AttachActorToComponent | Actor: AActor, TargetComponent: USceneComponent, Location?: Vector, Rotation?: Rotator, Socket?: string, AttachmentRules?: table, bDisableCollision?: boolean | boolean | Attaches an actor to a scene component, optionally at a named socket. |
DetachActor | Actor: AActor, DetachmentRules?: table | void | Detaches an actor from any parent. |
Distance Functions
| Function | Parameters | Return Type | Description |
|---|---|---|---|
GetDistanceBetweenCoords | Coords1: Vector, Coords2: Vector | number | Returns the distance between two world positions. |
GetDistanceBetweenActors | Actor1: AActor, Actor2: AActor | number or nil | Returns the distance between two actors, or nil if either is invalid. |
Examples
- Blueprint
- Lua
- JavaScript
// Global functions are accessed via Lua scripting.
// See the Lua tab for usage examples.
-- Get all players in the server
local players = GetAllPlayers()
for _, pc in ipairs(players) do
print("Player controller:", pc)
end
-- Get closest player to a location
local closest, dist = GetClosestPlayer(Vector(0, 0, 0), 5000)
if closest then
print("Closest player is " .. tostring(dist) .. " units away")
end
-- Get entity location and heading
local pawn = GetPlayerPawn()
local coords = GetEntityCoords(pawn)
local heading = GetEntityHeading(pawn)
-- Teleport an entity
SetEntityCoords(pawn, Vector(1000, 2000, 100))
-- Check if a pawn is in a vehicle
if IsPedInAnyVehicle(pawn) then
local veh = GetVehiclePedIsIn(pawn)
print("In vehicle:", veh)
end
-- Get distance between two points
local dist = GetDistanceBetweenCoords(Vector(0, 0, 0), Vector(300, 400, 0))
print("Distance:", dist)
// Global functions follow the same pattern via PuerTS or Helix JS bindings.
// Refer to the Lua examples for function signatures.
note
These global functions are designed to provide a familiar scripting experience for FiveM and GTA Online developers migrating to HELIX. Function names follow similar conventions where applicable.