MRI Qbox BrasilMRI Qbox
OverextendedOx LibModulesAddKeybind

Client

Registers keybinds and simplifies interactions of the keybinds.

CKeybind Class

A table representing a keybind with the following properties.

  • name: string
  • description: string
  • currentKey: string
    • Key that the current user has this keybind set to -- disabled: boolean
    • Se a keybind está atualmente desabilitada -- isPressed: boolean
    • Estado indicando se a keybind está pressionada ou não
  • hash: number
    • Internal hash of the keybind that is used to reference it within the game itself
  • defaultKey?: string
    • Default key to set the keybind to for new players
    • NOTE: Changing this will not change the key for existing players
  • defaultMapper?: string
  • secondaryKey?: string
    • An optional secondary keybind.
  • secondaryMapper?: string
    • An optional mapper for the secondary key, otherwise using the default mapper.
  • allowInPauseMenu?: boolean
    • Permite que a keybind dispare enquanto o menu de pausa/frontend estiver ativo.
    • Padrão: false
  • disable: function(self: CKeybind, disable: boolean)
    • Built-in function to enable / disable a keybind
  • isControlPressed: function(self: CKeybind)
    • Built-in function to get the current pressed state for the keybind
  • onPressed?: function(self: CKeybind)
    • Função definida pelo usuário disparada ao pressionar a keybind
  • onReleased?: function(self: CKeybind)
    • Função definida pelo usuário disparada ao soltar a keybind

lib.addKeybind

lib.addKeybind(data)
  • data: table
    • name: string
      • Nome do comando criado para RegisterKeyMap
      • Não deve conter espaços em branco
    • description: string
      • O nome exibido em 'Settings' -> 'Key Bindings' -> 'FiveM'
    • defaultKey?: string
      • Padrão: None
    • defaultMapper?: string
      • Padrão: keyboard
    • secondaryKey?: string
    • secondaryMapper?: string
    • allowInPauseMenu?: boolean
      • Padrão: false
      • Se true, os callbacks da keybind podem rodar enquanto IsPauseMenuActive() for true
    • disabled?: boolean
      • Se a keybind deve começar desabilitada por padrão
    • onPressed?: function(self: CKeybind)
      • Função disparada ao pressionar a keybind
    • onReleased?: function(self: CKeybind)
      • Função disparada ao soltar a keybind
local keybind = lib.addKeybind({
    name = 'respects',
    description = 'press F to pay respects',
    defaultKey = 'F',
    allowInPauseMenu = true,
    onPressed = function(self)
        print(('pressed %s (%s)'):format(self.currentKey, self.name))
    end,
    onReleased = function(self)
        print(('released %s (%s)'):format(self.currentKey, self.name))
    end
})

Enable / Disable Keybinds

Keybinds can be enabled / disabled by using the disable method.

keybind:disable(true) -- disables the keybind
keybind:disable(false) -- enables the keybind

Keybind pressed states

Todas as keybinds registradas com lib.addKeybind() possuem um estado booleano que indica se estão pressionadas ou não.

Você pode obter o estado com o método a seguir

local state = keybind:isControlPressed()

On this page

Usamos cookies para anúncios e métricas. Veja a política de privacidade.