Skip to main content
Use config/contextMenus.lua to configure weapons, animations, and a registry-based context menu system that lets you add your own actions and providers without editing client code.

Registry-based menu system

The menu is powered by a lightweight registry available at runtime via GM.ContextMenu:
  • Actions: registerAction(id, handler) maps a menu id to a function.
  • Prefix actions: registerActionPrefix(prefix, handler) handles any id starting with the prefix.
  • Providers: register(providerFn) returns a list of items for the current click context (ground, ped, vehicle, selection).
  • Default items: Always-visible items can be added statically with Config.ContextMenuDefaultItems, or dynamically at runtime.
Handlers receive (data, meta). meta.actionId is the clicked id; meta.context mirrors build-time context and can include ground, selectionCount, targetPed, targetVehicle.

Example: register actions and a provider

config/contextMenus.lua

Hello world: your first custom action and provider

This is the smallest end-to-end example. It registers a new action that prints a message using Bridge.Debug, and a provider that shows the item when you right-click on a ped.
config/contextMenus.lua
If you want your hello world to always be visible, add it as a default item instead:
config/contextMenus.lua

Providers explained for beginners

  • Think of a provider as a menu generator. It runs each time you open the menu and returns a list of items that make sense for the current situation.
  • The ctx (context) tells you what the player pointed at:
    • ctx.ground: where the right-click happened (a vector3)
    • ctx.selectionCount: how many entities are currently selected
    • ctx.targetPed: the ped under the cursor, if any
    • ctx.targetVehicle: the vehicle under the cursor, if any
  • Return an array of items shaped like { id, label, data?, children? }:
    • id: must match a registered action or a built-in one
    • label: the text players see
    • data: optional parameters passed to the handler
    • children: optional array for submenus
Start simple. Add one item, confirm it appears in the right place, then enhance the logic or add submenus.

Default items: static and dynamic

  • Static via config: set once, shown at the bottom of every context menu.
config/contextMenus.lua
  • Dynamic via API or events: add or replace at runtime from any client script.
Default items must reference action IDs that are either built-in or registered by you. Avoid actions that require a specific data.target (for example ped_kill) because defaults do not automatically provide one. Prefer actions that operate on your selection or use meta.context.ground.

Example: add quick orders to known locations

You can also mix built-in action IDs for convenience shortcuts. This example adds two global entries that use only a fixed coordinate and your current selection:
config/contextMenus.lua
When you right-click anywhere, these entries appear. If you have peds selected, they will either walk directly to the first coordinate or engage enemies within an area around the second.
Use game/admin tools to capture coordinates and paste them into vector3(x, y, z).

Built-in action IDs you can reuse

  • Movement: goto_direct, goto_path, goto_stand (require data.coord)
  • Combat: attack_area (requires data.coord)
Other IDs like attack, ped_remove_weapon, ped_revive, ped_toggle_god, ped_toggle_freeze, vehicle_unmount_all, vehicle_destroy, ped_enter_vehicle, ped_play_anim_*, and ped_give_weapon_named_* require a specific data.target (and sometimes more), which defaults cannot supply. Keep those for contextual menus provided by the script.

Weapons submenu

Add or remove weapons available under “Give Weapon…”. Each entry looks like:
config/contextMenus.lua
Use canonical RedM weapon names for the weapon field so the game can grant them properly.

Animations submenu

Control which animations appear under “Animations…”. Each entry looks like:
config/contextMenus.lua
Flags correspond to eScriptedAnimFlags (for example: 1 = loop, 2 = hold last frame, 16 = upper body). Duration -1 means use the animation’s natural length.