Scripts Guides
Exports & Events
Client

EXPORTS & EVENTS

This guide explains how to utilize events and exports with the onex-creation script. It assists you in opening menus, fetching data, and loading player models.

IMPORTANT NOTE ➤ You should be familiar with Lua and the basics of FiveM events and exports. It's also helpful to have some basic knowledge of HTML and CSS.

OPEN MENU

By using this event or export you can open emote menu.

TriggerEvent('onex-emotes:client:OpenMenu')

IS MENU OPEN?

return value : boolean

--return boolean
exports['onex-emotes']:isMenuOpen()

PLAY EMOTE

With this event or export, you can play any emote without needing to open the menu. It is useful for animations like eating food or other scenarios.

ARGUMENTS :

  • category: string
    • EXAMPLE VALUE: all_emotes or valid_emote_categ

    You can also use all_emotes as the category, so you don't need to specify each time which category your desired emote belongs to.


  • emote_name: string

  • ped: number (optional)

    If you set this to false, it will use the default value PlayerPedId(). To have a different player/ped play the animation, specify that player/ped.


  • coords: vector3 (optional)

    A vector3 representing the coordinates where the emote will be played. As this is optional, you can also set it to false, which will play the emote at the player's current position.


  • rotation: vector3 (optional)

    A vector3 representing the rotation of the player. When the emote is played, the ped's rotation will change if this value is not false/nil. You can also set it to false, which will use the player's current rotation.

-- category : string, emote_name : string, ped : number, coords : vector3, rotation : vector3
TriggerEvent('onex-emotes:client:PlayEmote' , categ, ename, ped, coords, rot)

CANCEL EMOTE

Cancel playing aniamtion.

-- force : boolean (optional)
TriggerEvent('onex-emotes:client:CancelEmote' , force)

[GET/SET] CAN CANCEL EMOTE?

SET

Set the state to determine if the emote can be canceled at this moment, either by a trigger or by the player.

-- boolean 
TriggerEvent('onex-emotes:client:setCanCancelEmote' , boolean)

GET

Set the state to determine if the emote can be canceled at this moment, either by a trigger or by the player.

exports['onex-emotes']:CanCancelEmote()

[SET/GET] CAN PLAYER PLAY EMOTE

SET

You can use this to block or unblock the emote from playing.

ARGUMENTS :

  • canplay : boolean
-- canplay : boolean
TriggerEvent('onex-emotes:client:setCanPlayEmote' , boolean)

GET

Use this export to know can player right now play emote or not.

ARGUMENTS :

  • canplay : boolean
-- canplay : boolean
exports['onex-emotes']:CanPlayEmote()

HANDLE WALK STYLE

SET WALK STYLE

Use this export to change current walk style.

RESET WALK STYLE :

For resetting walk style to default , pass walk_styleName argument value to reset.

walk_styleName : string --> reset

exports['onex-emotes']:setWalkstyle(walk_styleName)

RESTORE WALK STYLE

Use this to restore the walking style. If you've reset the walking style for a task and want to reapply the previously saved style, you can achieve that with this export.

exports['onex-emotes']:restoreWalkStyle()

HANDLE EXPRESSION

SET EXPRESSION

Use this export to change current expression.

RESET EXPRESSION :

For resetting expression to default , pass expression_name argument value to reset.

expression_name : string --> reset

exports['onex-emotes']:setExpression(expression_name)

RESTORE EXPRESSION

Use this to restore the face expression. If you've reset the expression for a task and want to reapply the previously saved style, you can achieve that with this export.

exports['onex-emotes']:restoreExpression()

GET EMOTES OBJECT

To access the Emotes object, inside onex-emotes/shared/emotes.lua.

exports['onex-emotes']:RetrieveEmotes()

[SET/GET]EMOTE SETTINGS STATE

SET

This is the Emote Menu's upper section:

If a player has enabled or disabled any of these options via the menu, you can also control these settings programmatically through an event.


USE CASE: Suppose you are playing a food animation, and you need to enable or disable the movement button accordingly. You can achieve this by setting up the configuration as shown below.

-- types -> [key : string] : [value (true/false) : string]
 
local Settings = {
  ["canmovealways"] = 'true',  
  ["emoteloop"] = 'false',
  ["upperbody"] = 'true',
  ["canmovealways"] = 'true',
  ["preview"] = 'false',
}
 
exports['onex-emotes']:setEmoteSettingState(Settings)

If you don’t want to modify a particular setting, such as emoteloop, simply exclude it from the Settings table. For instance, if you only want to control the upperbody setting, you can do so like this:

-- types -> [key : string] : [value (true/false) : string]
 
local Settings = {
  ["upperbody"] = 'true',
}
 
exports['onex-emotes']:setEmoteSettingState(Settings)

GET

It will help you to know the current player settings weather its canmovealways or any settings you can know.

KEY'S ARE :

  • canmovealways
  • emoteloop
  • upperbody
  • preview

It will RETURN : string

-- key : string
exports['onex-emotes']:getEmoteSettingState(key)