Skip to content

SA:O Lua API

COMPLETE SA:O REFERENCE

302 APIs added or extended by San Andreas Online

Every public Lua function added or extended by San Andreas Online is listed below. Browse the six areas, filter by where an API runs, or enter part of a function name.

82 APIs

NPCs and gameplay AI

Walking styles, ambient populations, traffic, and actions driven by GTA’s original AI.

2 APIs

NPC walking styles

Make an NPC use the natural movement style of its current character model.
System guide →

30 APIs

Ambient NPCs and road traffic

Ask GTA for suitable NPCs, vehicles, spawn points, groups, and ambient behavior.
System guide →
updateAmbientPedPopulationModels

Runs GTA's ped-only zone-model residency pass around an origin without enabling unmanaged population creation.

client
resetAmbientPedPopulationModels

Releases the stock population-model residency established by the ambient-ped update pass.

client
addPedNativeGunAimedAtEvent

Inserts GTA's real aimed-at event on the authoritative ambient-ped owner.

client
addPedNativeDamageResponseEvent

Replays GTA's civilian damage decision on the authoritative owner without applying physical damage again.

client
getAmbientVehicleSpawnCandidate

Ask GTA to choose a valid road lane, position, direction, speed, and driving style for a vehicle near the player—without creating the vehicle.

client
getAmbientVehicleModelCandidate

Ask GTA which civilian road vehicle naturally fits the current area and population settings—without creating it.

client
getAmbientVehicleOccupantModelCandidate

Ask GTA which pedestrian skins naturally fit a vehicle, so it can be created with a suitable driver and passengers.

client
getAmbientPedSpawnCandidate

Ask GTA where it would naturally place an NPC near a position. The result includes the suggested skin, NPC type, position, and facing direction—without creating the NPC.

client
getAmbientPedPopulationProfile

Returns GTA's current ambient population targets, zone state, density multipliers, and gang weights.

client
resetAmbientPedPopulationZonesToBootstrap

Restores the stock main.scm population-zone bootstrap inside San Andreas Online's reversible population world state.

client
setAmbientPedPopulationZoneState

Overrides selected native population fields for one GTA navigation zone inside the reversible population world state.

client
isAmbientPedSphereVisible

Runs GTA's camera-frustum sphere test without creating an entity.

client
getAmbientPedGangGroupCandidate

Asks GTA for a native ambient gang-group placement with two to four proposed members.

client
getAmbientPedCivilianCoupleCandidate

Ask GTA for two compatible civilian skins and nearby path positions that can spawn together as a walking couple.

client
acquirePedNativeGroup

Put several NPCs into one group so GTA treats them as a single walking group and manages their shared movement.

client
releasePedNativeGroup

Releases a native ambient group token owned by the calling resource.

client
isPedNativeGroupActive

Reports whether the calling resource still owns a live native ambient group.

client
getPedNativeGroupDiagnostic

Returns focused ownership and native-member diagnostics for one ambient group token.

client
addPedNativeDamageEvent

Replay a server-approved native NPC hit on the victim client so GTA applies the health, armour, hit reaction, and fall response once.

client
addPedNativeBikeJackTask

Installs GTA's canonical bike-jacked task on the authoritative local player after a synchronized ambient gang carjack is validated.

client
isPedNativeAmbientCopWanderTask

Reports whether San Andreas Online's safe ambient-cop wander task is the ped's current primary task.

client
validatePedNativeCouple

Pre-flight check that reports whether two peds can form a native GTA couple and which one should lead.

client
acquirePedNativeCouple

Pair two NPCs and GTA makes them walk together, choose their side, hold hands, and look at each other. They separate if they move too far apart.

client
releasePedNativeCouple

Releases a native couple lease owned by the calling resource.

client
isPedNativeCoupleActive

Reports whether the calling resource still owns a live native couple.

client
getPedNativeCoupleDiagnostic

Returns focused lease, task, and per-member diagnostics for one native couple token.

