# Exports

Koja Trucker exposes a stable, documented set of **server-side exports** so you can integrate it with your own resources.

```lua
-- The resource name is "koja-trucker"
local lvl = exports['koja-trucker']:GetLevel(source)
```

:::hint{type="info"}
Most functions accept a **`ref`** that is either a **server id** (number) or a **player identifier** (string). Functions that read live mission state need a server id.
:::

## Player progression

### GetPlayerData

```lua
local data = exports['koja-trucker']:GetPlayerData(ref) --> table | nil
-- { level, exp, skill_points, skill_data, total_deliveries, total_earnings, total_km, ... }
```

### GetLevel / GetXP / GetSkillPoints

```lua
local level = exports['koja-trucker']:GetLevel(ref)        --> number | nil
local xp    = exports['koja-trucker']:GetXP(ref)           --> number | nil
local sp    = exports['koja-trucker']:GetSkillPoints(ref)  --> number | nil
```

### GetSkillLevels

```lua
local skills = exports['koja-trucker']:GetSkillLevels(ref) --> { van_root = 1, van_luck = 2, ... }
```

### AddXP

Grants experience, handling level-ups, persistence and the HUD refresh.

```lua
local levelsGained = exports['koja-trucker']:AddXP(ref, 500) --> number
```

### AddSkillPoints

```lua
exports['koja-trucker']:AddSkillPoints(ref, 2) --> boolean
```

## Mission state

### IsOnMission

```lua
local busy = exports['koja-trucker']:IsOnMission(source) --> boolean
```

### GetActiveMission

```lua
local m = exports['koja-trucker']:GetActiveMission(source)
--> { id, category, from, to, started_at } | nil
```

### IsCurrentOrderIllegal

```lua
local illegal = exports['koja-trucker']:IsCurrentOrderIllegal(source) --> boolean
```

## Orders

### GetOrders

```lua
local orders = exports['koja-trucker']:GetOrders() --> table[]
```

### CreateOrder

Create or update an order. Returns `ok, err`.

```lua
local ok, err = exports['koja-trucker']:CreateOrder({
  id             = 'my_order',
  label          = 'Pallets of frozen pizza',
  category       = 'default',          -- default|urgent|dangerous|fragile|illegal|business
  required_class = 2,                  -- 1 van, 2 truck, 3 semi
  required_level = 1,
  reward         = { money = 4500, xp = 300 },
  pickup         = { road = '...', city = '...', coords = { x, y, z } },
  destination    = { road = '...', city = '...', coords = { x, y, z } },
})
```

### CreateBusinessOrder

Same as `CreateOrder` but forces `category = "business"` and fills sane defaults (class 2, level 1, 2-hour respawn).

```lua
exports['koja-trucker']:CreateBusinessOrder({
  id    = 'vip_electronics',
  label = 'VIP Electronics',
  reward = { money = 18000, xp = 1200 },
  business_reward_min = 16000,
  business_reward_max = 20000,
  pickup = { ... }, destination = { ... },
})
```

### DeleteOrder

```lua
local ok = exports['koja-trucker']:DeleteOrder('my_order') --> boolean
```

## Promo codes

### CreatePromoCode / DeletePromoCode

```lua
exports['koja-trucker']:CreatePromoCode({
  code = 'LAUNCH2X', kind = 'money', multiplier = 2.0,
  duration = 3600, max_uses = 0, note = 'Launch event',
})
exports['koja-trucker']:DeletePromoCode('LAUNCH2X')
```

### GrantPromoEffect

Apply a boost **directly** to a player — no code required. Ideal for Tebex hooks.

```lua
-- kind: 'money' | 'xp' | 'sp'
exports['koja-trucker']:GrantPromoEffect(source, 'money', 2.0, 3600)
```

### GetPromoMultiplier

```lua
local mult = exports['koja-trucker']:GetPromoMultiplier(ref, 'money') --> number (>= 1.0)
```

## Company

### GetPlayerCompany

```lua
local c = exports['koja-trucker']:GetPlayerCompany(ref)
--> { id, name, tag, role, level, bank_balance } | nil
```

### IsInCompany

```lua
local inCo = exports['koja-trucker']:IsInCompany(ref) --> boolean
```

## Rentals

### GetActiveRental

```lua
local rental = exports['koja-trucker']:GetActiveRental(ref) --> table | nil
```

## Related pages

- [Events](/jobs/trucker/configuration/api/events) — Koja Trucker emits server-side events you can listen to from your own resources. They're plain TriggerEvents, so subscribe with AddEventHandler.
- [API](/jobs/trucker/configuration/api) — back to the section overview
