Developers
The coke processing client and server exports, the notify event, the hooks in its open files, custom cooking steps and the shapes of its player, plant, table and lab data.
Exports, events and hooks for connecting coke processing to other resources. Every export is called on exports.lation_coke. A player is their server id (source), and a lab is its number in labs in config/shared.lua, which is also the routing bucket players are in while inside it.
Client exports
| Export | Returns |
|---|---|
getPlayerData(type?) | This player's data, or one field of it. See player data. |
getLevelData() | The experience table: the XP each level needs |
getPlantData(plantId) | A plant, or nil |
getTableData(tableId) | A table, or nil |
getLabData(labId) | An owned lab, or nil |
getAllLabs() | Every owned lab, keyed by lab id |
isLabAvailable(labId) | true when nobody owns the lab |
isOwner(labId) | true when this player owns the lab |
isAuthUser(labId) | true when this player is one of the lab's authorized users |
getUserPermissions(labId) | This player's permissions in the lab, or false |
isInsideLab() | Whether this player is inside a lab, and which |
openLabShop() | Opens Lab Availability |
Every client export except getLevelData and isInsideLab waits for the server, so call it where code can wait, such as an event handler or a CreateThread.
isInsideLab
Client export
local inside, labId = exports.lation_coke:isInsideLab()Returns
boolean, numbertrueand the lab id while inside a lab;falseand0otherwise
local inside, labId = exports.lation_coke:isInsideLab()
if inside then
print(('in lab %d'):format(labId))
endopenLabShop
Client export
exports.lation_coke:openLabShop()Opens Lab Availability for this player, as the lab dealer does: every unowned lab their level allows. It refuses a player below dealer.level. Use it to sell labs from your own ped, phone or laptop, with dealer.enable off.
Server exports
| Export | Returns |
|---|---|
getPlayerData(source, type?) | A player's data, or one field of it |
addPlayerData(source, dataType, amount) | Nothing |
getLevelData() | The experience table |
getPlantData(plantId) | A plant, or nil |
getTableData(tableId) | A table, or nil |
getLabData(source, labId) | An owned lab, or nil |
getAllLabs() | Every owned lab, keyed by lab id |
isLabAvailable(_, labId) | true when nobody owns the lab |
isOwner(source, labId) | true when the player owns the lab |
isAuthUser(source, labId) | true when the player is an authorized user |
getUserPermissions(source, labId) | The player's permissions in the lab, or false |
buyLab(source, labId) | Nothing |
The tables these hand out are the script's own, not copies: read them, don't change them.
getPlayerData
Server export
exports.lation_coke:getPlayerData(source, type)Parameters
sourcenumber- The server id of an online player
typestringoptionaldefaultnil- One field, such as
level,exp,leaves,grown,cementorbricks; the whole record when left out
Returns
table | any- The player's data, or that one field.
nilwhen the player has no character loaded.
A player with no record yet gets one, with their own gasoline and cement windows. The client export takes only type.
local level = exports.lation_coke:getPlayerData(source, 'level')
if level and level >= 3 then
-- let them into your own coke heist
endaddPlayerData
Server export
exports.lation_coke:addPlayerData(source, dataType, amount)Parameters
sourcenumber- The server id of an online player
dataTypestringexp, or a stat:leaves,grown,cementorbricksamountnumber- How much to add. Must be more than 0.
Adds to a player's XP or a lifetime stat. XP raises the level as it crosses each threshold, up to the top level; nothing takes XP or levels away. The change is saved when the player leaves or the resource stops.
-- 250 XP for finishing a coke delivery in your own script
exports.lation_coke:addPlayerData(source, 'exp', 250)getLabData
Server export
exports.lation_coke:getLabData(source, labId)Parameters
sourcenumber | nil- Not used, but taken first: pass
nilor a player labIdnumber- The lab's id
Returns
table | nil- The lab, or
nilwhen nobody owns it
isLabAvailable
Server export
exports.lation_coke:isLabAvailable(nil, labId)Parameters
_any- Not used, but taken first
labIdnumber- The lab's id
Returns
booleantruewhen nobody owns the lab
buyLab
Server export
exports.lation_coke:buyLab(source, labId)Parameters
sourcenumber- The server id of an online player
labIdnumber- The lab's id
Buys a lab for a player as the lab dealer does: it checks their level, their balance in settings.accounts.purchase, the lab limit and the CanBuyLab hook, charges the lab's price, and tells every player the lab is owned. A purchase refused for the level, the money or the limit tells the player why. Check isLabAvailable first: the export doesn't, and buying a lab someone owns fails on the database.
if exports.lation_coke:isLabAvailable(nil, 3) then
exports.lation_coke:buyLab(source, 3)
endEvents
lation_coke:notify
Client event
TriggerClientEvent('lation_coke:notify', source, message, type)Parameters
messagestring- The text
typestringsuccess,error,infoorwarning, as your notification system takes them
Shows a notification through the system set in setup.notify. The script sends its own messages this way, and any server script can too.
Hooks
Hooks are plain functions in the two open functions.lua files. Edit them in place.
Server hooks
In server/functions.lua.
| Hook | Called | By default |
|---|---|---|
CanPlacePlant(source) | When a player uses a seed. Return false to refuse. | Checks the pot, the plant limit, the blocked and allowed areas and the police count, and tells the player why it refuses |
CanPlaceTable(source) | When a player uses the table item. Return false to refuse. | Checks the table limit, the restricted areas and the police count |
CanBuyLab(source, labId) | Before a lab is bought, after the level, money and limit checks. Return false to refuse. | true |
CocaPlantSearched(source, farmId, plantId) | After a wild plant pays out | Nothing |
CementCollected(source, zoneId, cementId) | After a player takes cement | Nothing |
CocaSeedPlanted(source, plantId) | After a plant goes down | Nothing |
CocaPlantWatered(source, plantId) | After a plant is watered | Nothing |
CocaPlantFertilized(source, plantId) | After a plant is fertilized | Nothing |
CocaPlantHarvested(source, plantId) | After a harvest pays out, before the plant is removed | Nothing |
CokeTablePlaced(source, tableId) | After a table goes down | Nothing |
CompletedCook(source, cookType, data) | When a brick is taken from a table or a lab station | Nothing |
plantId is a key in the global Plants, and tableId in Tables. farmId and zoneId are positions in farms and cement.zones.
CompletedCook
Server hook
function CompletedCook(source, cookType, data) endParameters
sourcenumber- The player who took the brick
cookTypestringtableorlabdata.itemstring- The brick, such as
ls_cocaine_brickorls_crack_brick data.quantitynumber- How many
data.puritynumber- Its purity, 1 to 100
data.tableIdnumberoptional- The table, when
cookTypeistable data.labIdnumberoptional- The lab, when
cookTypeislab
function CompletedCook(source, cookType, data)
if data.purity == 100 then
TriggerClientEvent('lation_coke:notify', source, 'A perfect batch.', 'success')
end
endClient hooks
In client/functions.lua. They run on the player's client.
| Hook | Called | By default |
|---|---|---|
CanSearchCoca(farmId) | Before a wild plant is searched. Return false to refuse. | Checks the farm's required items and level |
CanUseCokeTable(tableId) | Before a table's menu opens | Checks table.police.use |
CanTakeCement(zoneId) | Before cement is taken | true |
CanEnterLab(labId) | Before a player goes into a lab | true |
CanOpenSupplyShop() | Before Rusty's Shop opens | true |
StartedPlacement(), StoppedPlacement() | When placing a plant starts and ends | Locks and unlocks the inventory |
Custom steps
Each step in cooking.table and cooking.lab runs the event in its event. Point a step at your own event to add a step of your own:
[8] = {
title = 'Press Brick',
description = 'Press a brick for a buyer',
icon = 'fas fa-compress',
iconColor = '',
event = { name = 'my_script:pressBrick', server = true }
},| Where | Arguments |
|---|---|
| A table step | stepId, tableId |
| A lab step | labId, stationId, stepId |
Without server = true, the event is triggered on the client. Your handler does the whole step: checks, progress bar and items. Steps are read in order, so number a new one after the last.
RegisterNetEvent('my_script:pressBrick', function(stepId, tableId)
local data = exports.lation_coke:getTableData(tableId)
if not data then return end
-- your step
end)Data
Player data
{
identifier = 'ABC12345', -- the character's framework identifier
level = 2,
exp = 7600,
gas_inputs = '{"min":37,"max":41}', -- JSON: this player's gasoline window
cement_inputs = '{"min":62,"max":66}', -- JSON: this player's cement window
inside = 0, -- the lab they are in, or 0
leaves = 340, -- lifetime stats
grown = 6,
cement = 18,
bricks = 4,
}Plant data
{
id = 1234567890,
x = 2101.5, y = 4830.2, z = 41.3,
thirst = 78.4, -- water, 0 to 100
hunger = 81.9, -- fertilizer, 0 to 100
yield = 100,
growth = 62.7,
stage = 2, -- 1 to 3
bucket = 0, -- the routing bucket it was planted in
owner = 'ABC12345', -- the planter's identifier
}Table data
{
id = 987654321,
x = 1501.2, y = 3601.8, z = 34.4, heading = 90.0,
stage = 4, -- the timed step on it, 0 when empty
duration = 23, -- minutes left
purity = 87, -- purity of the batch on it
bucket = 0,
owner = 'ABC12345',
}Lab data
{
id = 3,
owner = 'ABC12345',
style = 'upgrade', -- equipment: 'basic' or 'upgrade'
security = 'upgrade', -- 'basic' or 'upgrade'
locked = 'locked', -- 'locked' or 'unlocked'
passcode = '4821', -- or nil
upgrade = nil, -- { type = 'style' | 'security', duration = ms left } while one runs
users = { -- authorized users
{ identifier = 'DEF67890', name = 'Jane Doe', permissions = { true, false, false } },
}, -- permissions: lock/unlock door, view camera, manage users
stations = { -- by station number
[1] = { stage = 4, duration = 12, purity = 92 },
},
last_activity = 1762886400, -- os.time() of the last use
}Open files
These ship unescrowed:
| File | Holds |
|---|---|
config/*.lua | Every option. See configuration. |
locales/*.json | Every string players see |
bridge/client.lua, bridge/server.lua | Framework and inventory calls: players, jobs, money, items and usable items. Add another framework or inventory here. |
client/functions.lua | The client hooks, the notification, text UI, progress bar, menu, dialog and skill check calls, the target calls, stash opening and the dispatch calls |
server/functions.lua | The server hooks, item metadata, stashes, consumables, logging and /resetbucket |
On ox_inventory, server/functions.lua also merges the durability of stacked watering cans, fertilizer, gasoline and cement. The gasoline and cement names are written in its itemFilter, so rename them there too if you change those items.
Still stuck? Ask in our Discord: the people who write the scripts answer.
Last updated