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 viaGM.ContextMenu:
- Actions:
registerAction(id, handler)maps a menuidto 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.
(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 usingBridge.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 (avector3)ctx.selectionCount: how many entities are currently selectedctx.targetPed: the ped under the cursor, if anyctx.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 onelabel: the text players seedata: optional parameters passed to the handlerchildren: optional array for 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.
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
Built-in action IDs you can reuse
- Movement:
goto_direct,goto_path,goto_stand(requiredata.coord) - Combat:
attack_area(requiresdata.coord)
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.