ContextMenu is a script that allows you to create your own menus for any kind of purpose. It does nothing by itself.
You hold a button and your cursor appears on the screen. You can then click on any object and open specific menus for specific objects. This is kind of like your default rightclick menu in every other application.
Clicking on a player can have a completely different menu than clicking on a vehicle.
Features
Create custom menus using LUA.
Menu items include:
TextItem: Just has text and can be clicked.
CheckboxItem: Has a text and a checkbox that can be checked.
SubmenuItem: Automatically created when creating a submenu to a menu.
Separator: Just a separator line to group items together.
More to come depending on demand.
Use custom sprites on the right side of an item.
Fully customizable with width, height and colors (background, highlighted background, text, highlighted text, sprite, menu border, separator lines).
Includes the full source code.
Compatible with basically everything? Let me know if you find any issues!
Performance
The script itself draws no performance at all.
When you have created your own menu, the performance depends on the amount of items that are currently displayed on the screen.
The Client side performance of the Advanced Vehicle Interaction menu is around 0.25ms when the main menu is shown.
I love u and hate u at the same time, I just finished my bt-target adaptation in all my scripts today and now I need to redo it
PS: Only question do the checkbox is memorized only on a specific target ? Or for all targets with the same models (I’m reading the script actually not testing )
No. It is only memorized for the menu itself. But e.g. in Advanced Vehicle Interaction the menu is re-generated every time it is opened and thus setting it depending on what you set it to.
If you only generate it once, it is only saved per menu.
That is a real nice way to introduce yourself to a community. Thanks for that.
This script does nothing by itself.
If you want to see the example menu, make sure it is active in the fxmanifest.lua and then ingame hold Left Alt and right click things.
It would be great If you could have the option of creating job menus! I have more or less done something like that but when I change jobs from police to mechanic I still have the police menu, until I restart the script or reconnect
If you create it once with e.g. police job and then change to another job, you need to change the contents of the menu ofc.
Or create several menus for the jobs, but only the display the one for the job theplayer has.
itizen.CreateThread(function()
if ESX.PlayerData.job and ESX.PlayerData.job.name == 'mechanic' then
local menu_meca = menuPool:AddSubmenu(contextMenu, "Mechanic")
local itemDelete = menu_meca:AddItem("Eliminar vehiculo")
itemDelete.OnClick = function()
if (vehicle ~= nil and DoesEntityExist(vehicle)) then
SetEntityAsMissionEntity(vehicle)
DeleteEntity(vehicle)
end
end
elseif ESX.PlayerData.job and ESX.PlayerData.job.name == 'taxi' then
local menu_taxi = menuPool:AddSubmenu(contextMenu, "Taxi")
local itemDelete = menu_taxi:AddItem("Bill")
itemDelete.OnClick = function()
if (vehicle ~= nil and DoesEntityExist(vehicle)) then
SetEntityAsMissionEntity(vehicle)
DeleteEntity(vehicle)
end
end
end
end)
But until I change jobs and restart the plugin, or reconnect I don’t have the appropriate menu