OrigenNetwork
Docs

Exports · origen_ilegalv2

All exports are registered under the resource name origen_ilegalv2. The table below splits them by execution side — use the correct side or the call will be silently ignored.


Server-side exports

Gang data

GetPlayerGang(source)string | nil

Returns the gang ID of the given player, or nil if they have none.

lua
local gangId = exports['origen_ilegalv2']:GetPlayerGang(source)

GetPlayerGangData(source){ id, label } | nil

Returns the player's gang id and display label.

lua
local data = exports['origen_ilegalv2']:GetPlayerGangData(source)
if data then
    print(data.id, data.label)
end

GetPlayerGangByCid(citizenid)table | nil

Looks up gang membership by citizen identifier. Useful for admin panels and cross-resource reads.

lua
local info = exports['origen_ilegalv2']:GetPlayerGangByCid(citizenid)
-- { id, name, label, rankName, rankGrade, isLeader }

GetGangInfo(gangId)table | nil

Returns a consolidated snapshot of a gang. This is the recommended export for external resources that need more than just the ID or label — it aggregates in-memory data and a single DB count for territories in one call.

lua
local info = exports['origen_ilegalv2']:GetGangInfo('vagos')
if not info then return end -- gang doesn't exist or isn't loaded

Return fields:

FieldTypeDescription
idstringInternal gang ID
labelstringDisplay name
leaderstringLeader identifier (citizenid / license)
colorstringHex color (#rrggbb)
is_activebooleanWhether the gang is currently active (points > 0)
levelnumberGang level (1+)
expnumberCurrent XP within the current level
pointsnumberGang points (0–100). Reaches 0 → gang deactivated
moneynumberGang bank balance
member_countnumberTotal registered members
online_countnumberMembers currently online
max_membersnumberMaximum allowed members (origen_gang_config)
max_vehiclesnumberMaximum allowed vehicles
territory_countnumberTerritories currently controlled (live DB count)
base_territorystring|nilID of the gang's base territory
created_atstring|nilCreation timestamp

Usage example:

lua
local info = exports['origen_ilegalv2']:GetGangInfo('vagos')
 
-- Gate by level
if info.level < 3 then
    return cb({ success = false, reason = 'gang_level_too_low' })
end
 
-- Gate by territories
if info.territory_count < 2 then
    return cb({ success = false, reason = 'not_enough_territories' })
end
 
-- Check capacity before inviting
if info.member_count >= info.max_members then
    return cb({ success = false, reason = 'gang_full' })
end
 
print(string.format(
    '[%s] Level %d | Members %d/%d | Territories %d | Bank $%d',
    info.label,
    info.level,
    info.member_count, info.max_members,
    info.territory_count,
    info.money
))

territory_count is the only field that hits the database — everything else is read directly from the in-memory Gang instance. The query is a single SELECT COUNT(*) so it is safe to call per-request.


GetGangById(gangId){ id, label, name, money, level } | nil

lua
local gang = exports['origen_ilegalv2']:GetGangById('vagos')

GetGangByName(gangName){ id, label, name, money } | nil

lua
local gang = exports['origen_ilegalv2']:GetGangByName('vagos')

GetGangs()table<gangId, { id, label }>

Returns all active gang instances keyed by ID.

lua
local gangs = exports['origen_ilegalv2']:GetGangs()
for id, gang in pairs(gangs) do
    print(id, gang.label)
end

GetGangLevelById(gangId)number | nil

Returns the current level of a gang. Returns nil if the gang does not exist.

lua
local level = exports['origen_ilegalv2']:GetGangLevelById('vagos')
if level and level >= 5 then
    -- unlock tier-2 content
end

setGang(identifier, gangName, rankId)boolean

Compatibility export. Assigns a player by identifier to a named gang at the given rank, removing them from their current gang first.

lua
exports['origen_ilegalv2']:setGang(identifier, 'vagos', 1)

UI shortcuts

OpenGangMenuBySource(source)boolean

Opens the gang panel NUI for a player who is already in a gang.

lua
exports['origen_ilegalv2']:OpenGangMenuBySource(source)

OpenGangCreationBySource(source)boolean

Opens the gang creation wizard for a player. The player must have can_create_gang = 1 in origen_gang_permissions.

lua
exports['origen_ilegalv2']:OpenGangCreationBySource(source)

Labs

GetPlayerLabState(source){ lab_id, lab_type, bucket, world_exit } | nil

Returns which lab a player is currently inside. nil if the player is not in any lab.

lua
local state = exports['origen_ilegalv2']:GetPlayerLabState(source)
if state then
    print(state.lab_id, state.lab_type)
end

AdminLabsGetAll()table[]

Returns all lab rows from the database (cached). Used internally by lab access checks.

lua
local labs = exports['origen_ilegalv2']:AdminLabsGetAll()

AdminLabsInvalidateCache()

Clears the in-memory lab cache, forcing the next AdminLabsGetAll call to re-query the DB.

lua
exports['origen_ilegalv2']:AdminLabsInvalidateCache()

MethLabResetPlayerState(source)

Force-resets the meth lab production state for a player (useful when ejecting them mid-cycle).

lua
exports['origen_ilegalv2']:MethLabResetPlayerState(source)

CokeLabResetPlayerState(source)

Force-resets the coke lab production state for a player.

lua
exports['origen_ilegalv2']:CokeLabResetPlayerState(source)

WeedLabResetPlayerState(source)

Force-resets the weed lab state for a player (releases any occupied drying slots).

lua
exports['origen_ilegalv2']:WeedLabResetPlayerState(source)

Crafting

CraftingPointsGetAll()table[]

Returns all base crafting points (admin-defined, excluding lab instances) from the DB cache.

lua
local points = exports['origen_ilegalv2']:CraftingPointsGetAll()

CraftingLabInstancesGetAll()table[]

Returns all crafting point instances that were purchased inside labs (runtime-only, not base points).

lua
local instances = exports['origen_ilegalv2']:CraftingLabInstancesGetAll()

CraftingPointsInvalidateCache()

Invalidates both the base-points cache and the lab-instances cache.

lua
exports['origen_ilegalv2']:CraftingPointsInvalidateCache()

Stores

StoresGetAll()table[]

Returns all gang stores from the DB cache.

lua
local stores = exports['origen_ilegalv2']:StoresGetAll()

StoresInvalidateCache()

Clears the in-memory store cache.


SellStoresGetAll()table[]

Returns all gang sell stores from the DB cache.

lua
local sellStores = exports['origen_ilegalv2']:SellStoresGetAll()

SellStoresInvalidateCache()

Clears the in-memory sell store cache.


Territories

CaptureTerritory(territoryId, gangId)boolean

Programmatically assigns a territory to a gang. Triggers a client-side map update for all players.

lua
local ok = exports['origen_ilegalv2']:CaptureTerritory('davis', 'vagos')

ReleaseTerritory(territoryId)boolean

Removes gang ownership from a territory (sets gang_id = NULL). Triggers a client-side map update.

lua
exports['origen_ilegalv2']:ReleaseTerritory('davis')

AddTerritoryReputation(territoryId, gangId, amount){ success, message? }

Adds reputation points for a gang in a territory. Validates that the gang and territory exist, and that base territories are protected.

lua
local result = exports['origen_ilegalv2']:AddTerritoryReputation('davis', 'vagos', 10.0)
if result.success then ... end

RemoveTerritoryReputation(territoryId, gangId, amount){ success, message? }

Removes reputation points for a gang in a territory.


SetTerritoryReputation(territoryId, gangId, amount){ success, message? }

Sets the reputation for a gang in a territory to an exact value (0–100).


GetGangTerritoryReputation(territoryId, gangId)number

Returns the current reputation value of a gang in a territory.

lua
local rep = exports['origen_ilegalv2']:GetGangTerritoryReputation('davis', 'vagos')

GetAllTerritoryReputations(territoryId)table[]

Returns all reputation rows for a territory, sorted by reputation descending.


ClearTerritoryReputations(territoryId){ success, message? }

Removes all reputation data for a territory and releases gang ownership.


GetTerritoryStabilization(territoryId){ active, remaining_seconds, remaining_minutes }

Returns whether a territory is inside its post-capture stabilization window.

lua
local stab = exports['origen_ilegalv2']:GetTerritoryStabilization('davis')
if stab.active then
    print('Locked for', stab.remaining_minutes, 'more minutes')
end

GetTerritoryCaptureBlock(territoryId){ active, remaining_seconds, remaining_minutes, cooldown_days }

Returns whether the per-territory capture cooldown (DB field capture_cooldown_until) is still active.


GetPlayersInTerritory(territoryId)table[]

Returns the list of player sources currently tracked inside a territory by the presence system.

lua
local players = exports['origen_ilegalv2']:GetPlayersInTerritory('davis')

GetGangMembersInTerritory(territoryId, gangId)table[]

Returns only the members of a specific gang currently inside a territory.


GetPlayerPresenceData(source)table | nil

Returns the presence tracking state for a player: which territory they are in, how long they have been there, etc.


IsPlayerInTerritory(source, territoryId)boolean

Returns true if a player is currently inside the given territory according to the server-side presence tracker.

lua
local inside = exports['origen_ilegalv2']:IsPlayerInTerritory(source, 'davis')

Drug sales

GetDrugSellLevel(source)number (0–100)

Returns the street-sell level of a player (a 0–100 progression value that increases with successful sales).

lua
local level = exports['origen_ilegalv2']:GetDrugSellLevel(source)

ProcessDrugSaleReputation(source)

Manually triggers territory reputation processing for a drug sale by a player — the same logic that fires on origen_gang:drugSales:saleCompleted.

lua
exports['origen_ilegalv2']:ProcessDrugSaleReputation(source)

GetPlayerSalesInfo(source){ salesThisHour, maxSalesPerHour, remainingSales, nextResetIn }

Returns the current-hour drug sale stats for a player against the territory reputation limit.

lua
local info = exports['origen_ilegalv2']:GetPlayerSalesInfo(source)
print(info.remainingSales, 'sales left this hour')

Vehicles

GetGangVehicles(gangId)table[]

Returns all vehicle rows from origen_gang_vehicles for a gang.

lua
local vehicles = exports['origen_ilegalv2']:GetGangVehicles('vagos')

GetVehicleCatalog(gangId)table[]

Returns the enabled vehicle catalog entries for a gang from origen_gang_vehicle_catalog.


Organization — Tasks

AddOrganizationTask(taskDef)boolean

Registers a task in the global catalog. If task_key already exists, the row is updated.

lua
exports['origen_ilegalv2']:AddOrganizationTask({
    task_key      = 'deliver_supplies',
    label         = 'Deliver Supplies',
    description   = 'Complete 3 supply runs.',
    category      = 'supply',
    is_repeatable = false,
    meta          = { reward = 5000 },
})

Call inside AddEventHandler('onResourceStart', ...)OrgPanels is not ready before the resource finishes loading.


CompleteGangTask(gangId, taskKey, opts?){ ok, error?, times_completed }

lua
local result = exports['origen_ilegalv2']:CompleteGangTask('vagos', 'deliver_supplies', {
    completed_by = identifier,
})

IsGangTaskCompleted(gangId, taskKey)boolean

lua
local done = exports['origen_ilegalv2']:IsGangTaskCompleted('vagos', 'deliver_supplies')

GetGangTasks(gangId)table[]

Returns the full task catalog with per-gang completion state.


Organization — Upgrades

AddOrganizationUpgrade(upgradeDef)boolean

lua
exports['origen_ilegalv2']:AddOrganizationUpgrade({
    upgrade_key    = 'tier2_robberies',
    label          = 'Tier 2 Robberies',
    type           = 'robbery_unlock',
    required_tasks = { 'deliver_supplies' },
    effect         = { feature = 'robberies:tier2' },
})

UnlockGangUpgrade(gangId, upgradeKey, opts?){ ok, error?, missing_tasks? }

Validates task dependencies before unlocking. error = 'missing_dependencies' includes missing_tasks: [{ task_key, label }].


HasGangUpgrade(gangId, upgradeKey)boolean


IsGangFeatureUnlocked(gangId, featureKey)boolean

Checks if any unlocked upgrade for a gang has effect.feature == featureKey.

lua
local ok = exports['origen_ilegalv2']:IsGangFeatureUnlocked('vagos', 'robberies:tier2')

GetGangUpgrades(gangId)table[]

Returns the full upgrade catalog with per-gang unlock state and dependency resolution.


Robbery Requests

GetRobberyRequestConfig()table | nil

Returns the robbery request module configuration indexed for fast lookup by origen_police. Returns nil if the module is disabled.

This export is consumed internally by origen_police to validate request IDs, cooldowns, and participant ranges without coupling to the full Config table.

lua
local cfg = exports['origen_ilegalv2']:GetRobberyRequestConfig()
if not cfg then return end -- module disabled
 
local entry = cfg.requestsById['paleto_bank']
-- entry = { id, label, image, requiredCops, minParticipants, maxParticipants, cooldownSeconds }

Return fields:

FieldTypeDescription
enabledbooleanAlways true (nil is returned when disabled)
pendingExpireMinutesnumberTTL for pending requests in minutes
approvedExpireMinutesnumberTTL for approved requests in minutes
requestsByIdtable<robberyId, entry>All active robbery entries keyed by id for O(1) lookup

GetRobberyRequestStatus(source, robberyId){ ok, status, error? }

Returns the normalized status of the gang's robbery request for a given player source and robbery ID. Resolves the gang internally — the caller only needs the player's source.

lua
local res = exports['origen_ilegalv2']:GetRobberyRequestStatus(source, 'paleto_bank')
if res.ok and res.status == 'approved' then
    -- allow the robbery to start
end

Parameters:

ParameterTypeDescription
sourcenumberServer source of the player
robberyIdstringRobbery ID as defined in Config.RobberyRequest.Requests

Return:

FieldTypeDescription
okbooleanfalse if source or gang could not be resolved
statusstring"pending" | "approved" | "rejected" | "not_requested"
errorstring?Present when ok = false: "invalid_source" | "no_gang"

Internal states (cancelled, expired, started) are normalized to "not_requested" so integrators never need to handle them.


HasApprovedRobberyRequest(source, robberyId)boolean

Boolean shorthand for the common check: returns true only when the gang's request is in approved state. Ideal for direct conditionals in robbery scripts.

lua
if exports['origen_ilegalv2']:HasApprovedRobberyRequest(source, 'paleto_bank') then
    -- start the robbery flow
end

Returns false if the source is invalid, the player has no gang, or the request is in any state other than approved.


Client-side exports

Gang

GetPlayerGang()table | nil

Returns the local player's current gang data table (same object used by the NUI). nil if not in a gang.

lua
local gang = exports['origen_ilegalv2']:GetPlayerGang()
if gang then
    print(gang.id, gang.label)
end

OpenGangMenu()

Opens the gang panel NUI for the local player.

lua
exports['origen_ilegalv2']:OpenGangMenu()

OpenGangCreation()

Opens the gang creation wizard for the local player.

lua
exports['origen_ilegalv2']:OpenGangCreation()

Labs

GetInsideLab(){ lab_id, lab_type, lab_name } | nil

Returns the lab the local player is currently inside, or nil if they are not in one. Used by all lab client scripts to guard interactions.

lua
local lab = exports['origen_ilegalv2']:GetInsideLab()
if lab and lab.lab_type == 'meth' then ... end

IsGangLabOpen()boolean

Returns true if the lab laptop NUI panel is currently open.

lua
if exports['origen_ilegalv2']:IsGangLabOpen() then
    -- don't open another menu on top
end

CloseGangLab()

Programmatically closes the lab laptop NUI panel.


MethLabResetProduction()

Resets the client-side meth lab production state (clears current stage, timers, and modifiers).

lua
exports['origen_ilegalv2']:MethLabResetProduction()

CokeLabResetProduction()

Resets the client-side coke lab production state.


InitLabStashPoints(stashes)

Initialises lib.points interaction zones for lab stash spots. Called internally by the lab lifecycle on entry — only needed if you are building a custom lab integration.


ClearLabStashPoints()

Removes all active lab stash interaction points and hides any open HelpText.


ApplyLabIplState(labType, iplModules)

Applies the lab upgrade IPL state (interior prop changes) for the given lab type and module snapshot. Called internally when a player enters a lab — only needed for custom integrations.


Territories

GetTerritories()table<territoryId, territory>

Returns the full territory map currently loaded on the client.

lua
local territories = exports['origen_ilegalv2']:GetTerritories()

GetTerritoryById(territoryId)table | nil

Returns a single territory by ID from the client-side cache.

lua
local t = exports['origen_ilegalv2']:GetTerritoryById('davis')

IsPlayerInTerritory(territoryId)boolean

Returns true if the local player's current position is inside the given territory zone.

lua
local inside = exports['origen_ilegalv2']:IsPlayerInTerritory('davis')

GetPlayerPresenceData()table

Returns the client-side presence tracking state: { isInTerritory, currentTerritory, timeInZone, ... }.

lua
local presence = exports['origen_ilegalv2']:GetPlayerPresenceData()
if presence.isInTerritory then
    print('In territory:', presence.currentTerritory)
end

GetCurrentTerritory()table | nil

Returns the territory object the local player is currently inside, or nil if outside all zones.

lua
local territory = exports['origen_ilegalv2']:GetCurrentTerritory()

Drug sales

SellDrugToNearestPed(drugName)

Programmatically triggers an attempt to sell a drug to the nearest eligible ped — same logic as the street-sale passive mode but callable externally.

lua
exports['origen_ilegalv2']:SellDrugToNearestPed('packaged_weed')

Crafting

IsCraftingMenuOpen()boolean

Returns true if the crafting NUI panel is currently open.


CloseCraftingMenu()

Closes the crafting NUI panel and clears the server-side watch state.


Stores

IsStoreMenuOpen()boolean

Returns true if the gang store NUI is open.


CloseStoreMenu()

Closes the gang store NUI.


IsSellMenuOpen()boolean

Returns true if the gang sell-store NUI is open.


CloseSellMenu()

Closes the gang sell-store NUI.


Handcuff

IsHandcuffed()boolean

Returns true if the local player is currently handcuffed by the gang quick-menu cuff action.

lua
if exports['origen_ilegalv2']:IsHandcuffed() then
    -- prevent certain actions
end

RemoveHandCuff()

Forcibly removes handcuffs from the local player (detaches the prop, clears tasks, re-enables firing).

lua
exports['origen_ilegalv2']:RemoveHandCuff()

Admin panel

openManagement()

Opens the admin management panel NUI as if opened from an external hub (sets the openedFromHub flag so the panel skips its normal focus acquisition delay).

lua
exports['origen_ilegalv2']:openManagement()

IsOpenedFromHub()boolean

Returns whether the admin panel was last opened via openManagement().


ResetHubFlag()

Clears the openedFromHub flag.