Skip to Content
AM Scripts Docs

Exports

What other resources can call. Every export below is server-side and is exposed by the am-vehicleshop resource.

Stock

addStock

Adds units to a model. Creates the listing automatically if the dealership's categories allow that vehicle.

---@param dealershipId string
---@param model string
---@param amount number|nil defaults to 1
---@return boolean success, string|nil error
local ok, err = exports['am-vehicleshop']:addStock('pdm', 'sultan', 5)
if not ok then print('failed:', err) end

removeStock

Removes units. Fails with insufficient_stock rather than clamping to zero, so you can tell the difference between "took 3" and "only had 1".

---@param dealershipId string
---@param model string
---@param amount number|nil defaults to 1
---@return boolean success, string|nil error
local ok, err = exports['am-vehicleshop']:removeStock('pdm', 'sultan', 1)

setStock

Sets stock to an exact figure. Creates the listing if needed.

---@param dealershipId string
---@param model string
---@param stock number must be >= 0
---@return boolean success, string|nil error
local ok, err = exports['am-vehicleshop']:setStock('pdm', 'sultan', 10)

getStock

Total units the dealership holds across every model.

---@param dealershipId string
---@return number|false total, string|nil error
local total, err = exports['am-vehicleshop']:getStock('pdm')
-- will retun by example 42

Returns false, 'dealership_not_owned' for self-service shops they are not stock managed and every vehicle is always available.

getVehiclePrice

Sale price of one model. Owned shops report their own edited price; self-service shops report the catalogue price.

---@param dealershipId string
---@param model string
---@return number|false price, string|nil error
local price = exports['am-vehicleshop']:getVehiclePrice('pdm', 'sultan')
-- will return the vehcile price on that dealership example (3000).

getVehicleStock

Units of a single model.

---@param dealershipId string
---@param model string
---@return number|false stock, string|nil error
local stock, err = exports['am-vehicleshop']:getVehicleStock('pdm', 'sultan')
-- 3

Financing

All finance getters return rows in this shape:

{
  id = 12,
  citizenid = 'ABC12345',
  dealershipId = 'pdm',
  vehicleId = 87,              -- player_vehicles row id
  model = 'sultan',
  name = 'Sultan',
  plate = 'ABC 123',
  totalPrice = 87960,
  recurringPayment = 7330,
  totalPayments = 12,
  remainingPayments = 9,
  remainingBalance = 65970,
  overduePayments = 0,
  status = 'in-progress',      -- in-progress | overdue | completed | failed
  nextPaymentAt = '2026-08-02 14:00:00',
  lastPaymentAt = '2026-08-01 14:00:00',
  createdAt     = '2026-07-30 11:22:00',
}

getFinancedVehiclesByPlayer

By player server id the player must be online.

---@param src number player server id
---@return table[] vehicles (empty table when none)
local vehicles = exports['am-vehicleshop']:getFinancedVehiclesByPlayer(source)
for _, v in ipairs(vehicles) do print(v.plate, v.remainingBalance) end

getPlayerFinancedVehicles

Same data, but by identifier works for offline players.

---@param identifier string citizenid / identifier / charId
---@return table[] vehicles
local vehicles = exports['am-vehicleshop']:getPlayerFinancedVehicles('ABC12345')

getFinancedVehicleByPlate

The agreement attached to a plate, whoever owns it. Prefers an active agreement if a plate was ever reused.

---@param plate string
---@return table|false vehicle
local finance = exports['am-vehicleshop']:getFinancedVehicleByPlate('ABC 123')
if finance then print(finance.citizenid, finance.remainingPayments) end

getPlayerFinancedVehiclesCount

How many agreements the player still owes on. Completed and failed ones are not counted.

---@param identifier string
---@return number count
local count = exports['am-vehicleshop']:getPlayerFinancedVehiclesCount('ABC12345')
-- returns the number by example 2

Dealership balance

getDealershipBalance

---@param dealershipId string
---@return number|false balance, string|nil error
local balance, err = exports['am-vehicleshop']:getDealershipBalance('pdm')
-- retrns the banalce example: 400000

addDealershipBalance

---@param dealershipId string
---@param amount number must be > 0
---@return boolean success, string|nil error
local ok, err = exports['am-vehicleshop']:addDealershipBalance('pdm', 50000)

removeDealershipBalance

Fails with insufficient_funds if the balance does not cover the amount it will never take the shop negative.

---@param dealershipId string
---@param amount number must be > 0
---@return boolean success, string|nil error
local ok, err = exports['am-vehicleshop']:removeDealershipBalance('pdm', 25000)

Employees

isPlayerEmployed

The player's role at that dealership, or false when they do not work there.

---@param src number player server id
---@param dealershipId string
---@return string|false role
local role = exports['am-vehicleshop']:isPlayerEmployed(source, 'pdm')
-- 'owner' | 'manager' | 'sales' | false

getPlayerPermissions

The permission grants for that player's role, taken straight from the permissions table in config/shared.lua. Returns false if they are not employed there.

---@param src number player server id
---@param dealershipId string
---@return table|false permissions
local perms = exports['am-vehicleshop']:getPlayerPermissions(source, 'pdm')
if perms and perms.canWithdrawFromBank then
  -- ...
end

Returned keys mirror the config:

canAccessManagement · canEditPrices · canEditStock · canEditEmployees · canEditGrades · canEditDisplaySpots · canManageCoupons · canAccessToBank · canWithdrawFromBank · canDepositToBank

getDealershipEmployees

---@param dealershipId string
---@return table[]|false employees, string|nil error
local employees = exports['am-vehicleshop']:getDealershipEmployees('pdm')

Example of data returned

{
  { citizenid = 'ABC12345', name = 'John Doe', role = 'owner',   directSaleCut = 10, online = true },
  { citizenid = 'XYZ98765', name = 'Jane Roe', role = 'manager', directSaleCut = 15, online = false },
}

Dealerships

getDealerships

Every dealership from config/shops.lua, enabled or not, sorted by id. Each entry has the same shape as getDealershipInfo.

---@return table[] dealerships
local dealerships = exports['am-vehicleshop']:getDealerships()

getDealershipInfo

---@param dealershipId string
---@return table|false info, string|nil error
local info, err = exports['am-vehicleshop']:getDealershipInfo('pdm')
{
  id = 'pdm',
  name = 'Premium Deluxe Motorsport',
  type = 'owned',                    -- 'owned' | 'selfservice'
  owned = true,
  enabled = true,
  categories = { 'vans', 'sports', 'oneofone' },
  showroomSpots = 4,
  showroomLocation = { x = -57.15, y = -1097.3, z = 26.42 },
  hasManagement = true,
  hasDirectSale = true,
  testDriveEnabled = true,

  -- owned dealerships only, nil for self-service
  ownerCitizenId = 'ABC12345',
  balance = 395432,
  vehiclesInStock = 6,
}

getShowroomVehicles

The vehicle list a player would see in the showroom, with live stock merged in.

---@param dealershipId string
---@return table[]|false vehicles, string|nil error
local vehicles = exports['am-vehicleshop']:getShowroomVehicles('pdm')
{
  {
    model = 'sultan',
    name = 'Sultan',
    brand = 'Karin',
    category = 'sports',
    price = 73299,
    stock = 3,              -- nil on self-service dealerships
    unlimitedStock = false, -- true on self-service dealerships
  },
}

On this page