FiveM Tutorial - How to make a dedicated map button / command - Thu, Oct 19, 2023
Either because you changed the main menu, or because you hate the extra clicks you need to reach the map, this code will help you implement the full size map with all it's functionality, using one single input.
Not much to say here, so here is the code:
RegisterCommand('map', function(source, args)
ActivateFrontendMenu("FE_MENU_VERSION_MP_PAUSE", false, -1) --Opens a frontend-type menu. Scaleform is already loaded, but can be changed.
while not IsPauseMenuActive() or IsPauseMenuRestarting() do --Making extra-sure that the frontend menu is fully loaded
Wait(0)
end
PauseMenuceptionGoDeeper(0) --Setting up the context menu of the Pause Menu. For other frontend menus, use https://docs.fivem.net/natives/?_0xDD564BDD0472C936
PauseMenuceptionTheKick()
while not IsControlJustPressed(2,202) and not IsControlJustPressed(2,200) and not IsControlJustPressed(2,199) do --Waiting for any of frontend cancel buttons to be hit. Kinda slow but whatever.
Wait(0)
end
PauseMenuceptionTheKick() --doesn't really work, but the native's name is funny.
SetFrontendActive(false) --Force-closing the entire frontend menu. I wanted a simple back button, but R* forced my hand.
end)
If you want to bind this to a button, use the bind console command, or RegisterKeyMapping(), like this:
RegisterKeyMapping('map', 'Open Map', 'keyboard', 'm')
Back to Home
Categories