client
acquirePedNativeCouplePresentation

Opens an observer-side presentation channel so a non-syncing client can present two peds as a walking couple.

client
updatePedNativeCouplePresentation

Refreshes the observer-side couple pairing and walk-side presentation for one token.

client
releasePedNativeCouplePresentation

Closes an observer-side couple presentation channel owned by the calling resource.

client
isPedNativeCouplePresentationActive

Reports whether the calling resource still owns a live observer-side couple presentation.

client

50 APIs

NPC actions and mission behavior

Give NPCs native movement, driving, combat, interaction, and action sequences, and control gang-tag progress.
System guide →

Movement & social

12 APIs
setPedGoTo

Send an NPC straight toward a nearby coordinate. GTA handles the walk or run, slows the NPC down, and stops it inside the arrival radius.

client
setPedNavigateTo

Give an NPC a destination and GTA's pedestrian pathfinder takes over: it chooses a route through the native path network, goes around buildings, walks or runs naturally, slows down, and stops near the target.

client
setPedChatWith

Pair two NPCs and GTA makes them face each other and perform its original conversation behavior, with one character leading and the other replying.

client
setPedStandStill

Queues GTA's simple stand-still task on a simulated ped.

client
setPedJump

Starts GTA's native jump, airborne, optional climb, and landing task chain on a ped simulated by this client.

client
setPedTurnToFace

Queues GTA's native body-turn task so an owned ped faces another live ped.

client
setPedGoToOffset

Tell an NPC to move to a chosen side and distance around another NPC. GTA tracks the other NPC while approaching that offset.

client
setPedWander

Tell an NPC to wander and GTA's original pedestrian AI takes over: it follows the native path network, chooses its own direction from node to node, and keeps walking or running without Lua waypoints.

client
setPedScriptedSpeechMuted

Enables or suppresses a ped's GTA scripted speech without muting unrelated game audio.

client
setPedFacialTalk

Requests GTA's native FACTALK expression on a streamed ped's persistent facial controller.

client
stopPedFacialTalk

Stops all active requests on a streamed ped's native facial controller.

client
isPedNativeTaskReady

Check whether a living, streamed ped has its GTA AI brain back and is ready for a native task call. This is useful just after stream-in or a cutscene rebuild, when the element exists before GTA has finished recreating its intelligence.

client

NPC rules

19 APIs
setPedMissionActor

Persists GTA's PED_MISSION classification on a script-created ped across native model recreation.

client
isPedMissionActor

Reports the locally persisted mission-actor policy, including while the native model is streamed out.

client
acquirePedNativeEventProfile

Exclusively leases one of San Andreas Online's stock native-event adapters for a script ped.

client
releasePedNativeEventProfile

Releases one native ped event-profile token owned by the calling resource.

client
isPedNativeEventProfileActive

Reports whether this resource's native event-profile lease is active for the current authoritative ped generation.

client
setPedStoryProtected

Persists GTA's grouped story-actor protection flags on a script ped across native recreation.

client
isPedStoryProtected

Reports the locally persisted grouped story-actor protection policy.

client
setPedSuffersCriticalHits

Persists GTA's critical-hit policy on a script ped without enabling the broader story-protection tuple.

client
getPedSuffersCriticalHits

Reads the locally persisted critical-hit policy for a script ped, including while it is streamed out.

client
setPedStayInSamePlace

Persists GTA's scalar stay-in-place flag on a script ped without assigning a stand-still task.

client
getPedStayInSamePlace

Reads the effective local stay-in-place flag for a script ped.

client
setPedNeverTargeted

Persists only GTA's never-targeted bit without enabling the grouped protagonist protection policy.

client
isPedNeverTargeted

Reads the effective local never-targeted policy for a script ped.

client
setPedPhysicalProofs

Choose exactly which kinds of physical damage an NPC ignores: bullets, fire, explosions, collisions, or melee hits.

