Skip to content

Exports & events

Public exports, events and player states of Cuxial Emotes for use from other resources.

Other resources can play and cancel emotes, lock the player, change walk styles and read what the player is doing. Anything not listed on this page is internal.

All client exports act on the local player unless stated otherwise.

Client exports ​

Play and cancel ​

ExportParametersReturnsWhat it does
PlayEmoteByCommandcommand: string, variant?: numberbooleanPlays an emote, scenario, walk style or expression by its command. Returns false if the command does not exist, the player is locked or the cooldown is active.
StartAnimationPlaycommand: string, variant?: number—Same as above, without a return value.
PlayEmotedata: table, variation?: numberbooleanPlays an emote from its data table, as returned by findEmoteByCommand.
playScenarioname: string—Starts a GTA scenario in place. Does nothing in a vehicle or while locked.
CancelEmoteskipReset?: boolean—Cancels the current emote. If an upper body emote is layered on top, only that one is cancelled. With true it stops everything at once, skips the exit animation and works even while locked.
StopAnimationskipReset?: boolean—Alias of CancelEmote.
CancelUpperLayer——Cancels only the upper body animation layered on top of another emote.
CancelAllAnimations——Clears emotes and movement states (hands up, crossed arms, pointing, prone). Does nothing while locked.
PlayAnimOnNPCcommand: string, ped: number—Plays an emote or scenario from the catalog on another ped.
lua
local played = exports.cuxial_emotes:PlayEmoteByCommand('adjust')
if not played then
    print('Emote could not be played')
end

-- later
exports.cuxial_emotes:CancelEmote()

Lock and state ​

ExportParametersReturnsWhat it does
SetEmoteLocklocked: boolean, reason?: string—Locks or releases the player for the calling resource and that reason ('default' without one). See Animation lock.
IsEmoteLocked—booleanWhether any lock is active.
GetEmoteLocks—tableActive locks by resource: { [resource] = { reason, ... } }.
SetCanPlayAnimationvalue: boolean—Allows or blocks starting emotes.
CanPlayAnimation—booleanWhether emotes can be started.
SetCanCancelAnimationvalue: boolean—Allows or blocks cancelling the current emote.
SetAnimationPlayingvalue: boolean—Overrides the "an emote is playing" flag.
IsPlayingAnimation—booleanWhether an emote is playing.
isPlayerDead—booleanWhether the script considers the player dead, following deadCheck.
GetBaseLayer—table | nilCurrent emote: { data, variation, dict, anim }.
GetUpperLayer—table | nilCurrent upper body emote, same shape.
HasUpperLayer—booleanWhether an upper body emote is layered.

Animation lock ​

A lock keeps the player still in a scene of your resource. While any lock is active, the player cannot start or cancel emotes (commands, shortcuts, menu and shared emotes), raise hands, cross arms, point, ragdoll, lie down or crouch, and gets a short notice when trying. Whatever the player was doing is released when the lock starts.

Each lock belongs to the resource that sets it and to a reason, so several resources and scenes can lock at the same time. The player is free again when every lock has been released.

lua
-- Hold the player in a scripted animation
exports.cuxial_emotes:SetEmoteLock(true, 'seat')
-- ... your scene ...
exports.cuxial_emotes:SetEmoteLock(false, 'seat')

-- Who is locking the player right now
local locks = exports.cuxial_emotes:GetEmoteLocks()   -- { my_resource = { 'seat' } }

The animLock player state holds 'resource:reason' of the first active lock, or nil. It is replicated, so the server and other resources can read it to avoid starting their own animation on top. Resources that include Cuxial Bridge can use Bridge.Anim, which wraps these exports and applies the locks again if Cuxial Emotes restarts.

Always release a lock you set, with the same reason. A locked player cannot use any emote until it is released. Locks are also released when the resource that set them stops.

Catalog ​

ExportParametersReturnsWhat it does
findEmoteByCommandcommand: stringtable | nil, string | nilEmote data and its kind: 'emote', 'scenario', 'walk' or 'expression'.
buildAnimationsList—table[]The list shown in the menu. Each entry has name, title, description, category and liked. Emotes also carry isSynced, icon, tags and added.
GetAnimationFromSetsetIndex: number, animIndex: numberstring | nilCommand stored in a slot of a quick set.
buildPropsFromDataprops: table, variation?: numbertable[]Converts an emote's Options.Props into { hash, bone, placement, variant } entries.
CleanAllPedProps——Removes the emote props attached to the player.
lua
local emote, kind = exports.cuxial_emotes:findEmoteByCommand('atm')
if emote then
    print(emote.Label, kind)
end

Walk style, expression and aiming ​

