Skip to content

Conversation

@L1iith
Copy link

@L1iith L1iith commented Oct 7, 2025

This PR introduces a new showIf property for target options, allowing developers to conditionally display options in the target menu based on custom logic. Unlike canInteract, which is evaluated every tick, showIf is only checked when the menu is about to be shown, improving performance and enabling more flexible UI logic.

How it helps:

  • Reduces unnecessary per-tick checks for options that only need to be conditionally shown at menu open.
  • Allows for advanced UI logic, such as hiding options based on player state, permissions, or other one-time conditions.
  • Maintains backward compatibility existing options work as before if showIf is not used.
  • Simple to use: just add a showIf function to your option definition.

Example usage:

showIf = function(entity, distance, coords, name)
    return not IsPedInAnyVehicle(PlayerPedId(), false)
end

This addition gives developers more control over when options appear, without impacting runtime performance.

L1iith added 2 commits October 7, 2025 20:50
Introduces filtering of options and zones using their showIf function before sending data to the UI. This ensures only relevant options are displayed based on dynamic conditions.
add unique IDs for target options in Lua and passes them to the NUI frontend ensuring correct option selection even when filtering or reordering occurs. Updates both Lua and JS to use and transmit these IDs improving robustness of option handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant