Skip to content

MetaDen Restorations API Reference

Server Callbacks

All callbacks are registered via MetaBridge.registerCallback and invoked from the client with MetaBridgeClient.requestCallbackAwait.


metaden-restoration:server:getPlayerRankingStats

Returns ranking stats for a player.

Parameters

NameTypeRequiredDescription
targetCitizenIdstringNoTarget citizen ID. Omit to return the caller's own stats.

Returns

lua
{
    summary = { citizenId, totalWrecksRestored, totalResourcesAdded, updatedAt },
    byType  = { { wreckType, totalWrecksRestored, totalResourcesAdded }, ... },
}

metaden-restoration:server:getRankingLeaderboard

Returns a ranked leaderboard.

Parameters

NameTypeRequiredDescription
wreckTypestringNoFilter by type (car, bike, pickup, van). Omit for global.
limitnumberNoNumber of entries (default 10, clamped 1–100).

Returns — array of player stat rows ordered by total wrecks restored descending.


metaden-restoration:server:getWrecksForSale

Returns all model-pool entries currently available for purchase (price > 0).

Returns

lua
{ { id, wreckType, model, price, currency }, ... }

metaden-restoration:server:buyWreck

Purchases a wreck from the model pool, deducts payment, and delivers the prop to TraderPed.WreckDeliveryCoords.

Parameters

NameTypeDescription
poolIdnumberRow ID from veh_restoration_model_pool

Returns

lua
{ success = boolean, reason = string? }

metaden-restoration:server:requestRestorationMission

Assigns a random restoration mission from TraderPed.Skills.Missions to the requesting player via metaden-skills.

Returns

lua
{ success = boolean, missionId = string?, missionTitle = string?, reason = string? }

metaden-restoration:server:hasRestorationInProgress

Returns true if the player has already reached their active wreck limit.

Returnsboolean


metaden-restoration:server:beginRestoration

Registers a new wreck restoration for the calling player. Called automatically when a player interacts with a wreck prop.

Parameters

NameTypeDescription
wreckTypestringCar | Bike | Pickup | Van
wreckNamestringProp model name of the wreck entity
coordstable{ x, y, z } world position
rotationtable{ pitch, roll, yaw }

Returns — full wreck data table, or { error = 'limit_reached', current, max } if capped.


metaden-restoration:server:addMaterialToWreck

Adds a material or part from the player's inventory to a wreck. Enforces condition requirements for parts (Condition = 100%), updates progress, and triggers stage-transition prop swaps.

Parameters

NameTypeDescription
materialstringInventory item name
wreckIdstringTarget wreck ID

Returns — updated wreck record, or false on failure.


metaden-restoration:server:completeRestoration

Finalises a fully completed restoration. Creates the owned vehicle record, spawns it in the world, grants keys to the player, and deletes the wreck from the database.

Parameters

NameTypeDescription
coordstable(unused, resolved from DB)
wreckIdstringTarget wreck ID

Returns

lua
{ success = boolean, spawned = boolean, plate = string? }

metaden-restoration:server:getRestorationData

Fetches a wreck record by lookup key.

Parameters

NameTypeDescription
lookuptable|string{ id }, { wreckKey, wreckKeyNormalized }, or raw wreck key string

Returns — decoded wreck record, or nil.


metaden-restoration:server:getRestorationZones

Returns all zone records from veh_restoration_zones. Used by the client on resource start to register sphere zones.

Returns — array of zone rows { id, x, y, z, wreckId }.


Admin Callbacks

All admin callbacks require ACE permission metaden.restoration.admin.

