Controls Checker while dead

Hello everyone,

I had a problem last night so i decided to share my code with you guys.

Issue and Solution

In FiveM, the problem lies in the inability to directly block actions triggered by RegisterKeyMapping(). This occurs because key presses execute commands rather than actions themselves (i guess, not 100% sure).
As a result, players can perform actions like using phones when their characters are dead.

To counter this, i made this script last night. It monitors inputs and prevents unauthorized actions that can’t be directly blocked through RegisterKeyMapping().

  1. Control Handling: The script actively monitors control actions in the game. It iterates through a predefined list of controls, consisting of control index and description pairs.

  2. Skipping Allowed Controls: Certain controls are allowed to be active even when the player’s character is dead. These controls are defined in the Config.allowedControlsWhileDead list. The script checks if the current control index matches any of these allowed controls and skips disabling their actions.

  3. Disabling Controls: For controls that are not in the allowed list, the script uses the DisableControlAction function to prevent those control actions from being performed. This effectively disables the corresponding inputs.

  4. Reporting Controls to Discord: If a disabled control is pressed, the script identifies the control description based on the predefined controls collection. It then reports this event to a Discord channel using a webhook. The control’s description and index are included in the message.

  5. Server Event for Discord Reporting: The script responds to the sendToDiscord server event. This event is triggered when a control action is disabled. It constructs an embed message with relevant details, such as the title, message content, and sender’s identifier.

  6. Customization: The script is highly customizable. You can configure various aspects, including the message content, colors, webhook, and more, through the Config section.

  7. ESX Integration (Optional): If enabled in the configuration, the script can include the player’s identifier (ESX identifier) when reporting to Discord. This can be useful for server administrators to identify the source of the control action.

Remember that this script is intended to enhance your gameplay experience and potentially catch unintended control actions while your character is incapacitated. The reporting to Discord allows server staff to monitor such incidents and take appropriate action if necessary.

Feel free to provide feedback or suggestions for improving this script. Your input is valuable in refining its functionality.

Thank you for using this script and contributing to a better gaming experience!

Download: Github

3 Likes

I still don’t understand the point of this script. Why is there a discord log attached to a disabledcontrolpressed ?

So you add a ControlAction in the Config to “block” any Registered KeyMapping on that Key?
However, this would require that the player has not changed the ControlAction Key in the settings. Right?

Hey. And no. We disable all actions by default and in the config u can set keys which are allowed. So the config is a “whitelist” for the keys. For example, u dont want a Discord message if the dead player moves the mouse.

You cant disable KeyMapping thats why we track the actions made by a player to take gim in the support and ask them why he uses his phone while dead

Issue and Solution

In FiveM, the problem lies in the inability to directly block actions triggered by RegisterKeyMapping(). This occurs because key presses execute commands rather than actions themselves (i guess, not 100% sure).
As a result, players can perform actions like using phones when their characters are dead.

And there is no f… way to cancel/disable Commands or even block the input :confused:

I don’t think this is how it should be handled. Instead add death checks in the command.

Yes u are absolutly right but if u buy a script for example a phone and its encrypted and u cant edit the command by ur self u have to pray that the creator will check the dead condition in a future update. This script is just a workaround if u have a script where u cant edit commands

1 Like

If u have access to the RegisterCommand then its easy possible. If not then check if u have access to a function where the name is similar to the command for example /openphone, serch for a function named openphone and add the condition here to check if a player is dead

Yeah, that’s true. But usually the creators add an editable file with such functions or you can request them. Anyways nice work!

1 Like