Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] - es_extended - KeyMapping interfere with es_extended when it shouldn't #1344

Closed
s1nyx opened this issue Apr 9, 2024 · 4 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@s1nyx
Copy link

s1nyx commented Apr 9, 2024

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
image

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 s1nyx added the bug Something isn't working label Apr 9, 2024
@s1nyx s1nyx changed the title [Bug] - esx_script - Issue [Bug] - es_extended - KeyMapping interfere with es_extended when it shouldn't Apr 9, 2024
@Gellipapa
Copy link
Member

@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
Copy link
Author

s1nyx commented Apr 14, 2024

@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.

@Gellipapa
Copy link
Member

Hi! @s1nyx Any news?

@s1nyx
Copy link
Author

s1nyx commented May 4, 2024

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.

@s1nyx s1nyx closed this as completed May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

3 participants