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

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