> For the complete documentation index, see [llms.txt](https://docs.kojascripts.eu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kojascripts.eu/jobs/trucker/configuration/api/exports.md).

# 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 style="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.
{% endhint %}

## 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
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kojascripts.eu/jobs/trucker/configuration/api/exports.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
