Browse docs

Storage

Reference for Storage in sky_jobs_base.

All server exports

Storage

Use the actual target storage station ID. The stationId on a wholesale order identifies the ordering location and can differ from the delivery storage. These exports use the supplied job and grade context; the calling server script must authorize its own player-facing requests.

GetStorageItemCount(stationId, jobName, grade, name)

  • Purpose: Counts how many items with the given name are currently available in one station storage. Metadata does not split the result; matching stacks are added together.
  • Arguments:
    • stationId (string | number) - target station ID.
    • jobName (string) - job name used for storage restrictions.
    • grade (number?) - job grade context.
    • name (string) - item name to count.
  • Returns: number - total available amount, or 0 when the station or item is missing.
local wheels = exports["sky_jobs_base"]:GetStorageItemCount("station_1", "mechanic", 2, "wheels")

if wheels > 0 then
    print(("Storage has %d wheel kits"):format(wheels))
end

RemoveStorageItem(stationId, jobName, grade, name, amount)

  • Purpose: Removes a trusted amount of an item directly from station storage. This is intended for server-side job resources that already validated the player, station, and workflow.
  • Arguments:
    • stationId (string | number) - target station ID.
    • jobName (string) - job name used for storage restrictions.
    • grade (number?) - job grade context.
    • name (string) - item name to remove.
    • amount (number) - positive item count.
  • Returns: boolean - true when the requested amount was removed.
local removed = exports["sky_jobs_base"]:RemoveStorageItem("station_1", "mechanic", 2, "wheels", 1)

if not removed then
    print("Not enough wheel kits in storage")
end

AddStorageItem(stationId, jobName, grade, name, amount, metadata?)

  • Purpose: Adds an item or weapon stack directly to station storage. The export validates input, job and station availability, and storage capacity before writing.
  • Arguments:
    • stationId (string | number) - target station ID.
    • jobName (string) - job name used for storage restrictions.
    • grade (number?) - job grade context.
    • name (string) - item name.
    • amount (number) - positive whole number, at most 2147483647.
    • metadata (table?) - optional item metadata.
  • Returns: boolean - true when the database write succeeds; false on rejected input, insufficient capacity, or a failed write.
local ok = exports["sky_jobs_base"]:AddStorageItem(
    "station_1",
    "mechanic",
    2,
    "repair_crate",
    1,
    { quality = 100 }
)

AddStorageItems(stationId, jobName, grade, items)

  • Purpose: Adds multiple item or weapon stacks to station storage with one database statement. All entries and the total capacity are checked before writing; an invalid entry rejects the entire batch.
  • Arguments:
    • stationId (string | number) - target station ID.
    • jobName (string) - job name used for storage restrictions.
    • grade (number?) - job grade context.
    • items (table[]) - dense array of 1–200 entries with name, a positive whole-number amount or quantity (at most 2147483647), and optional metadata.
  • Returns: boolean - true when the complete batch is written; false when validation or the database write fails.
local ok = exports["sky_jobs_base"]:AddStorageItems("station_1", "mechanic", 2, {
    { name = "repair_crate", amount = 1, metadata = { quality = 100 } },
    { name = "cleaning_kit", quantity = 2 }
})

Weapons use the same exports. For unique serial numbers, provide one entry per weapon with amount = 1 and its own metadata.serial:

local ok = exports["sky_jobs_base"]:AddStorageItems("police_storage", "police", 4, {
    { name = "weapon_pistol", amount = 1, metadata = { serial = "DELIVERY-001" } },
    { name = "weapon_pistol", amount = 1, metadata = { serial = "DELIVERY-002" } }
})

Neither storage export completes a wholesale order. Call CompleteWholesaleOrder after successful delivery and keep a persistent delivery record in the external script to prevent duplicate deposits. Storage writes and order status updates are separate operations, without a shared transaction.