client
getPedPhysicalProofs

Read the NPC's five stored physical-damage protections so a resource can change them temporarily and restore them later.

client
setPedCanBeDraggedOut

Choose whether a script-created NPC can be pulled out of its vehicle during a carjack. Set false to keep an important driver or passenger in the car; set true to allow the normal GTA extraction.

client
canPedBeDraggedOut

Check whether GTA currently allows a script-created NPC to be pulled out of its vehicle.

client
setPedOnlyDamagedByPlayer

Make a script-created NPC ignore GTA damage events whose attacker is not a player, while still allowing attacks attributed to a player. This matches the story-script rule used for actors who should be hurt by the player but not by other NPCs.

client
isPedOnlyDamagedByPlayer

Check whether a script-created NPC currently uses GTA's player-attributed-damage-only rule.

client

57 APIs

Story and mission tools

Streaming, mission vehicles, scene loading, cameras, cutscenes, audio, text, and recorded routes.

2 APIs

Streaming control

Keep important elements streamed while a resource needs their native GTA state.
System guide →

8 APIs

Mission vehicle behavior

Control locks, tyres, physical protection, collision loading, and mission vehicle checks.
System guide →

3 APIs

Scene loading and vehicle helpers

Prepare a world area and use small GTA mission vehicle primitives.
System guide →

14 APIs

Scripted cameras

Own and control GTA cameras, movement, tracking, fades, widescreen, and near clip.
System guide →
acquireScriptCamera

Acquires the resource-exclusive GTA script camera and returns a generation token.

client
releaseScriptCamera

Restores captured gameplay camera state and optionally leaves a successful scene under its black fade.

client
isScriptCameraLeaseActive

Reports whether the calling resource still owns the specified camera generation.

client
setScriptCameraFixed

Place the camera at one position and make it look at another, using an immediate cut or GTA's camera transition.

client
moveScriptCamera

Move the camera between two world positions over a chosen duration, linearly or with GTA's original easing.

client
trackScriptCamera

Animate what the camera looks at from one point to another, independently from the camera's own movement.

client
setScriptCameraPersist

Selects whether completed position and target tracks retain their endpoints.

client
resetScriptCamera

Resets GTA's scriptable camera interpolation components without releasing the lease.

client
fadeScriptCamera

Runs GTA's native fade under the current camera lease.

client
isScriptCameraFading

Reports the native fade state for the current camera generation.

client
isScriptCameraMoveRunning

Reports whether the native position track is still running.

client
isScriptCameraTrackRunning

Reports whether the native look-at track is still running.

client
setScriptCameraWidescreen

Uses GTA's native widescreen transition under the current lease.

client
setScriptCameraNearClip

Sets GTA's scripted near clip, or clears the override with false.

client

11 APIs

Original GTA cutscenes

Load, play, fade, skip, and release GTA’s original file-based cutscenes.
System guide →

6 APIs

Mission sounds and completion music

Load and play GTA mission audio and the original mission-complete tunes.
System guide →

7 APIs

Mission text and HUD messages

Show GTA mission text, help prompts, and large on-screen messages.
System guide →

6 APIs

Recorded vehicle routes

Load and play GTA vehicle recordings for scripted driving scenes.
System guide →

32 APIs

World, maps and models

Custom models, protected assets, imported maps, radar tiles, environment zones, seabed, and runtime collision.

11 APIs

Custom models

Allocate stable custom model IDs and resolve the GTA slots used by each client.
System guide →

1 APIs

Encrypted resource assets

Authenticate and apply protected DFF, TXD, and COL files without exposing keys or plaintext to Lua.
System guide →

6 APIs

SA-MP maps and object materials

Parse SA-MP map source and control object materials and streaming limits.
System guide →

3 APIs

Custom radar tiles

Replace individual radar and F11 map tiles with resource-provided textures.
System guide →

3 APIs

Ocean and seabed boundaries

