What exactly is the “ContextMenu” and what can you do with it?
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.
E.g. clicking on a player can have a completely different menu than clicking on a vehicle.
An example of what can be done with this script can be found in this video:
Yes, this script is very much a work-in-progress project.
A lot of things will be added and changed throughout this process.
I’ll try to keep updates as compatible as possible, but new versions might break backwards compatibility here or there.
If you have any suggestions on changes or find features missing, just let me know and I’ll see what is possible and can be done.
How can I create a custom menu?
The documentation is currently WIP and not yet accessible. You can however take a look at the example and try and figure it out for yourself. It is not difficult!
Known Issues
Resolutions wider than 21:9 will cause dislocation problems of the cursor and menu. This issue is being worked on.
Controller support is not working as of now.
Patchnotes
Open Me
Update (v1.1):
Breaking change: removed Process() function (example updated to reflect this change)
Added more functions to the MenuPool:
OnOpenMenu: gets called, when the menu should open
OnAltFunction: gets called, when alt button is clicked
OnMouseOver: gets called while the button for the menu is held
Added TextItem: No functionality, just text.
Added camera rotation when touching the screen edge with the mouse (can be turned off).
Renamed variable “opacity” to “alpha” in all instances.
Renamed variable “text” from Text class to “title”.
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