Vehicle Extras Menu w/ MenuV

Screenshot_1

Hey all,

I am pretty new to FiveM development and I have been enjoying doing it for the past few weeks. I have been working on my own little server using QBCore and wanted to add a little something for my friends and I to use. I came across many different resources using NativeUI and not many using MenuV like QBCore uses. So here is a little Vehicle Extras/Livery menu that I created using MenuV. I used a lot of other resources as references so it may be a little jumbled.

Feel free to give any feedback you may have or suggestions to the code to make it neater or work better. Be kind because as I said, I am new to doing development :smiley:

3 Likes

Nice simple menu. I actually had something like this planned for my next little project for our server but now I don’t need to do it :slight_smile: The only change I’d consider is putting in checks to prevent access to changing extras if the vehicle is damaged or at minimum, prevent the vehicle from auto-repairing when extras are toggled. It’s an easy FailRP to have a vehicle that is damaged or low on gas and then just toggle an extra off/on to fix/refuel it.

Thanks for the input! The plan that I have is to implement this into a DrawText3D event to only be accessed at certain locations. But, I guess bad actors would still have access to the menu.

I think adding

SetVehicleAutoRepairDisabled(veh, true)

right before where it turns the extra on “should” do the trick to at least prevent it from repairing. Auto repairs don’t happen when removing extras, just when adding them. As far as the fuel part of it goes, I’m not sure if it will refuel if it doesn’t repair so stopping the auto repair may fix that as well but if not, could capture the fuel level and then just reset it. Where you are getting the vehicle, you could add

local fuel = GetVehicleFuelLevel(veh)

and then after the extra is set on, use

SetVehicleFuelLevel(veh, fuel)

Seems as though setting the auto repair disabled broke being able to change the extras on the vehicle.

Huh, that’s kinda weird. We used an old extras menu before that used that native and it worked fine but sure enough, for some reason it doesn’t work here. For our needs, I just added locals to get the vehicle body health and engine health and used an “if” where if either of them are less than 1000, it gives you a message saying you can’t adjust extras on damaged vehicles and if the vehicle is fine, it toggles it as expected.

Nice Little Script To Have Will Use This For Police In My Server To Change There Livery’s An Add Extras Without Having To Go To A Shop. Hope You Don’t Mind But For Anyone That Wants It For PD Here Is A Quick Little Change To Do So.

local QBCore = exports['qb-core']:GetCoreObject()

RegisterCommand('carextra', function(source, args)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
	
	if Player.PlayerData.job.name == "police" then
      TriggerClientEvent('openVehMenu', source)
	else
       TriggerClientEvent('QBCore:Notify', src, "This Command Is Only For Law Enforcement!!")	
	end  
end)

I would advise against having this menu accessible with a command without admin/mod permissions, especially in RP situations. I simply included the command for people to be able to test it out. You could however, add this into a PolyZone to allow the command be accessible within a certain area, for example the MRPD parking lot.

Yes, it is indeed strange, I will look more into how to stop the repair from happening. But for now, your idea would work just fine.

For example in client.lua:

if availableExtra[k] then
  SetVehicleExtra(veh, k, 0)
else
  if GetVehicleBodyHealth(veh) < 1000 then
    TriggerEvent('chat:addMessage', 'The vehicle must be repaired first.')
  else
    SetVehicleExtra(veh, k, 1)
  end
end
1 Like

where could i get this command from ?

The command is in the code already in the server.lua file. To open the menu, just type /carextra and the menu should open with no issues.

is there a way to keybind it in the script to a specific key ?

You could make a thread and listen for a key press using the IsControlJustPressed() native.

CreateThread(function()
  while true do
    Wait(0)
    if IsControlJustPressed(*enter your aguments here*) then
      TriggerEvent('openVehMenu')
    end
  end
end)

does not work

any new update ?

If this worked where did you place it in the top of client.lua at line 6? and replaced line 7/9?

Placed it in the server.lua