REGISTER_KEY_MAPPING
Registers a key mapping for the current resource.
Signature
void REGISTER_KEY_MAPPING(char* commandString, char* description, char* defaultMapper, char* defaultParameter);Parameters
| Name | Type | Description |
|---|---|---|
commandString | char* | The command to execute, and the identifier of the binding. |
description | char* | A description for in the settings menu. |
defaultMapper | char* | The mapper ID to use for the default binding, e.g. |
defaultParameter | char* | The IO parameter ID to use for the default binding, e.g. |
Returns void
Description
Registers a key mapping for the current resource.
See the related cookbook post for more information.
Below you can find some examples on how to create these keybindings as well as the alternate keybinding syntax, which is preceded by ~! to indicate that it's an alternate key.
Usage
RegisterKeyMapping(commandString, description, defaultMapper, defaultParameter)
-- always works, by hash
Citizen.InvokeNative(0xd7664fd1, commandString, description, defaultMapper, defaultParameter)JavaScript and C#
RegisterKeyMapping(commandString, description, defaultMapper, defaultParameter);
// by hash
Citizen.invokeNative('0xd7664fd1', commandString, description, defaultMapper, defaultParameter);Function.Call((Hash)0xd7664fd1, commandString, description, defaultMapper, defaultParameter);Examples
local handsUp = false
CreateThread(function()
while true do
Wait(0)
if handsUp then
TaskHandsUp(PlayerPedId(), 250, PlayerPedId(), -1, true)
end
end
end)
RegisterCommand('+handsup', function()
handsUp = true
end, false)
RegisterCommand('-handsup', function()
handsUp = false
end, false)
RegisterKeyMapping('+handsup', 'Hands Up', 'keyboard', 'i')
-- Alternate keybinding syntax
RegisterKeyMapping('~!+handsup', 'Hands Up - Alternate Key', 'keyboard', 'o')Sources
Something wrong or missing? Contribute a verified note — corrections ship through pull requests.