[Release] GUI Script - v0.8

Hi here, i just did a simple Menu system who can be easily configurable.


Installation :

  • Add GUI.lua on your Script folder
  • Add GUI.lua on your __resource.lua (client)

Utilisation :

To add a Menu add this function to your client side script :

function NameOfMenu()
	MenuTitle = "Title of the menu"
	ClearMenu()
	Menu.addButton("First Button","FunctionName1","arg")	
	Menu.addButton("Second Button","FunctionName2",nil) -- No arg
	-- ...
end

Next add this on your keypress event loop :


Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if IsControlJustPressed(1,Keys["H"]) then
		
			NameOfMenu()                     -- Menu to draw
			Menu.hidden = not Menu.hidden    -- Hide/Show the menu

		end
		Menu.renderGUI()     -- Draw menu on each tick if Menu.hidden = false
	end
end)

Keys:

Up : Up Arrow Key
Down : Down Arrow key
Select : Enter key

:warning:Warning​:warning:
Maybe you dont have the same keybinding of me, so check the wiki to see what is the value of your keybinding
You can edit the GUI.lua to change keys table or simply modify like this
IsControlJustPressed(1--[[input group]], 51--[[control index]])

Here is the wiki
https://wiki.fivem.net/wiki/Controls
thanks to Kng for the tips

Note :

args are always chars for now, if someone know how to better pass function you can help me to make this script better.


Screen :

Download :

#[Redacted]

8 Likes

Thanks, good job ;D i will try this today

How to register the character in the Db of MySQL ?

1 Like

nice, i had hard times to find out how to use it but this is a very good job :slight_smile:

Thank you for the add, I believe that we can find multiple uses for this script in progressive rp.

1 Like

Going to be useful, thanks a lot !

Hello thanks i a new dev and i don’t how where to install GUI.lua, where is script folder and __resource.lua ?
Can you help me with more installation details please ?

thanks you so much

It’s simple, just create a file __resource.lua in the folder of your script with a code:

client_script 'GUI.lua'

Your folder

  • __resource.lua
    -> GUI.lua

I’m not all inclusive I put the script in my folder and all it is loader well by the server but how to make appear the menu game?

H must be pressed normally

yeah thank i have finally unsderstand the script x)

holle

Do oas function i create a file with the resource + GUI
In the resoucre I have added client_script ‘GUI.lua’ a liver in the game H touches and nothing goes ???

Thx for the script, Do you know how can i add a button in a button. Exemple: When i press E, the menu show. I have 2 Button first : Weapon, second : Ammo. When i press button weapon i have a button pistol, riffle etc … Thx

Hey

Controls aren’t keys but instead the things you can assign to keys in keybind options, See https://wiki.fivem.net/wiki/Controls for more info.

do
Menu.addButton("New Menu Name","NewMenu",nil)

and add a function called

function NewMenu()
        MenuTitle = "Title of the new menu"
	ClearMenu()
	Menu.addButton("First Button","FunctionName1","arg")	
	Menu.addButton("Second Button","FunctionName2",nil) -- No arg

end
1 Like

Thx i will try this tommorow

If i understand the code i have to call the fonction of the second menu in a button of the first menu ? Thx

@Ideo Is there a way to transmit several arguments for a function at once?

Hello everyone, I have improved the script of Ideo, now we can resize the menu and move it
GUI.lua (6.5 KB)

where i must add this script ? in client essentiamode? or client of es_freeroam-master ? or not ^^