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.
local gangId = exports['origen_ilegalv2']:GetPlayerGang(source)GetPlayerGangData(source) → { id, label } | nil
Returns the player's gang id and display label.
local data = exports['origen_ilegalv2']:GetPlayerGangData(source)
if data then
print(data.id, data.label)
endGetPlayerGangByCid(citizenid) → table | nil
Looks up gang membership by citizen identifier. Useful for admin panels and cross-resource reads.
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.
local info = exports['origen_ilegalv2']:GetGangInfo('vagos')
if not info then return end -- gang doesn't exist or isn't loadedReturn fields:
| Field | Type | Description |
|---|---|---|
id | string | Internal gang ID |
label | string | Display name |
leader | string | Leader identifier (citizenid / license) |
color | string | Hex color (#rrggbb) |
is_active | boolean | Whether the gang is currently active (points > 0) |
level | number | Gang level (1+) |
exp | number | Current XP within the current level |
points | number | Gang points (0–100). Reaches 0 → gang deactivated |
money | number | Gang bank balance |
member_count | number | Total registered members |
online_count | number | Members currently online |
max_members | number | Maximum allowed members (origen_gang_config) |
max_vehicles | number | Maximum allowed vehicles |
territory_count | number | Territories currently controlled (live DB count) |
base_territory | string|nil | ID of the gang's base territory |
created_at | string|nil | Creation timestamp |
Usage example:
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
local gang = exports['origen_ilegalv2']:GetGangById('vagos')GetGangByName(gangName) → { id, label, name, money } | nil
local gang = exports['origen_ilegalv2']:GetGangByName('vagos')GetGangs() → table<gangId, { id, label }>
Returns all active gang instances keyed by ID.
local gangs = exports['origen_ilegalv2']:GetGangs()
for id, gang in pairs(gangs) do
print(id, gang.label)
endGetGangLevelById(gangId) → number | nil
Returns the current level of a gang. Returns nil if the gang does not exist.
local level = exports['origen_ilegalv2']:GetGangLevelById('vagos')
if level and level >= 5 then
-- unlock tier-2 content
endsetGang(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.
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.
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.
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.
local state = exports['origen_ilegalv2']:GetPlayerLabState(source)
if state then
print(state.lab_id, state.lab_type)
endAdminLabsGetAll() → table[]
Returns all lab rows from the database (cached). Used internally by lab access checks.
local labs = exports['origen_ilegalv2']:AdminLabsGetAll()AdminLabsInvalidateCache()
Clears the in-memory lab cache, forcing the next AdminLabsGetAll call to re-query the DB.
exports['origen_ilegalv2']:AdminLabsInvalidateCache()MethLabResetPlayerState(source)
Force-resets the meth lab production state for a player (useful when ejecting them mid-cycle).
exports['origen_ilegalv2']:MethLabResetPlayerState(source)CokeLabResetPlayerState(source)
Force-resets the coke lab production state for a player.
exports['origen_ilegalv2']:CokeLabResetPlayerState(source)WeedLabResetPlayerState(source)
Force-resets the weed lab state for a player (releases any occupied drying slots).
exports['origen_ilegalv2']:WeedLabResetPlayerState(source)Crafting
CraftingPointsGetAll() → table[]
Returns all base crafting points (admin-defined, excluding lab instances) from the DB cache.
local points = exports['origen_ilegalv2']:CraftingPointsGetAll()CraftingLabInstancesGetAll() → table[]
Returns all crafting point instances that were purchased inside labs (runtime-only, not base points).
local instances = exports['origen_ilegalv2']:CraftingLabInstancesGetAll()CraftingPointsInvalidateCache()
Invalidates both the base-points cache and the lab-instances cache.
exports['origen_ilegalv2']:CraftingPointsInvalidateCache()Stores
StoresGetAll() → table[]
Returns all gang stores from the DB cache.
local stores = exports['origen_ilegalv2']:StoresGetAll()StoresInvalidateCache()
Clears the in-memory store cache.
SellStoresGetAll() → table[]
Returns all gang sell stores from the DB cache.
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.
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.
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.
local result = exports['origen_ilegalv2']:AddTerritoryReputation('davis', 'vagos', 10.0)
if result.success then ... endRemoveTerritoryReputation(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.
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.
local stab = exports['origen_ilegalv2']:GetTerritoryStabilization('davis')
if stab.active then
print('Locked for', stab.remaining_minutes, 'more minutes')
endGetTerritoryCaptureBlock(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.
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.
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).
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.
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.
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.
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.
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 }
local result = exports['origen_ilegalv2']:CompleteGangTask('vagos', 'deliver_supplies', {
completed_by = identifier,
})IsGangTaskCompleted(gangId, taskKey) → boolean
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
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.
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.
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:
| Field | Type | Description |
|---|---|---|
enabled | boolean | Always true (nil is returned when disabled) |
pendingExpireMinutes | number | TTL for pending requests in minutes |
approvedExpireMinutes | number | TTL for approved requests in minutes |
requestsById | table<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.
local res = exports['origen_ilegalv2']:GetRobberyRequestStatus(source, 'paleto_bank')
if res.ok and res.status == 'approved' then
-- allow the robbery to start
endParameters:
| Parameter | Type | Description |
|---|---|---|
source | number | Server source of the player |
robberyId | string | Robbery ID as defined in Config.RobberyRequest.Requests |
Return:
| Field | Type | Description |
|---|---|---|
ok | boolean | false if source or gang could not be resolved |
status | string | "pending" | "approved" | "rejected" | "not_requested" |
error | string? | 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.
if exports['origen_ilegalv2']:HasApprovedRobberyRequest(source, 'paleto_bank') then
-- start the robbery flow
endReturns 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.
local gang = exports['origen_ilegalv2']:GetPlayerGang()
if gang then
print(gang.id, gang.label)
endOpenGangMenu()
Opens the gang panel NUI for the local player.
exports['origen_ilegalv2']:OpenGangMenu()OpenGangCreation()
Opens the gang creation wizard for the local player.
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.
local lab = exports['origen_ilegalv2']:GetInsideLab()
if lab and lab.lab_type == 'meth' then ... endIsGangLabOpen() → boolean
Returns true if the lab laptop NUI panel is currently open.
if exports['origen_ilegalv2']:IsGangLabOpen() then
-- don't open another menu on top
endCloseGangLab()
Programmatically closes the lab laptop NUI panel.
MethLabResetProduction()
Resets the client-side meth lab production state (clears current stage, timers, and modifiers).
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.
local territories = exports['origen_ilegalv2']:GetTerritories()GetTerritoryById(territoryId) → table | nil
Returns a single territory by ID from the client-side cache.
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.
local inside = exports['origen_ilegalv2']:IsPlayerInTerritory('davis')GetPlayerPresenceData() → table
Returns the client-side presence tracking state: { isInTerritory, currentTerritory, timeInZone, ... }.
local presence = exports['origen_ilegalv2']:GetPlayerPresenceData()
if presence.isInTerritory then
print('In territory:', presence.currentTerritory)
endGetCurrentTerritory() → table | nil
Returns the territory object the local player is currently inside, or nil if outside all zones.
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.
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.
if exports['origen_ilegalv2']:IsHandcuffed() then
-- prevent certain actions
endRemoveHandCuff()
Forcibly removes handcuffs from the local player (detaches the prop, clears tasks, re-enables firing).
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).
exports['origen_ilegalv2']:openManagement()IsOpenedFromHub() → boolean
Returns whether the admin panel was last opened via openManagement().
ResetHubFlag()
Clears the openedFromHub flag.