[Release] GUI Management (Maker) | Mod Menu Style Menus (uhh.. ya)

Cool to see, nice work!

1 Like

cool, you can use github ?

I will end up doing it. This was just to get it out there

Edited to Github. https://github.com/MrDaGree/guimanagement

Development branch now has the ability to move the menu up and down. If you want anything else added let me know.

I found a little bug with the String Array.

local position = 1
local array = {"TEST", "TEST2", "TEST3", "TEST4"}

TriggerEvent("GUI:StringArray", "string:", array, position, function(cb)
	position = cb
end)

With this the default one would be TEST. If I press DPAD Right it changes to TEST2 etc., this works without any problem. But if I press DPAD Left instead of DPAD Right, it is blank instead of changing to TEST4.

Also a Suggestion, could you add FLOAT the same way you did with INT

nvm, I found the bug. You did this:


function Menu.StringArray(option, array, position, cb)

	Menu.Option(option);

	if (optionCount == currentOption) then
		local max = tablelength(array)
		local min = 1
		if (leftPressed) then
			if(position >= min) then position = position - 1 else position = max end
		end

And here is the problem.
if(position >= min) then position = position - 1 else position = max end

min is 1, if position is bigger or equal to 1 you subtract one. But if position is equal to 1 and you subtract one you get 0 and array[0] doesn’t exist.

Solve this through changing the line to this:

if(position > min) then position = position - 1 else position = max end

1 Like

Haha I was trying to figure out why it did that. Thanks for the finds!

1 Like

No problem, it way really annoying, so I thought I will take a look at it myself and instantly saw it hahaha

I hate it when something like this happens but sometimes it helps, when someone else takes a look at it :smile:

BTW. Great work, I really love it. It is very simple but there are so many possibilities with your GUI Manager

1 Like

Fantastic release, been looking to move away from all the annoying /commands I’ve been using. This will make life so much easier :slight_smile:

1 Like
Nevermind, Solution in my next post

@MrDaGree

Hey again, I tried adding a Float Option, but somehow it is not working…

This is what I added to the GUI.lua:

function Menu.Float(option, float, min, max, cb)
	Menu.Option(option);

	if (optionCount == currentOption) then
		if (leftPressed) then
			if (float > min) then
				float = float - 0.1
			elseif (float == min) then
				float = max
			end
		end
		if (rightPressed) then
			if (float < max) then
				float = float + 0.1
			elseif (float == max) then
				float = min
			end
		end
	end

	if (currentOption <= GUI.maxVisOptions and optionCount <= GUI.maxVisOptions) then
		GUI.Text(tostring(float), GUI.optionText, { menuX + 0.068, optionCount * 0.035 + 0.125 }, { 0.5, 0.5 }, true)
	elseif (optionCount > currentOption - GUI.maxVisOptions and optionCount <= currentOption) then
		GUI.Text(tostring(float), GUI.optionText, { menuX + 0.068, optionCount - (currentOption - maxVisOptions) * 0.035 + 0.125 }, { 0.5, 0.5 }, true)
	end

	if (optionCount == currentOption and selectPressed) then cb(float) return true
	elseif (optionCount == currentOption and leftPressed) then cb(float) return true
	elseif (optionCount == currentOption and rightPressed) then cb(float) return true end

	return false
end

And this to the client.lua:

RegisterNetEvent("GUI:Float")
AddEventHandler("GUI:Float", function(option, float, min, max, cb)
	Menu.Float(option, float, min, max, function(data)
		cb(data)
	end)
end)

The following is how I call it:

TriggerEvent("GUI:Float", "Float Test", float, 0.1, 1.9, function(cb)
	float = cb
	Citizen.Trace(float)
end)

But somehow it f*cks completly up when I use it. Maybe you can try it at your own, because IDK how to explain the problem. Would be nice if you could help me getting it to work :slight_smile:

Hm… I will add the option for a float sometime this week for you.

1 Like

Thank you, but I got it working :smile:

GUI.lua

function Menu.Float(option, float, min, max, step, cb)
	Menu.Option(option)

	if (optionCount == currentOption) then
		if (leftPressed) then
			if (round(float, 1) > min) then
				float = round(float, 1) - step
			end
		end
		if (rightPressed) then
			if (round(float, 1) < max) then
				float = round(float, 1) + step
			end
		end
	end

	if (currentOption <= GUI.maxVisOptions and optionCount <= GUI.maxVisOptions) then
		GUI.Text(tostring(float), GUI.optionText, { menuX + 0.068, optionCount * 0.035 + 0.125 }, { 0.5, 0.5 }, true)
	elseif (optionCount > currentOption - GUI.maxVisOptions and optionCount <= currentOption) then
		GUI.Text(tostring(float), GUI.optionText, { menuX + 0.068, optionCount - (currentOption - maxVisOptions) * 0.035 + 0.125 }, { 0.5, 0.5 }, true)
	end

	if (optionCount == currentOption and selectPressed) then
		cb(float)
		return true
	elseif (optionCount == currentOption and leftPressed) then
		cb(float)
		return true
	elseif (optionCount == currentOption and rightPressed) then
		cb(float)
		return true
	end

	return false
end

function round(num, numDecimalPlaces)
  local mult = 10^(numDecimalPlaces or 0)
  return math.floor(num * mult + 0.5) / mult
end

client.lua

RegisterNetEvent("GUI:Float")
AddEventHandler("GUI:Float", function(option, float, min, max, step, cb)
	Menu.Float(option, float, min, max, step, function(data)
		cb(data)
	end)
end)

local float = 1.0
TriggerEvent("GUI:Float", "Float", float, 0.0, 2.0, 0.1, function(cb)
	float = cb
end)

I hope this helps others too :smile:

2 Likes

How would you go about adding a second menu? Forward and back.

copy pasta the code but change title?

How can i move?
image

How can i move?

What do you mean by how can you move?

How do i open the menu???

How do i make so like i can spawn a car with arraystring because idk how to get the current array