πŸ”¨Framework.lua

The framework.lua file handles framework-specific configurations and functions for managing rewards, notifications, and vehicle systems. It supports QBCore, ESX, and can be extended to other framework


Configuration Options

πŸ”§ acePermissions

  • Type: String

  • Default: 'pickups.admin'

  • Description: Sets the ACE permission name used to control admin access. This can be customized to match your server's permission system. Example:

    acePermissions = 'my.custom.permission'

πŸ”§ customFrameworkExport

  • Type: Function or nil

  • Default: nil

  • Description: Allows integration with custom frameworks by defining a function for exporting player or server data. Leave as nil if not using a custom framework.


πŸ”§ useMulticharacter

  • Type: Boolean (true/false)

  • Default: true

  • Description: Enable this option if your server uses a multicharacter system.


Core Functions

πŸ’° giveMoneyFunction

Handles rewarding money to players.

Parameters:

  • source: The player’s server ID.

  • moneyType: The type of money ('cash', 'bank', etc.).

  • amount: The amount to reward.

  • Framework: The active framework object (QBCore or ESX).

  • FrameworkName: The name of the framework ('QBCore' or 'ESX').

Framework Behavior:

  • QBCore: Uses xPlayer.Functions.AddMoney.

  • ESX: Uses xPlayer.addAccountMoney.

Example:

giveMoneyFunction(1, 'cash', 500, QBCore, 'QBCore')

πŸ“¦ giveItemFunction

Handles rewarding items to players.

Parameters:

  • source: The player’s server ID.

  • itemName: The item identifier.

  • amount: The quantity of the item.

  • Framework: The active framework object.

  • FrameworkName: The name of the framework.

Framework Behavior:

  • QBCore: Uses xPlayer.Functions.AddItem.

  • ESX: Uses xPlayer.addInventoryItem.

Example:

giveItemFunction(1, 'bread', 3, ESX, 'ESX')

πŸš— giveCarFunction

Handles rewarding vehicles to players.

Parameters:

  • source: The player’s server ID.

  • vehicleModel: The model of the vehicle (e.g., 'adder').

  • Framework: The active framework object.

  • FrameworkName: The name of the framework.

Framework Behavior:

  • QBCore: Inserts vehicle data into the player_vehicles database table.

  • ESX: Inserts vehicle data into the owned_vehicles database table.

Example:

giveCarFunction(1, 'adder', QBCore, 'QBCore')

πŸ†” getIdentifierFunction

Retrieves a player's unique identifiers (e.g., license, citizen ID).

Parameters:

  • source: The player’s server ID.

  • Framework: The active framework object.

  • FrameworkName: The name of the framework.

Return Values:

  • QBCore: Returns license and citizenid.

  • ESX: Returns identifier.

Example:

local license, citizenid = getIdentifierFunction(1, QBCore, 'QBCore')

πŸ”” notificationsFunction

Sends notifications to players.

Parameters:

  • source: The player’s server ID.

  • message: The notification message.

  • type: The type of notification ('success', 'info', 'error').

  • args: Additional arguments for formatting the message.

  • FrameworkName: The name of the framework.

Framework Behavior:

  • QBCore: Uses QBCore:Notify.

  • ESX: Uses esx:showNotification.

Example:

notificationsFunction(1, "You have received %d %s", 'success', {500, 'cash'}, 'QBCore')

Utility Functions

GeneratePlate

Generates a random license plate using three random letters and three random numbers.

Example:

local plate = GeneratePlate()

GenerateUniquePlate

Generates a unique license plate by checking the database for existing plates.

Parameters:

  • isQBCore: Boolean (true if using QBCore, false for ESX).

Example:

local uniquePlate = GenerateUniquePlate(true)

At a Glance

Function

Purpose

Framework Support

giveMoneyFunction

Reward money to players.

QBCore, ESX

giveItemFunction

Reward items to players.

QBCore, ESX

giveCarFunction

Reward vehicles to players.

QBCore, ESX

getIdentifierFunction

Retrieve player identifiers.

QBCore, ESX

notificationsFunction

Send notifications to players.

QBCore, ESX


Tips and Recommendations

  • Framework Detection: Ensure the FrameworkName matches the active framework (e.g., 'QBCore', 'ESX').

  • Notifications Localization: Use the Locales.Notifications table for consistent message localization.

  • Database: Ensure oxmysql is properly configured for vehicle handling.


Last updated