AI Core

Every aiLib function

The full list of aiLib members: side, whether the call waits, and the page that documents it with its Lua tab.

Every member of aiLib, from ai-lib's init.lua. Most are the twin of a TypeScript function and are documented on that function's page, with the Lua call in the signature block and a Lua example tab. Waits means the call pauses until the answer comes: call it inside a thread (see Functions that wait).

Methods of a class (points:add(...), job:set(...)) are listed with their class.

Both sides

FunctionWaitsDocumented on
aiLib.sidenoLib for Lua
aiLib.every(ms, fn, options?), job:set(active), job:stop(), job.runningnoScheduling: every
aiLib.waitFor(check, timeout?, interval?)yesScheduling: waitFor
aiLib.formatText(text, ...)noText and numbers: formatText
aiLib.locale(resource?)noLocale: createLocale
aiLib.fail(error)noActions and client input: fail
aiLib.numbers.round(value, decimals?)noText and numbers: round
aiLib.numbers.groupDigits(value, separator?)noText and numbers: groupDigits
aiLib.numbers.headingTo(from, to)noPositions: headingTo
aiLib.stripGameText(text)noText and numbers: stripGameText
aiLib.notify(...): client (text, kind?, duration?), server (source, text, kind?, duration?)noClient: Shared UI, Server: Players
aiLib.inventory, aiLib.world, aiLib.appearance, aiLib.mdtsee belowThe members differ per side (below).

Client

FunctionWaitsDocumented on
aiLib.triggerServerCallback(name, args?, timeout?)yesTalking to the server
aiLib.onServerCallback(name, handler)noTalking to the server
aiLib.onServerEvent(name, handler)noTalking to the server
aiLib.callAction(name, args?, { fallback, timeout?, silent? })yesTalking to the server
aiLib.cache (ped, playerId, serverId, vehicle, seat, weapon), aiLib.cache.onChange(key, handler)noThe local player
aiLib.player (coords, heading, distanceTo, freeze, teleport, playAnim, stopAnim)teleport yesThe local player
aiLib.fadeOut(ms?), aiLib.fadeIn(ms?)yesThe local player
aiLib.playerPed(serverId)noThe local player
aiLib.nearestPlayer(metres, { from?, filter? })noThe local player
aiLib.playerData.get(key), aiLib.playerData.onChange(key, handler)noLua-only helpers
aiLib.Points.new(): :add, :addModel, :addVehicle, :remove, :clear, :refreshnoInteraction points
aiLib.Zones.new(): :add, :remove, :clear, :isInsidenoZones
aiLib.LocalPed.new(options): :removenoPeds, blips and props
aiLib.Blips.new(): :add, :get, :remove, :clear; aiLib.Blips.create(options)noPeds, blips and props
aiLib.progress(options), aiLib.progress.cancel(), aiLib.progress.isRunning()progress yesShared UI
aiLib.menu.show(request, listeners?)yesShared UI, the menu table
aiLib.input(request) / aiLib.menu.inputyesShared UI
aiLib.itemPicker(request) / aiLib.menu.itemPickeryesShared UI
aiLib.skillCheck(difficulty, keys?) / aiLib.menu.skillCheckyesShared UI
aiLib.lockpick(options?) / aiLib.menu.lockpickyesShared UI
aiLib.showPrompt(id, text), aiLib.hidePrompt(id), aiLib.onPromptPressed(handler)noShared UI
aiLib.hud (hide, show, visible)noScreens and controls
aiLib.keyHints (show, hide)noScreens and controls
aiLib.controls (disable, disableAll, enable)noScreens and controls
aiLib.Keybind.new(options): :disablenoKeybinds
aiLib.inventory (openInventory, hasItem, currentWeapon)noLayers through ai-core
aiLib.world (pauseSync, resumeSync)noLayers through ai-core
aiLib.appearance (apply, read, openMenu, wearOutfit, reloadSkin)noLayers through ai-core
aiLib.gestures (isHandsUp, isPointing, provider, playEmote, cancelEmote, emoteProvider)noLayers through ai-core
aiLib.seatbelt (isOn, onChange, provider)noLayers through ai-core
aiLib.radial (add, remove, refresh)noLayers through ai-core
aiLib.mdt.open()noLayers through ai-core
aiLib.nearestVehicle(metres, { networked?, notOwn?, filter? })noVehicles and entities
aiLib.waitForEntity(netId, timeout?)yesVehicles and entities
aiLib.raycast(from, to, options?)noProbes and loading
aiLib.groundZ(x, y, z?), aiLib.locationName(coords?), aiLib.vehicleLabel(vehicle), aiLib.waypoint()noProbes and loading
aiLib.pedHeadshot(ped, transparent?, timeout?)yesProbes and loading
aiLib.onShot(handler)noProbes and loading
aiLib.requestModel, requestAnimDict, requestAnimSet, requestPtfxAsset, requestTextureDict, requestWeaponAsset (name, timeout?)yesProbes and loading

aiLib.ModelPoints and aiLib.targets are internal (they serve Points:addModel and the target script adapters); do not call them.

Server

FunctionWaitsDocumented on
aiLib.onClientCallback(name, handler, { rate?, lock?, ace? })noClient input
aiLib.onClientEvent(name, handler, { rate?, ace? })noClient input
aiLib.triggerClientCallback(name, source, args?, timeout?)yesClient input
aiLib.progressFor(source, options)yesClient input
aiLib.minigameFor(source, options)yesClient input
aiLib.isAdmin(source, ace?)noLua-only helpers
aiLib.addCommand(name, options, handler)noCommands
aiLib.online (character, name, jobs, gangs, jobGrade, gangGrade, dutyJob, sources)noLua-only helpers
aiLib.onCharacter({ loaded?, unloaded? })noPlayers and characters
aiLib.playersNear(source, radius), aiLib.playersNearEntity(entity, radius), aiLib.nearestPlayerTo(source, metres, filter?)noPlayers and characters
aiLib.RateLimit.new(count, windowMs): :take(source), :release(source)noPlayers and characters
aiLib.inventory (addItem, removeItem, getItemCount, hasItem, canCarryItem, getItems, clearInventory, registerStash, openInventory, registerUsableItem, getItemDefinition, registerShop, openShop)noItems
aiLib.spawnVehicle(options)yesVehicles
aiLib.vehicleKeys (give, remove, has)noVehicles
aiLib.vehicleFromNet(netId), aiLib.vehicleNearPlayer(source, netId, options?), aiLib.nearestVehicleTo(source, metres, filter?)noVehicles
aiLib.billing (send, unpaid, pay, provider)unpaid yesMoney and banking
aiLib.banking (open, societyBalance, provider)noMoney and banking
aiLib.dispatch.alert(alert)noJobs and services
aiLib.prison (jail, release, timeLeft)noJobs and services
aiLib.mdt (record, provider)noJobs and services
aiLib.ems (available, distress, provider)noJobs and services
aiLib.stress (gain, relieve, provider)noJobs and services
aiLib.world (getWeather, setWeather, getTime, setTime, setBlackout, freezeTime)noWorld
aiLib.phone (number, sourceOf, hasPhone, mail, message, notify)noPhone and appearance
aiLib.appearance (get, provider)get yesPhone and appearance
aiLib.aiLog(channel, message, options?)noLogs

On this page