Move or restore the outer boundary of GTA’s procedural seabed.
System guide →

6 APIs

World environment zones (CULL)

Read, create, change, disable, and restore GTA environment zones.
System guide →

2 APIs

Lua-generated collision

Build collision data at runtime and apply it to models.
System guide →

105 APIs

Objects, environment and effects

Physics, breakable objects, ropes, fire, birds, foliage, and model lights or effects.

2 APIs

Dynamic object physics

Let synchronized objects use GTA’s native physical movement.
System guide →

15 APIs

Breakable objects

Break object models into physical fragments and control their durability.
System guide →

28 APIs

Ropes

Create and control GTA ropes, holders, carried objects, length, movement, and physics.
System guide →
createRope

Creates a managed rope driven by one of GTA's own native rope types.

client + server
getRopeType

Returns which native GTA rope type a rope runs.

client + server
setRopeType

Changes which native GTA rope type a rope runs.

client + server
getRopeDuration

Returns the total lifetime a rope was created with, in milliseconds.

client + server
setRopeDuration

Sets a rope's total lifetime in milliseconds.

client + server
getRopeRemainingTime

Returns how long a rope still has before it expires.

client + server
setRopeRemainingTime

Extends or shortens a live rope without recreating it.

client + server
getRopeHolder

Returns the element a rope hangs from.

client + server
setRopeHolder

Sets the element a rope hangs from.

client + server
getRopeHolderOffset

Returns the local offset of the rope's attachment on its holder.

client + server
setRopeHolderOffset

Moves the rope's attachment point on its holder.

client + server
getRopeLength

Returns a rope's length.

client + server
setRopeLength

Changes a rope's length, which is how attached cargo is raised or lowered.

client + server
getRopeWinchHeight

Returns a rope's winch height.

client + server
setRopeWinchHeight

Sets a rope's winch height.

client + server
getRopeFixedNode

Returns which node of the rope is pinned.

client + server
setRopeFixedNode

Pins one node of the rope.

client + server
isRopeOnGround

Reports whether a rope is set to sit on the ground.

client + server
setRopeOnGround

Sets whether a rope sits on the ground.

client + server
getRopeTopVelocity

Returns the velocity applied at the top of a rope.

client + server
setRopeTopVelocity

Applies velocity at the top of a rope.

client + server
isRopePhysicsEnabled

Reports whether a rope is simulated by the native solver.

client + server
setRopePhysicsEnabled

Turns the native rope solver on or off for one rope.

client + server
getRopeCarriedElement

Returns the element a rope is currently carrying.

client + server
attachElementToRope

Attaches an element to a rope so the native solver carries it.

client + server
detachElementFromRope

Releases whatever a rope is carrying.

client + server
getRopePositionAt

Returns an interpolated point along a rope, read from the live native solver.

client
isRopeActive

Reports whether a rope currently holds one of GTA's eight native rope slots.

client

20 APIs

Fire

Create synchronized fires and control their lifetime, damage, spread, source, and target.
System guide →
createFireEXTENSION

Creates a managed fire element when given an options table, or the original native GTA fire otherwise.

client + server
extinguishFireEXTENSION

Destroys one managed fire element, in addition to the standard radius and no-argument forms.

client + server
getFireStrength

Returns the strength multiplier of a managed fire.

client + server
setFireStrength

Changes how large a managed fire burns, without recreating it.

client + server
getFireDuration

Returns the total lifetime a managed fire was created with, in milliseconds.

client + server
setFireDuration

Sets the total lifetime of a managed fire in milliseconds.

client + server
getFireRemainingTime

Returns how long a managed fire still has to burn, in milliseconds.

client + server
setFireRemainingTime

Extends or shortens a burning managed fire without recreating it.

client + server
isFireDamageEnabled

Reports whether a managed fire damages anything at all.

client + server
setFireDamageEnabled

Turns damage on or off for one managed fire, leaving the visual effect alone.

client + server
getFireDamageTargets

