Exports

Client Side Exports

openUI

Export to open the trucker UI

Example Usage

-- Set the parameters
local trucker_location = "trucker_1" --  (string): Location index from your Config.trucker_locations
 
-- Call the export
exports['lc_truck_logistics']:openUI(trucker_location)

Server Side Exports

generateContract

This is the simplest function used to generate a Quick job or Freight job contract.

Behavior

  • The function will randomly select a delivery location from the configuration, calculate the price per kilometer, and assign a truck and load type if it's a Quick job.
  • The urgency, fragility, and value of the cargo are also determined randomly based on the configuration values.

Example Usage

-- Set the type of contract you want to generate
local contract_type = 0 	-- (number): The type of job. 0 for Quick job, 1 for Freight job.
 
-- Call the function to create the contract
exports['lc_truck_logistics']:generateContract(contract_type)

generateContractDetailed

This function allows for a more detailed contract creation with several customizable parameters, giving more control over the job's specifics.

Behavior

  • This function offers full customization of the job's properties, from the type of truck and trailer to the urgency and fragility of the cargo.

Example Usage

-- Set the parameters for the contract
local contract_type = 1 		-- (number): The type of job. 0 for Quick job, 1 for Freight job.
local contract_name = "Heavy Machinery Delivery" -- (string): The name of the contract.
local coords_index = 3 			-- (number): The index of the delivery location (must be between 1 and the total number of available locations in Config.delivery_locations).
local price_per_km = 50 		-- (number): Payment per kilometer for the delivery.
local cargo_data = { 			-- (table): Details about the cargo.
	cargo_type = 2, 			-- (number): Type of cargo. Must be a number between 0 and 6 (0 = None, 1 = Explosives, 2 = Flammable gases, 3 = Flammable liquids, 4 = Flammable solids, 5 = Toxic substances, 6 = Corrosive substances).
	is_fragile = true, 			-- (boolean): Whether the cargo is fragile. true or false.
	is_valuable = false, 		-- (boolean): Whether the cargo is valuable. true or false.
	is_urgent = true, 			-- (boolean): Whether the job is urgent. true or false.
	is_illegal = false 			-- (boolean): Whether the cargo is illegal. true or false.
}
local truck = "hauler" 			-- (string): The model of the truck to be used.
local trailer = "trailers" 		-- (string): The model of the trailer to be used.
 
-- Call the function to create the contract
exports['lc_truck_logistics']:generateContractDetailed(contract_type, contract_name, coords_index, price_per_km, cargo_data, truck, trailer)

generateContractWithCallback

โš ๏ธ

This export requires some coding knowledge and has different behaviors. Use with caution

This advanced function generates a contract with additional metadata, allowing you to provide custom callbacks and parking locations for the job.

Behavior

  • Unlike the others, this delivery will be considered a "special delivery". It will have a different border, never will be automatically deleted, and it won't be possible to start it in a party.
  • This function includes the ability to define a custom parking location, reward amount, and execute a callback upon contract completion.
  • It inserts metadata into the database, which can be used to track custom data.

Example Usage

-- Set the parameters for the contract
local contract_type = 1 		-- (number): The type of job. 0 for Quick job, 1 for Freight job.
local contract_name = "Special Delivery" -- (string): The name of the contract.
local truck = "phantom" 		-- (string): The model of the truck to be used.
local trailer = "trailers" 		-- (string): The model of the trailer to be used.
local vector_parking_location = vector4(-758.14, 5540.96, 33.49, 110.53) -- (vector4): The parking location (x, y, z, h coordinates).
local reward = 10000 			-- (number): The reward amount for successfully completing the job.
local resource_name = GetCurrentResourceName() -- (string): The name of the resource/script to be called when the job is finished.
local metadata = { item = "bread", amount = 2, rarity = "rare" } -- (table): Optional. Additional metadata for the contract (e.g., items transported, extra information).
 
-- Call the function to create the contract
exports['lc_truck_logistics']:generateContractWithCallback(contract_type, contract_name, truck, trailer, vector_parking_location, reward, resource_name, metadata)
 

Example Callback

The callback function is called once the player finishes the delivery.

โš ๏ธ

The callback function must exist in the script that created the contract and must be named
finishTruckerContract(source, metadata, contract_id)

function finishTruckerContract(source, metadata, contract_id)
	-- Do here any code you want to do once the player finishes the delivery
	-- The metadata you set when generating the contract will be available here. For example if you set "metadata = { item = "bread", amount = 2, rarity = "rare" }", then:
	local item = metadata.item -- "bread"
	local amount = metadata.amount -- 2
	local rarity = metadata.rarity -- "rare"
end
exports('finishTruckerContract', finishTruckerContract)

givePlayerXp

Export to give XP to a specific user

Example Usage

-- ESX
local user_id = ESX.GetPlayerFromId(source).identifier
-- QBCore
local user_id = QBCore.Functions.GetPlayer(source).PlayerData.citizenid
--
local xp_amount = 100 -- (number): Amount of XP to give to the user
 
-- Call the export
exports['lc_truck_logistics']:givePlayerXp(user_id, xp_amount)

getPlayerLevel

Export to get a specific user level

Example Usage

-- ESX
local user_id = ESX.GetPlayerFromId(source).identifier
-- QBCore
local user_id = QBCore.Functions.GetPlayer(source).PlayerData.citizenid
 
-- Call the export
local player_level = exports['lc_truck_logistics']:getPlayerLevel(user_id) -- returns a number