rotateTask & Updates

The Organization Panel (OrgPanels) lets you wire any external resource โ€” missions, heists, robberies โ€” into the gang's progress board. Your resource registers tasks and upgrades; origen_ilegalv2 handles persistence, validation, NUI display, and hooks.


Concepts

Concept
What it is

Task

A milestone a gang can complete. Tracks completed and times_completed. Can be one-off or repeatable.

Upgrade

A permanent unlock for a gang. Requires one or more tasks to be completed before it can be activated.

Feature key

A string stored in effect.feature on an upgrade. External resources use this key โ€” not the upgrade_key โ€” to check access. Decouples your resource from upgrade names.

Data flow:

External resource registers task/upgrade on boot
        โ†“
Gang members complete tasks in-game โ†’ your resource calls CompleteGangTask
        โ†“
Leader unlocks upgrade from the gang panel (NUI) or your code calls UnlockGangUpgrade
        โ†“
Other resources gate content behind IsGangFeatureUnlocked

Timing โ€” when to register

OrgPanels loads its catalogs when the resource starts. Always register inside onResourceStart to guarantee the module is ready:

AddEventHandler('onResourceStart', function(resourceName)
    if GetCurrentResourceName() ~= resourceName then return end

    exports['origen_ilegalv2']:AddOrganizationTask({ ... })
    exports['origen_ilegalv2']:AddOrganizationUpgrade({ ... })
end)

Calling these exports at the top level (outside an event) risks a race condition where `origen_ilegalv2` has not finished loading yet.


Registering tasks

AddOrganizationTask(taskDef)

Field
Type
Required
Description

task_key

string

โœ…

Unique identifier. Used in required_tasks of upgrades and in all export calls

label

string

โœ…

Display name shown in the gang panel

description

string

โ€”

Longer description shown in the NUI

category

string

โ€”

Free-form label used to group tasks in the panel

is_repeatable

boolean

โ€”

true allows the task to be completed more than once (each call increments times_completed). Default: false

meta

table

โ€”

Arbitrary data stored as JSON. Readable by hooks and GetGangTasks. Not used by the core system

enabled

boolean

โ€”

Set to false to hide the task from the panel without deleting it. Default: true

If task_key already exists in the database, the row is updated (upsert). Safe to call on every boot.


Registering upgrades

AddOrganizationUpgrade(upgradeDef)

Field
Type
Required
Description

upgrade_key

string

โœ…

Unique identifier

label

string

โœ…

Display name in the gang panel

description

string

โ€”

Longer description

type

string

โ€”

Free-form type label for NUI grouping (e.g. 'robbery_unlock', 'logistics', 'economy')

required_tasks

table or string

โ€”

Array of task_key values that must be completed. Also accepts a CSV string: 'task_a, task_b'

effect

table

โ€”

Arbitrary data. effect.feature is the key other resources query via IsGangFeatureUnlocked

enabled

boolean

โ€”

Default: true

Multiple required tasks

All listed tasks must be completed before the upgrade can be unlocked. The NUI shows per-task completion status to the gang.


Completing tasks from your resource

Call this whenever a gang member finishes the corresponding in-game activity:

Return value

Field
Type
Description

ok

boolean

true on success

error

string|nil

'already_completed' / 'task_not_found' / 'invalid_gang'

times_completed

number

How many times completed after this call


Checking task completion

IsGangTaskCompleted(gangId, taskKey) โ†’ boolean

Synchronous in-memory check. Use this inside server callbacks before allowing an action:


Unlocking upgrades

Upgrades are normally unlocked by the gang leader or a member with the manage_org_upgrades rank permission from the NUI. You can also unlock them from code โ€” useful for automatic rewards or server events:

Return value

Field
Type
Description

ok

boolean

true on success

error

string|nil

'already_unlocked' / 'missing_dependencies' / 'upgrade_not_found' / 'invalid_gang'

missing_tasks

{ task_key, label }[]

Only present when error == 'missing_dependencies'


Gating content with feature keys

This is the recommended pattern. Your resource does not know the upgrade_key โ€” only the feature string. You can rename the upgrade later without touching other resources.


Reading full state

GetGangTasks(gangId) โ†’ table[]

Returns the full catalog enriched with per-gang progress:

GetGangUpgrades(gangId) โ†’ table[]

Returns the full upgrade catalog with unlock state and dependency resolution:


Hooks

The hooks file lives at custom/server/org_panels_hooks.lua. It is loaded by the resource and executed inside origen_ilegalv2 โ€” no cross-resource wiring needed.

Edit **only the body** of each function. Do not rename the functions or the `OrgPanelsHooks` table.

OrgPanelsHooks.onTaskCompleted(ctx)

Fires every time a task is marked completed for a gang, including repeatable ones.


OrgPanelsHooks.onUpgradeUnlocked(ctx)

Fires exactly once per (gangId, upgradeKey) pair โ€” upgrades are permanent.


OrgPanelsHooks.onUpgradeUnlockBlocked(ctx)

Fires when someone attempts to unlock an upgrade but required tasks are not yet complete. Useful for logging or giving extra feedback.


Complete integration example

Below is a condensed version of what a full integration from an external resource looks like:

Last updated