# context menu

{% hint style="info" %} <mark style="color:yellow;">Fontawesome</mark> is used to add icons to the list items, you can find the code [here](https://fontawesome.com/v5/search?o=r\&m=free).
{% endhint %}

## Context Menu

<figure><img src="https://share.lvsoft.com.ar/images/JxVCa.jpg" alt=""><figcaption></figcaption></figure>

***

### How to use:

Client-side using exports

**Example:**

```lua
-- menu table
local menu = {
	{
		header = "Item #1",
		txt = "This trigger an event",
		icon = "fas fa-user", -- add icon to item
		--disabled = true, -- make item disabled
		params = {
			event = "event:client:test1",
			args = {
				number = 1,
			}
		}
	},
	{
		header = "Item #2",
		txt = "Can trigger a  server event",
		params = {
			event = "qb-menu:server:test2",
			isServer = true,
			args = {
				number = 2,
			}
		}
	},
	{
		header = "Item #3",
		txt = "Can trigger a function",
		params = {
			event = function(args)
				print(json.encode(args))
			end,
			isAction = true,
			args = {
				number = 3,
			}
		}
	},
}

-- open context menu
exports.lvs_lib:openContext('Menu Title', menu)


-- close context menu
exports.lvs_lib:closeContext()
```

***

### qb-menu replacement

To replace <mark style="color:orange;">qb-menu</mark> with this script, you need to enable the functionality in the `config.lua` and remove a comment in the `fxmanifest.lua`

{% code title="fxmanifest.lua (line 58)" %}

```lua
provide 'qb-menu'
```

{% endcode %}

{% code title="config.lua" %}

```lua
--- ### CONTEXT ###
-- make lvs context menu replace of qb-menu
-- uncomment line 57 on fxmanifest.lua [provide 'qb-menu']
-- remove qb-menu
Config.ContextAsQBMenu = true
Config.QBMenuCommand = {
    name = 'playerfocus',
    description = 'Give Menu Focus',
    key = 'Alt',
    keymapping = 'LMENU'
}
```

{% endcode %}
