πŸš—Give Vehicle Functionality

This code is located in the server/functions.lua file.

Overview

The function GiveVehicle(source, vehicleName, type) grants a vehicle to a player and saves it in the database with a unique plate and default properties.

Key Components

  • GeneratePlate() Creates a unique vehicle plate based on the configured framework. It checks the database to avoid duplicate plates.

  • GetVehicleProperties(name, plate, helicopter) Returns default vehicle settings, including colors, health, mods, and extras. Supports cars and helicopters.

  • GiveVehicle(source, vehicleName, type)

    1. Retrieves the player data.

    2. Generates a unique plate.

    3. Determines the appropriate garage based on the vehicle type (car, air, boat).

    4. Gets vehicle properties.

    5. Inserts vehicle data into the database, adapting to the framework used.

How to Modify

  • Adjust plate format in GeneratePlate().

  • Change vehicle stats or add mods in GetVehicleProperties().

  • Add support for other frameworks inside GiveVehicle() by extending the database logic.

  • Customize garage assignment inside GiveVehicle() as needed.

Last updated