API Reference

Server exports for integrating with oxide-weed from other resources.

Overview

oxide-weed exposes a server-side export API via FiveM's standard exports system. Any server resource can call these without needing community_bridge or ox_lib — just ensure oxide-weed before your resource.

-- Basic usage from any server resource
local level = exports['oxide-weed']:GetPlayerLevel(source)

The API follows a read-generous, write-minimal philosophy. External resources can query any state freely, but mutations are limited to AddXP — all other progression (levels, stats) is handled internally.


Server Exports

GetPlayerLevel

Returns the player's current weed progression level.

local level = exports['oxide-weed']:GetPlayerLevel(source)
ParameterTypeDescription
sourcenumberPlayer server ID

Returns: number — Level (1-10). Returns 1 if no progression data exists.


GetPlayerProgression

Returns the player's full progression data including XP, stats, and milestone unlocks.

local prog = exports['oxide-weed']:GetPlayerProgression(source)
ParameterTypeDescription
sourcenumberPlayer server ID

Returns: table or nil

{
    level = 4,
    xp = 820,
    currentLevelXp = 650,
    nextLevelXp = 1200,     -- nil if max level
    totalCreated = 15,
    totalSold = 42,
    unlocks = {
        { level = 1, label = 'Planting & Growing',
          unlocked = true },
        { level = 2, label = 'Street Selling',
          unlocked = true },
        { level = 2, label = 'Lab Reports',
          unlocked = true },
        { level = 3, label = 'Crossbreeding',
          unlocked = true },
        { level = 4, label = 'Seed Cloning',
          unlocked = true },
        { level = 7, label = 'Freeze Dryer',
          unlocked = false },
    },
}

AddXP

Adds XP to a player's weed progression. Automatically triggers level-up checks.

local success = exports['oxide-weed']:AddXP(source, amount)
ParameterTypeDescription
sourcenumberPlayer server ID
amountnumberXP to add (must be > 0)

Returns: booleantrue if XP was added, false if player not found or invalid amount.


GetPlantCount

Returns the number of active plants placed by a specific player.

local count = exports['oxide-weed']:GetPlantCount(source)
ParameterTypeDescription
sourcenumberPlayer server ID

Returns: number — Plant count for this character. Returns 0 if none.


GetAllPlants

Returns all active plants on the server. Useful for admin tools, map overlays, or police systems.

local plants = exports['oxide-weed']:GetAllPlants()

Returns: table<plantId, plantData>

{
    [42] = {
        type = 'cannabis_seed',
        strain = 'abc123',
        strain_name = 'OG Kush',
        coords = vector3(x, y, z),
        water = 75.5,
        fertilizer = 60.2,
        lastStage = 3,
        quality = 72,
        gender = 'female',  -- or 'male' or nil
        generation = 2,
        placedBy = '12345',
        bucket = 0,
    },
}

GetPlantData

Returns detailed data for a specific plant including calculated stage and growth info.

local plant = exports['oxide-weed']:GetPlantData(plantId)
ParameterTypeDescription
plantIdnumberPlant ID

Returns: table or nil

{
    type = 'cannabis_seed',
    strain = 'abc123',
    strain_name = 'OG Kush',
    coords = vector3(x, y, z),
    water = 75.5,
    fertilizer = 60.2,
    currentStage = 3,
    totalStages = 4,
    quality = 72,
    gender = 'female',
    generation = 2,
    traits = {
        potency = 75,
        thc = 80,
        -- ...
    },
    placedBy = '12345',
    bucket = 0,
}

GetStrainData

Looks up strain data from the genetics registry by hash. Use this to read strain info from item metadata.

local strain = exports['oxide-weed']:GetStrainData(strainHash)
ParameterTypeDescription
strainHashstringStrain hash (found in item metadata.strain_id)

Returns: table or nil

{
    strain_name = 'OG Kush',
    traits = {
        potency = 75,
        thc = 80,
        flavor = 65,
        -- ...
    },
    base_quality = 72,
    required_level = 0,
}

IsPlayerSmoking

Checks if a player is currently under smoking effects.

local smoking = exports['oxide-weed']:IsPlayerSmoking(source)
ParameterTypeDescription
sourcenumberPlayer server ID

Returns: boolean


Integration Examples

Gate Access by Growing Level

local level = exports['oxide-weed']:GetPlayerLevel(source)
if level < 5 then
    TriggerClientEvent('ox_lib:notify', source, {
        description = 'You need more growing experience',
        type = 'error',
    })
    return
end

Reward XP from Another Resource

exports['oxide-weed']:AddXP(source, 50)

Read Strain from Item Metadata

local items = exports['ox_inventory']:GetInventoryItems(source)
for _, item in pairs(items) do
    if item.name == 'weed_1g'
        and item.metadata
        and item.metadata.strain_id
    then
        local strain = exports['oxide-weed']:GetStrainData(
            item.metadata.strain_id
        )
        if strain then
            print(('Player has %s — quality %d'):format(
                strain.strain_name,
                item.metadata.quality_score or 0
            ))
        end
    end
end

Police Dispatch — Count Plants in Area

local plants = exports['oxide-weed']:GetAllPlants()
local nearbyCount = 0
local searchCoords = vector3(100.0, 200.0, 30.0)
for _, plant in pairs(plants) do
    if #(plant.coords - searchCoords) < 50.0 then
        nearbyCount = nearbyCount + 1
    end
end

Check Smoking State for Combat Penalties

if exports['oxide-weed']:IsPlayerSmoking(source) then
    -- Apply debuff
end

Next Steps