CallbackParametersDescription
metaden-restoration:admin:getModelPoolReturns all veh_restoration_model_pool entries.
metaden-restoration:admin:addToModelPool{ wreckType, model, price, currency }Inserts a new model into the pool (upserts on duplicate).
metaden-restoration:admin:removeFromModelPool{ id }Removes an entry by its row ID.
metaden-restoration:admin:getAllActiveWrecksReturns all live wrecks with owner, type, state, and coordinates.
metaden-restoration:admin:forceDeleteWreck{ id }Force-deletes a wreck and its zone record.
metaden-restoration:admin:getPlayerStats{ citizenId }Returns ranking stats for a specific citizen ID.
metaden-restoration:admin:getLeaderboardReturns the global leaderboard.
metaden-restoration:admin:assignMission{ citizenId, missionId }Assigns a specific mission to a player.
metaden-restoration:admin:getStoreItemsReturns all veh_restoration_store_items rows (runs lazy restock first).
metaden-restoration:admin:addStoreItem{ item, label, price, currency, condition, stock, restockAmount, restockInterval }Inserts a new store item.
metaden-restoration:admin:updateStoreItem{ id, label, price, currency, condition, maxStock, restockAmount, restockInterval }Updates an existing store item.
metaden-restoration:admin:removeStoreItem{ id }Deletes a store item by row ID.
metaden-restoration:admin:restockStoreItem{ id }Manually restocks a single item to its maxStock value.
metaden-restoration:admin:moveWreck{ wreckId }Moves a wreck to the admin's current position, updating DB and broadcasting to all clients.

Server Events

EventDirectionDescription
metaden-restoration:server:requestLoadWreckClient → ServerRequests the full wreck record for a given zone ID; server triggers loadWreck back.
metaden-restoration:server:cancelRestorationClient → ServerDeletes a wreck and its zone record (owner-only).
metaden-restoration:server:updateWreckLocationClient → ServerPersists a new wreck position after hoist/tow movement (owner-only).
metaden-restoration:server:searchScrapClient → ServerProcesses a scrap-search action; awards parts or materials.
metaden-restoration:server:getEngineHoistClient → ServerGives the player one engine_hoist item if they have space.
metaden-restoration:server:restorePartClient → ServerRepairs a broken part at a crafting bench, consuming raw materials.

Client Events

EventDirectionDescription
metaden-restoration:client:loadWreckServer → ClientFires after a wreck is created or purchased; client spawns the prop and registers zones.
metaden-restoration:client:RemoveWreckServer → Client (broadcast)Instructs all clients to delete a completed/cancelled wreck entity and zone.
metaden-restoration:client:RelocateWreckServer → Client (broadcast)Cleans up the old entity/zone and creates a fresh streaming zone at new coordinates (used by admin move).

Admin UI

Open with /restoration_admin. Requires ACE metaden.restoration.admin.

Build required before first use: cd ui && npm install && npm run build

PageDescription
Model PoolAdd or remove purchasable wreck entries with type, model, price, and currency.
StoreManage trader store items: add, edit, delete, manually restock, and monitor stock levels.
MissionsAssign a metaden-skills mission to any player by citizen ID.
Player StatsPer-player lookup and global leaderboard with character names, dual progress bars, and a by-type breakdown chart.
Active WrecksMonitor all live wrecks, set a map waypoint to their location, move a wreck to the admin's position, or force-delete entries.

Skills Integration (metaden-skills)

Mission Stat Hooks

When metaden-skills is running, this resource automatically increments the following mission stat counters:

Stat KeyTrigger
restoration.search.totalAny scrap search
restoration.search.type.<scrapType>Search on a specific prop type (e.g. vehicle, door)
restoration.material.totalAny material or part added to a wreck
restoration.material.<materialKey>Specific material added (e.g. restoration.material.engine)
restoration.restore.totalAny restoration completed
restoration.restore.type.<car|bike|pickup|van>Restoration completed by type

Use these as requiredStatsAndAmount entries in metaden-skills mission definitions.

Search Reward Tuning Examples

Conservative

lua
Skills      = { { name = 'scrapping', multiplier = 0.8 }, { name = 'education_engineering', multiplier = 0.2 } },
ItemBonuses = { WEAPON_WRENCH = 0.25, anglegrinder = 0.75 },
MaxBonus    = 4,

Generous

