Toggling Hud


#1

A common request on my server is a function to be able to toggle the HUD and various UI stuff on screen (or as much of it as possible) to get nice screenshots. I’m seeking a way to make this possible and I think I have a lead but I’m not sure how it would work (not the most experienced in coding).

We do have the plugin that allows us to hide crosshairs and that uses “HideHudComponentThisFrame(14)” in order to hide the reticle. There is a full list of different HUD components listed here: https://wiki.fivem.net/wiki/HUD

What I’m curious as to, and I hope someone can tell me if this is possible, is if we can use that line to toggle HUD. Basically, you press a hotkey and it hides the various components that we want it to hide.Then you press it again and it goes back to normal. Any ideas would be appreciated!


#2

What about
HideHudAndRadarThisFrame() ?

also, to make a toggle you can use something like toggle = not toggle


#3

Good point. Thanks.

Would need to learn how to do the toggle = not toggle


#4

basically,

toggle = false
if buttonpressed then
    toggle = not toggle
    if toggle then
        hidehud
    else
       showhud
    end
end

of course this wont work, but thats how you would use toggle


#5

Interesting, I may fix it up and give it a shot. Is there a “function” to show the hud again? Sorry for all the questions.