esx_core
esx_core copied to clipboard
[Bug] - es_extended - KeyMapping interfere with es_extended when it shouldn't
Hi,
Describe the bug If I try to create a KeyMapping on another script, when pressing the key it will show the message error 'Invalid Command - /cmd'.
To Reproduce Steps to reproduce the behavior: Create a client-side script with for example:
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')
Expected behavior Nothing, shouldn't interfere with other scripts.
Screenshots
Debug Info (please complete the following information):
- OS: Linux
- FiveM Artifact: Latest recommended
- ESX Version: 1.10.5
Additional context
This issue is from this part of the code located in es_extended/server/main.lua
.
AddEventHandler("chatMessage", function(playerId, _, message)
local xPlayer = ESX.GetPlayerFromId(playerId)
if message:sub(1, 1) == "/" and playerId > 0 then
CancelEvent()
local commandName = message:sub(1):gmatch("%w+")()
xPlayer.showNotification(TranslateCap("commanderror_invalidcommand", commandName))
end
end)
@s1nyx Hi! I copied your code into a plain client-side lua file and didn't experience any problems, the chatMessage is only called when you actually try to call a non-valid command, otherwise it is not called.
For me your code worked flawlessly, it up the hand nicely then down the hand I didn't get any errors.
@s1nyx Hi! I copied your code into a plain client-side lua file and didn't experience any problems, the chatMessage is only called when you actually try to call a non-valid command, otherwise it is not called.
For me your code worked flawlessly, it up the hand nicely then down the hand I didn't get any errors.
Hi,
Let me check again. I'll get back to you asap.
Hi! @s1nyx Any news?
Hi! @s1nyx Any news? Hi,
The issue came from the fact that I didn't register the command with the -, only the +. Now fixed and works perfectly.
Have a nice day.