lua
Skills      = { { name = 'scrapping', multiplier = 1.0 }, { name = 'education_engineering', multiplier = 0.35 } },
ItemBonuses = { WEAPON_WRENCH = 1, anglegrinder = 5 },
MaxBonus    = 8,

Database Schema

veh_restoration_wrecks

ColumnTypeDescription
idVARCHAR(255) PKUnique wreck ID (citizenId:timestamp:random)
ownerCitizenIdVARCHAR(255)Owning player's citizen ID
modelVARCHAR(255)Target vehicle model to restore towards
wreckTypeVARCHAR(50)Car | Bike | Pickup | Van
wreckPropVARCHAR(50)Current prop model displayed in world
wreckKeyVARCHAR(250)Raw coord string key (legacy)
wreckKeyNormalizedVARCHAR(255)Rounded coord key for stable post-move lookups
locationJSONWorld position { x, y, z }
rotationJSONWorld rotation { pitch, roll, yaw }
stateJSONMaterial/part progress state + overall progress percentage
createdAtTIMESTAMPRecord creation time
updatedAtTIMESTAMPAuto-updated on any change

veh_restoration_zones

ColumnTypeDescription
idVARCHAR(255) PKZone ID (matches wreck ID)
x, y, zFLOATZone world position
wreckIdVARCHAR(255) FKReferences veh_restoration_wrecks.id
createdAtTIMESTAMPCreation time
updatedAtTIMESTAMPAuto-updated on change

veh_restoration_model_pool

ColumnTypeDescription
idINT UNSIGNED AI PKAuto-increment row ID
wreckTypeVARCHAR(50)Car | Bike | Pickup | Van
modelVARCHAR(255)Vehicle model name
priceINTPurchase price (0 = not for sale)
currencyVARCHAR(50)Currency key resolved via CurrencyMap
createdByVARCHAR(255)Citizen ID or 'console' of the admin who added the entry
createdAtTIMESTAMPInsertion time

veh_restoration_player_stats

Per-player aggregate totals.

ColumnDescription
citizenIdPK — player citizen ID
totalWrecksRestoredCumulative wrecks completed
totalResourcesAddedCumulative material units contributed
updatedAtLast stat update time

veh_restoration_player_type_stats

Per-player, per-type breakdown used for leaderboards and profile charts.

ColumnDescription
citizenId + wreckTypeComposite PK
totalWrecksRestoredWrecks completed for this type
totalResourcesAddedResources contributed for this type
updatedAtLast stat update time

veh_restoration_store_items

Trader store inventory. Seeded from Config.TraderPed.Store.Items on resource start.

ColumnTypeDescription
idINT UNSIGNED AI PKAuto-increment row ID
itemVARCHAR(255) UNIQUEInventory item name (unique — seed uses INSERT IGNORE)
labelVARCHAR(255)Display name shown to players
priceINT UNSIGNEDCost per unit
currencyVARCHAR(50)cash, bank, or any item name, resolved via CurrencyMap
conditionTINYINT UNSIGNED NULLIf set (0–100), sold item receives { Condition = 'N%' } metadata
maxStockINTMaximum stock count; -1 = unlimited
currentStockINTUnits currently available
restockAmountINT UNSIGNEDUnits added per restock cycle (0 = auto-restock disabled)
restockIntervalINT UNSIGNEDSeconds between auto-restock cycles (0 = disabled)
lastRestockAtTIMESTAMP NULLTimestamp of the last restock; NULL while never restocked
createdByVARCHAR(255)Citizen ID or 'seed' / 'console' of the creator
createdAtTIMESTAMPInsertion time

Restock behaviour: Stock is replenished lazily — the UPDATE runs once when the store is opened, topping up every overdue interval in a single SQL statement. No background polling loop runs.


Inventory Integration

All inventory operations are routed through metabridge:

  • Item count checks
  • Metadata display registration
  • Slot-aware metadata updates
  • Slot-targeted item removal (for condition-based parts)
  • Item definition and weight lookups
  • Create-item metadata hook registration (auto-sets Condition = "100%" on new parts)

No direct exports.ox_inventory:* calls are used in gameplay code.