ExportParametersReturnsWhat it does
SetWalkclipset: string, skipSave?: boolean—Applies a movement clipset, such as 'move_m@brave', and sets the walkstyle state. With skipSave it is not stored for the next session.
ResetWalk——Returns to the default walk and clears the walkstyle state.
RestoreLastWalkStyle——Applies the clipset in the walkstyle state again, or the default walk if there is none.
SetExpressionname: string, skipSave?: boolean—Applies a facial expression, such as 'mood_angry_1'. With skipSave it is not stored for the next session.
ResetExpression——Returns to the default expression.
SetWeaponAnimationdict?: string, name?: string—Sets the animation played while aiming with a weapon listed in data/weapons.lua. Call it without arguments to clear it.
GetWeaponAnimation—string | nil, string | nilCurrent aiming dictionary and clip.
lua
-- Your script changed the movement clipset with natives for an effect.
-- When it ends, give the player their own walk style back.
exports.cuxial_emotes:RestoreLastWalkStyle()

Movement ​

ExportParametersReturnsWhat it does
IsPlayerCrouched—boolean | nilCrouching.
IsPlayerProne—booleanLying prone.
IsPlayerCrawling—booleanCrawling.
IsHandUp—booleanHands up.
IsPointing—booleanPointing.
IsCrossArms—booleanArms crossed.
IsInRagdoll—booleanIn ragdoll triggered by the script.
SetPlayerCrouchvalue: boolean—Forces crouch on or off.
SetHandsUpvalue: boolean—Forces hands up on or off.
lua
if exports.cuxial_emotes:IsHandUp() then
    -- the player is surrendering
end

Position editor, photo mode and zones ​

ExportParametersReturnsWhat it does
GetLockedEditPosition—table | nilPosition fixed with the position editor: { x, y, z, heading }.
UnlockEditedPosition——Releases that position.
IsPhotoModeActive—booleanWhether photo mode is open.
IsCameraActive—booleanWhether the free camera is in use.
GetActiveZones—string[]Internal names of the emote zones the player is inside, as cuxial_zone_<id>.
IsInZonezoneName: stringbooleanWhether the player is inside the zone with that internal name.
GetActiveZoneCategories—string[]Names of the zone categories currently available in the menu.
lua
if exports.cuxial_emotes:IsPhotoModeActive() then return end

Server exports ​

ForcePlaySyncedEmote ​

Starts a paired emote between two players without asking for confirmation.

lua
exports.cuxial_emotes:ForcePlaySyncedEmote(requesterId, responderId, senderCommand)
ParameterTypeDescription
requesterIdnumberServer id of the player who performs senderCommand.
responderIdnumberServer id of the other player.
senderCommandstringCommand of a synchronized emote.

Returns boolean: true if the emote started. It fails if either player is offline, both ids are the same, the command is not a synchronized emote with a valid OtherEmote, or the players are further apart than sync.distance.

lua
local started = exports.cuxial_emotes:ForcePlaySyncedEmote(source, targetId, 'rasurar')

Item exports ​

condom_closed, condom_open, pregnancy_test and hiv_test are item hooks for ox_inventory. They are meant to be referenced from the item definition, not called by hand. See Installation.

Events ​

cuxial_emotes:OpenMenu ​

Client, local. Opens the emote menu. Useful from a radial menu.

lua
TriggerEvent('cuxial_emotes:OpenMenu')

cuxial_emotes:PlayQuickAnim ​

Client, network event. Plays a slot of the active quick set. The slot goes in the second argument, in the shape radial menus use.

lua
TriggerEvent('cuxial_emotes:PlayQuickAnim', nil, { id = 1 })

cuxial_emotes:ChangeSet ​

Client, network event. Switches the active quick set.

lua
TriggerEvent('cuxial_emotes:ChangeSet', nil, { id = 2 })

Both quick set events exist only when emotes.quickAnims is true.

cuxial_emotes:server:syncedEmoteStarted ​

Server, local. Fired every time a paired emote starts.

lua
AddEventHandler('cuxial_emotes:server:syncedEmoteStarted', function(requesterId, responderId, command)
    print(('%s and %s started %s'):format(requesterId, responderId, command))
end)

Player states ​

The script writes these state bags on the player. Read them from any resource.

KeyReplicatedValue
isInEmoteYestrue while an emote is playing.
inSynchronizedEmoteYesServer id of the partner during a paired emote.
walkstyleYesCurrent movement clipset.
expressionYesCurrent facial expression.
handsUpYestrue while the hands are up.
emoteProps, emotePropsUpperYesProps of the current emote.
crouchNo, local onlytrue while crouching.
animLockYes'resource:reason' of the first active animation lock, or nil. Written by the client: use it to block actions, never to grant them.
lua
-- server side
if Player(source).state.handsUp then
    -- allow the search
end

The script also reads two states that other resources set:

KeyEffect
deadThe player counts as dead when deadCheck.useStateBag is true.
isLimitedWhile it is set, the player cannot start emotes.

© Cuxial