This section allows you to insert custom logic that runs before a player is allowed to start a job.
Optional: You do not need to edit this unless you have specific requirements (e.g., specific licenses, job cooldowns, or police checks).
The Logic: This function acts as a "Gatekeeper." If it returns true, the job starts. If it returns false, the job is blocked.
⚠️ IMPORTANT
Even if you do not want to use any checks, the function must always return true at the end. If you delete the return line or set it to false, no one will be able to start deliveries.
Example Code: License Check
The default code below checks if the player has a drive_truck license (using esx_license). If they don't, it sends a notification and blocks the job.
functionadditionalRequirementsServer(src)ifsrcthenlocaltoReturn=true -- Example: Check for Driver LicenseTriggerEvent('esx_license:checkLicense', src, 'drive_truck', function(hasLicense)ifhasLicensethentoReturn=trueelsetoReturn=false-- Block the jobendend) -- Notification if blockedifnottoReturnthenTriggerClientEvent('g-hud:sendNotification', src, 'You do not have a Class C License!', 5000, 'error', 'fa-solid fa-id-card')endreturntoReturn-- MUST RETURN TRUE TO ALLOW JOBendreturntrue-- Fallback safetyend
Client
Financial Transaction Handlers
These functions handle the actual transfer of money (Cash or Bank) to and from the player.
Cash Payouts (GiveCashPayout)
Triggered when the player finishes a job and Config.UseBank = false.
Bank Payouts (GiveBankPayout)
Triggered when the player finishes a job and Config.UseBank = true.
Bank Deductions (RemoveBankMoney)
Triggered when the player pays a deposit or a penalty.
Custom target menu
These functions allow you to hook into your server's interaction system. This is useful if you have a custom interaction script that isn't ox_target or qb-target
Add Custom Interaction (AddCustomInteraction)
Configuration Parameters
data.type: type of interaction either client or server
data.label: label of the interaction
data.icon: icon of the interaction
data.entity: entity that is being used in this interaction
data.netID: netID of the entity
data.event: event of the current interaction
data.id: unique name id of the current interaction
data.distance: distance that is recommended for interaction, value from Config.InteractionSettings.distance
Marker Interaction (AddCustomMarkerInteraction)
Used when Config.MarkerType = 'custom'.
Important: If using a custom marker system, you must trigger the event manually.
Configuration Parameters
data.name: name of the interaction
data.coords: coords of the interaction
data.label: label of the interaction
data.event: event of the interaction
data.truckBaseID: trucker base that might be used in the interaction
⚠️ IMPORTANT
When triggering your custom event to open the menu, you MUST pass the truckBaseID so the script knows which job location to show.
Option A (Trigger Event): If triggering an event, the first argument must be data.truckBaseID.
Option B (Direct Function):You can directly call the internal function showUI(data.truckBaseID).
data.entity: entity that is being used in this interaction
data.label: label of the interaction
data.id: unique name id of the current interaction
Tutorial Integration (ShouldShowTutorial)
Allows you to integrate the script's tutorial with external menu settings. This is useful if you have a "Settings" menu where players can toggle help messages on/off.
Default: Always returns true (Tutorial is always enabled).
Custom: You can check a client-side KVp (Key-Value pair) or an export from your menu script.
Block/Unblock Target (BlockTargetInteraction)
Temporarily disables the targeting system.
Usage: Used primarily during Developer Mode (Tool placement) so that when you try to click a tool button, you don't accidentally click the entity behind it.
function GiveCashPayout(src, amount)
local xPlayer = ESX.GetPlayerFromId(src)
if xPlayer then
xPlayer.addMoney(tonumber(amount))
end
end
function GiveBankPayout(src, amount)
local xPlayer = ESX.GetPlayerFromId(src)
if xPlayer then
xPlayer.addAccountMoney('bank', tonumber(amount))
end
end
function RemoveBankMoney(src, amount)
local xPlayer = ESX.GetPlayerFromId(src)
if xPlayer then
xPlayer.removeAccountMoney('bank', amount)
end
end
function AddCustomInteraction(data)
exports['g-interaction']:NewEntityInteractions({
{
id = data.id,
event = data.event,
label = data.label,
args = {},
requirements = {},
canInteract = function(entity)
return not IsPedInAnyVehicle(PlayerPedId(), false) and
not IsEntityDead(PlayerPedId())
end,
},
})
end
function AddCustomMarkerInteraction(data)
-- Add your custom marker code here
end
function RemoveCustomInteraction(data)
exports['g-interaction']:RemoveEntityInteraction(data.id)
end
function ShouldShowTutorial()
local type = 'custom' -- Change to 'script' to disable custom logic
if type == 'custom' then
-- Example: Checking an external menu setting
local jobHelp = exports['vv_mainMenu']:GetSettingData('howToWork-visible')
if jobHelp.dataSetttings == "1" then
return type, true -- Show Tutorial
else
return type, false -- Hide Tutorial
end
end
return type, true
end
function BlockTargetInteraction(resource)
if resource == 'ox_target' then
exports.ox_target:disableTargeting(true)
elseif resource == 'qb-target' then
exports['qb-target']:AllowTargeting(false)
end
end