API Reference

Server exports provided by oxide-weed for integrations.

Server exports provided by oxide-weed, for integrating other resources (selling scripts, MDTs, leaderboards, etc.).

Call them with standard FiveM exports from any server script, as long as oxide-weed is started first:

local level = exports['oxide-weed']:GetPlayerLevel(source)

Progression

GetPlayerLevel(source)

Returns the player's weed level (1–10). Returns 1 if the player has no progression row yet.

local level = exports['oxide-weed']:GetPlayerLevel(source)

GetPlayerProgression(source)

Returns the player's full progression stats, or nil if the player has no valid character loaded.

local progression = exports['oxide-weed']:GetPlayerProgression(source)

Return shape:

{
    level = 1,
    xp = 0,
    currentLevelXp = 0,    -- XP threshold of the current level
    nextLevelXp = 100,     -- XP threshold of the next level (nil at max level)
    totalCreated = 0,
    totalSold = 0,
    unlocks = {            -- milestone list shown on the stats card
        { level = 3, labelKey = 'stats_unlock_crossbreed', unlocked = false },
        -- ...
    },
}

AddXP(source, amount)

Adds weed XP and runs the level-up check. Returns true on success, false if the player is invalid or the amount is not a positive number.

local ok = exports['oxide-weed']:AddXP(source, 25)

AddSold(source, amount)

Adds to the player's lifetime sold count. Returns true on success, false if the player is invalid or the amount is not a positive number. (oxide-drugselling calls this automatically.)

local ok = exports['oxide-weed']:AddSold(source, 3)

Plants

GetPlantCount(source)

Returns how many active plants the player owns.

local count = exports['oxide-weed']:GetPlantCount(source)

GetAllPlants()

Returns every active plant on the server, keyed by plant id.

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

Each entry:

{
    type = 'cannabis_seed',
    strain = 'og_kush',
    strain_name = 'OG Kush',
    coords = vector3(0.0, 0.0, 0.0),
    water = 50,
    fertilizer = 50,
    lastStage = 1,
    quality = 50,
    gender = 'female',
    generation = 1,
    placedBy = 'char:123',   -- character identifier
    bucket = 0,              -- routing bucket
}

GetPlantData(plantId)

Returns detailed live data for one plant, or nil if the id is invalid or the plant no longer exists.

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

Return shape:

{
    type = 'cannabis_seed',
    strain = 'og_kush',
    strain_name = 'OG Kush',
    coords = vector3(0.0, 0.0, 0.0),
    water = 50,
    fertilizer = 50,
    currentStage = 2,        -- computed live, including lamp/trait speed-ups
    totalStages = 4,
    quality = 62,
    gender = 'female',
    generation = 1,
    traits = {},             -- the 10 genetics traits
    placedBy = 'char:123',
    bucket = 0,
}

Genetics

GetStrainData(strainHash)

Looks up a strain in the genetics registry by its hash (found on item metadata as strain_id). Returns nil for unknown hashes.

local strain = exports['oxide-weed']:GetStrainData(strainHash)

Return shape:

{
    strain_name = 'OG Kush',
    traits = { potency = 35, thc = 25, --[[ ... ]] },
    base_quality = 65,
    required_level = 2,
}

oxide-drugselling uses this for trait-based price bonuses; it's also the hook for custom pricing, effects, or sale logic.

Smoking

IsPlayerSmoking(source)

Returns true while the player has an active smoking effect session.

local smoking = exports['oxide-weed']:IsPlayerSmoking(source)

Settings

Settings live in the database and are normally edited in game with /weed settings (see Admin). These exports let another resource read or change them programmatically.

GetSetting(key)

Returns the current live value of a top-level setting key (e.g. 'Store', 'PlantSettings', 'Strains'). Keys match the Config.* names in Configuration.

local store = exports['oxide-weed']:GetSetting('Store')
print(store.items[1].price)

SetSetting(key, value)

Replaces a setting's value: applies it live, saves it to the database, pushes it to every player, and re-runs anything that depends on it (NPCs re-spawn, item handlers re-register, wild plants re-seed). The value must be the whole value for that key — read it with GetSetting, modify, and write it back.

local settings = exports['oxide-weed']:GetSetting('PlantSettings')
settings.waterDecayRate = 0.5
exports['oxide-weed']:SetSetting('PlantSettings', settings)

This export is not permission-checked — it trusts the calling resource. Values are not validated the way the in-game menu validates them, so keep the same shape and value ranges the config files use.