[FREE] WarMenu - Lua Menu Framework

Love War Menu! Me and my fellow developer are currently making a LS Customs, Vehicle Dealer, Ammunation and Trainer all using War Menu. Love it! Modified some of it to add sprite support and action on hover buttons.

2 Likes

Where does the API actually change the color of the drawn rectangles in accordance with the currentOption index?

I’ve literally combed through the script and can not find it.

Just looking for all of the navigation functions. IsControlPressed(xxx) -> Highlight option below selected one etc

Line 152 - 161
if menus[currentMenu].currentOption == optionCount then
    backgroundColor = menus[currentMenu].menuFocusBackgroundColor -- HERE!
    textColor = menus[currentMenu].menuFocusTextColor
    subTextColor = menus[currentMenu].menuFocusTextColor
else
    backgroundColor = menus[currentMenu].menuBackgroundColor
    textColor = menus[currentMenu].menuTextColor
    subTextColor = menus[currentMenu].menuSubTextColor
    shadow = true
end

You can use WarMenu.SetMenuFocusColor(id, r, g, b, a) to change the colour of the selected option.

Looking to develop my own framework

Hey, i’m getting some trouble trying to make a godmode on/off button using the menu.

	local playerPed = GetPlayerPed(-1)
	local godmode = false

	WarMenu.CreateMenu('test', 'ADM')
    WarMenu.CreateSubMenu('closeMenu', 'test', 'Are you sure?')

    while true do
        if WarMenu.IsMenuOpened('test') then
            if WarMenu.CheckBox('Checkbox', checkbox, function(checked)
                end) then
                    -- Do your stuff here
			elseif WarMenu.MenuButton('God Mode', 'test') then
						drawNotification('God Mode:~g~ON')
						SetEntityInvincible(GetPlayerPed(-1), (godmode == false))
						SetPlayerInvincible(PlayerId(), (godmode == false))
						local godmode = true

i want to turn the godmode OFF using the same button, is there a way to do this? If it’s a dumb question i’m sorry, just started messing around with this.

Put the godmode in it’s own function and call the function.

Noob here, what would a callback be? I have built a basic working menu with Button() and MenuButton(), but I’d like to use the toggle option and explore the combobox, I just don’t understand the example.

See Usage section.
(20 ch)

Yea, I’ve seen it plenty of times, like I said I just don’t know enough to understand it but submenus cover the same functionality with one more press of the enter key so it’s no big deal, great work creating this btw, by far the easiest and fastest way to bring menus to FiveM. :ok_hand: :ok_hand:

@Warxander

hello would it be possible to make an update to include a background image instead of the title color please thank you

It’s just a matter of design and amount of line codes.

Well, it’s possible.

Yeah good thank you bro !!! @Warxander

Hello, To start very good work, according to you it is possible to change the top of the menu like this. :thinking:

Screen

Not yet, but I’ve already received this feature request.

Hello I am working on a garage script to work with this menu and its not working correctly properly and was wondering if I could get some help. when I open the menu it will show the cars but flashes/flickers and changes a lot. I will put parts of the code here. I have a feeling its something in the server script when it says table.insert(vehicules, {vehicle = vehicle, state = v.state}) but I don’t know.

Client side

			WarMenu.Display()
        elseif WarMenu.IsMenuOpened('getcar') then
		
			ESX.TriggerServerCallback('eden_garage:getVehicles', function(vehicles)
				for _,v in pairs(vehicles) do
			
					local hashVehicle = v.vehicle.model
					local vehicleName = GetDisplayNameFromVehicleModel(hashVehicle)
					local labelvehicle
					if(v.state) then
						labelvehicle = vehicleName..': Returns'
					else
						labelvehicle = vehicleName..': Exit'
					end	
                    if WarMenu.Button(labelvehicle) then
					if(v.state)then
					SpawnVehicle(vehicle)
					else
					TriggerEvent('esx:showNotification', 'Your vehicle is already out')
                    end
                end
			end
		end)

Server side

ESX.RegisterServerCallback('eden_garage:getVehicles', function(source, cb)
	local _source = source
	local xPlayer = ESX.GetPlayerFromId(_source)
	local vehicules = {}

	MySQL.Async.fetchAll("SELECT * FROM owned_vehicles WHERE owner=@identifier",{['@identifier'] = xPlayer.getIdentifier()}, function(data) 
		for _,v in pairs(data) do
			local vehicle = json.decode(v.vehicle)
			table.insert(vehicules, {vehicle = vehicle, state = v.state})
		end
		cb(vehicules)
	end)
end)

You call ESX.TriggerServerCallback inside while-true loop - that’s why I suppose.

So would I take it out of the while true or something else. Not really good with while true yet thanks for the help so far.

EDIT: Might have figured it out will see when I get home. So take out the ESX.TriggerServerCallback and put that somewhere else that’s not in the while true and then keep the rest and it should work?

You should move more logic to the server-side.
Try to store what you need to display on client-side and use shared identifier to match it with server-side data.