Installation

Script Download

Before starting, you must log in to the CFX portal to download the asset. You will be able to download it as many times as you want on the official CFX page. Just as you download it the first time, you will also download it multiple times in the future to get updates.

1

Logging in to the CFX Portal

First, log in to the official CFX portal by clicking here.

2

Finding Your Assets

Once logged in, navigate to the Granted Assets section to access your purchased assets. You can download them by clicking the "Download" button.

Remember, if you encounter any issues or errors when starting the asset, you can check here to see if the problem is related.

Understanding CFX Auth

Downloading Dependencies

The dependencies for this asset are mandatory, so please follow the dependency guide completely and use all required files.

When downloading a dependency, ensure the file is properly unzipped and does not include "-main" at the end of its name. If it does, please remove it.


Update artifacts and gamebuild

Updating to the latest artifacts and gamebuild is essential to avoid common server issues. Here's how to do it properly:

1

Update Artifacts

Completely replace your current artifacts with the latest version. Download the appropriate artifacts for your operating system from the official links:

2

Update Gamebuild

Using the latest gamebuild is critical to take advantage of the newest features and avoid compatibility errors.

Edit the server.cfg file and add the following line:

sv_enforceGameBuild 3258

You can see the complete guide to update your server here:

How to update my server

Server.cfg Positioning

This asset must always be started below your framework and inventory but above any vehicle-related scripts. Failure to follow this order may result in functionality issues or critical errors. To ensure smooth operation and proper initialization, it is highly recommended to start the entire download folder using "ensure [vehiclekeys]" in your server.cfg while maintaining the correct order.


Debugging and Helper Tips

Debugging is an essential part of creating and modifying scripts, especially when working with vehicle-related assets. Using tools like print() statements, you can inspect the values of variables, test logic, and identify errors in your code. Below are some practical tips and examples to help you debug and improve your scripts.

1

Using print Statements for Debug

You can use print() statements to display the values of variables in the console. This is particularly useful when youโ€™re unsure of the data being returned or when you need to verify the behavior of your code. Here are two examples:

-- Printing multiple values separated by commas
print(vehicleData.model, vehicleData.name, vehicleData.other)

-- Including descriptive labels for clarity
print('Model: ', vehicleData.model, 'Name: ', vehicleData.name)

This approach helps identify whether specific variables are returning the expected values.

2

Example Debugging Scenario in a Callback

In complex scripts, such as when purchasing a vehicle, you might want to validate the data being processed. Using print() statements inside callbacks can reveal any unexpected issues.

ESX.TriggerServerCallback('esx_vehicleshop:buyVehicle', function(success)
    if success then
        IsInShopMenu = false
        menu2.close()
        menu.close()
        DeleteDisplayVehicleInsideShop()
        FreezeEntityPosition(playerPed, false)
        SetEntityVisible(playerPed, true)

        -- Debugging vehicle data
        print('Model: ', vehicleData.model, 'Name: ', vehicleData.name, 'Other: ', vehicleData.other)
    else
        ESX.ShowNotification(TranslateCap('not_enough_money'))
    end
end, vehicleData.model, generatedPlate)

By adding debugging prints, you can determine if the vehicle data (e.g., vehicleData.model, generatedPlate) is correct before proceeding with the rest of the logic.

3

Retrieve Vehicle Model and Plate

If you need to get the model name or plate of a vehicle, you can use the following native functions. These are simple yet powerful tools for obtaining vehicle information directly:

local model = GetDisplayNameFromVehicleModel(GetEntityModel(veh)) -- Returns the vehicle model name
local plate = GetVehicleNumberPlateText(veh) -- Returns the vehicle's license plate

These functions can be integrated into your scripts to quickly fetch the necessary details about a vehicle.

4

Best Practices for Debugging

  1. Place print() Strategically: Add print() statements before and after key operations to understand the flow of your code.

  2. Label Debug Outputs: Use descriptive text in print() to make debugging outputs easier to read.

    print('Current Vehicle Model:', model)
    print('Current Vehicle Plate:', plate)
  3. Test Incrementally: Test small portions of your script to isolate errors and verify logic step by step.

By following these practices, youโ€™ll streamline your debugging process and ensure that your vehicle scripts operate as intended. Debugging effectively not only saves time but also enhances the reliability and performance of your code.


Integrating Key Management with Third-Party Assets

Vehicle Keys provides an export system to grant or revoke keys for vehicles in external assets. This guide demonstrates how to integrate the GiveKeys export with a third-party asset, such as esx_vehicleshop, to seamlessly handle vehicle key assignments.

1

Export Overview

The GiveKeys export assigns keys to a specified vehicle. It accepts the following parameters:

exports['qs-vehiclekeys']:GiveKeys(plate, model, true)
  • plate: The vehicle's license plate.

  • model: The vehicle's model name.

  • bypassKeyCheck: (optional, default false) If set to true, the export bypasses the key validation check.

2

Implementation Example

Below is an example of integrating the GiveKeys export within esx_vehicleshop. This code ensures that once a vehicle is purchased, keys are automatically assigned to the buyer:

ESX.TriggerServerCallback('esx_vehicleshop:buyVehicle', function(success)
    if success then
        IsInShopMenu = false
        menu2.close()
        menu.close()
        DeleteDisplayVehicleInsideShop()
        FreezeEntityPosition(playerPed, false)
        SetEntityVisible(playerPed, true)

        -- Retrieve the vehicle's model and plate using natives
        local model = GetDisplayNameFromVehicleModel(GetEntityModel(vehicleData))
        local plate = GetVehicleNumberPlateText(vehicleData)

        -- Grant keys to the buyer
        exports['qs-vehiclekeys']:GiveKeys(plate, model, true)
        
    else
        ESX.ShowNotification(TranslateCap('not_enough_money'))
    end
end, vehicleData.model, generatedPlate)
3

Key Points for Integration

  1. Dynamic Plate and Model Retrieval:

    • Use natives like GetDisplayNameFromVehicleModel and GetVehicleNumberPlateText to dynamically fetch the vehicle's model and plate.

  2. Export Usage:

    • Call GiveKeys with the retrieved plate and model values, and set bypassKeyCheck as true if necessary.

  3. Custom Implementation:

    • While this example uses esx_vehicleshop, the logic can be adapted for any third-party asset where key assignment is needed.

By integrating the GiveKeys export in your scripts, you can enhance the gameplay experience by automatically assigning keys upon vehicle purchase or spawn.

Learn more about exports by viewing the following link:

Exports and commands

Key bind manipulation

All Quasar Store assets use the same process for modifying Key Binds to ensure consistency and optimized performance across all resources.

Below is a clear and detailed guide on how to adjust them to your preferences.

How to change key bindings

Last updated