Returns which element categories a managed fire is allowed to damage.

client + server
setFireDamageTargets

Restricts a managed fire to damaging only selected element categories.

client + server
isFireSpreadEnabled

Reports whether a managed fire can spawn further fires.

client + server
setFireSpreadEnabled

Allows or prevents a managed fire from spreading.

client + server
getFireMaxGenerations

Returns how many further generations a spreading managed fire may produce.

client + server
setFireMaxGenerations

Bounds how far a spreading managed fire can propagate.

client + server
getFireSource

Returns the element blamed for a managed fire's damage.

client + server
setFireSource

Sets which element is held responsible for a managed fire's damage.

client + server
getFireTarget

Returns the element a managed fire is following.

client + server
setFireTarget

Attaches a managed fire to an element so it follows wherever that element goes.

client + server

20 APIs

Birds

Create birds and control their flight, appearance, visibility, and reactions to shots.
System guide →
createBird

Creates a managed bird element with its own renderer and flight control.

client
processBirdGunShot

Runs a gunshot trace against every shootable managed bird, for custom weapon systems.

client
getBirdVelocity

Returns the current velocity of a managed bird.

client
setBirdVelocity

Sets a managed bird's velocity immediately.

client
getBirdTargetVelocity

Returns the velocity a managed bird is easing toward.

client
setBirdTargetVelocity

Sets where a managed bird should be heading and lets it ease toward it.

client
getBirdSize

Returns the size multiplier of a managed bird.

client
setBirdSize

Changes how large a managed bird is drawn.

client
getBirdColors

Returns the body and wing colors of a managed bird.

client
setBirdColors

Recolors a managed bird's body and wings.

client
getBirdWingBeatTime

Returns the wing beat period of a managed bird.

client
setBirdWingBeatTime

Changes how fast a managed bird flaps.

client
getBirdRenderDistance

Returns the distance at which a managed bird stops being drawn.

client
setBirdRenderDistance

Sets how far away a managed bird remains visible.

client
isBirdCurvedFlightEnabled

Reports whether a managed bird banks through curves instead of flying straight.

client
setBirdCurvedFlightEnabled

Turns curved flight on or off for one managed bird.

client
isBirdShootable

Reports whether a managed bird takes part in gunshot hit testing.

client
setBirdShootable

Makes a managed bird shootable, or purely decorative.

client
isBirdMovementEnabled

Reports whether a managed bird is currently flying or frozen.

client
setBirdMovementEnabled

Freezes one managed bird in place or lets it fly again.

client

7 APIs

Grass and foliage

Create custom foliage patches from Lua-controlled ground triangles.
System guide →

13 APIs

Model lights and effects (2DFX)

Add, remove, inspect, and change lights and other effects stored on a model.
System guide →

18 APIs

Rendering, audio and client

Renderer diagnostics, markers, vehicle sound, GTA radio, visual settings, and web links.

6 APIs

Rendering limits and distant lights

Inspect expanded renderer capacity and control distant world lights.
System guide →

2 APIs

Mission markers and marker limits

Inspect marker capacity and draw GTA’s pulsing mission-area marker.
System guide →

4 APIs

Custom vehicle sounds

Load custom engine banks and trigger configured backfire sounds and flames.
System guide →

2 APIs

GTA radio playback

Read and restore the current GTA radio station, track, queue, and playback position.
System guide →

3 APIs

San Andreas Online visual settings

Read, change, and reset client visual options exposed by San Andreas Online.
System guide →

1 APIs

Open web links

Open an allowed HTTPS page in the player’s external browser.
System guide →

8 APIs

Server and compatibility

Verified player identity, bans, and extensions to existing MTA settings.

6 APIs

Player identity and bans

Read verified SA:O account and Discord identities and use them in server bans.
System guide →

2 APIs

Weapon glitch settings

Use the weapon-glitch options that San Andreas Online adds to existing MTA functions.
System guide →