Installation

Downloading The Resource

Follow the steps below to gain access to the resources files

1

Log Into the CFX Portal

First, log in to the official CFX portal

2

Finding The Resource

After logging in, go to the Granted Assets section to view your purchased assets. Find Midnight-VehicleMenu, and simply click the download button.


Adding The Resource To Your Server

Follow the steps below to implement the resource onto your server

1

Placing The Resource

Unzip the md_carcontrol.zip folder and place the extracted folder into your servers resources folder

2

Ensuring The Resource

Open your servers server.cfg file and write ensure md-carcontrol anywhere after your framework is ensured


Integrating Your Servers Fuel Script

The vehicle control UI displays the amount of fuel a vehicle has. Follow the steps below to integrate your servers fuel script, depending on which one you have (if any). This script includes direct support for using no fuel script (standalone), cdn-fuel and legacy-fuel - however any fuel script can be added with some additional configuration.

NO FUEL SCRIPT

Set Config

shared/config.lua
-- The fuel script you wish to use. 
-- The script comes with support for cdn-fuel, legacy-fuel and standalone functionality. Check documentation for more info
Config.FuelScript = 'none'    
CDN-FUEL

Set Config

shared/config.lua
Config.FuelScript = 'cdn-fuel'
LEGACY-FUEL

Set Config

shared/config.lua
Config.FuelScript = 'legacy-fuel'
ANY OTHER FUEL SCRIPT

Set Config

shared/config.lua
Config.FuelScript = 'other'

Add Custom Fuel Reading Code

  • Open up the shared functions file found in shared/functions.lua

  • Edit the last elseif statement in the givenGetFuelLevel function.

    • The vehicle being checked is provided as a paramater (veh).

    • shared/functions.lua
      function GetFuelLevel(veh)
          --standalone
          if Config.FuelScript == 'none' or Config.FuelScript == 'standalone' then 
              return GetVehicleFuelLevel(veh)
      
          --cdn fuel script
          elseif Config.FuelScript == 'cdn-fuel' then 
              return exports['cdn-fuel']:GetFuel(veh) 
      
          --legacy fuel script
          elseif Config.FuelScript == 'legacy-fuel' then
              return DecorGetFloat(veh, '_FUEL_LEVEL') 
          
          elseif Config.FuelScript == 'other' then
              -- If you are using any other fuel script, just add the code that gets the fuel amount right here
              -- Make sure the fuel amount is RETURNED as a number between 0 and 100 
          end
      end
    • Utilize exports or any means from your custom fuel script to check how much fuel the vehicle has, and return the amount as a number between 0 and 100


Configuring Your Resource

Read the pages in Configuration to configure the script as needed.

Last updated