> 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/events.md).

# Events

```lua
AddEventHandler('koja-trucker:delivery:completed', function(data)
    print(('%s earned $%s'):format(data.identifier, data.money))
end)
```

{% hint style="info" %}
These fire **server-side**. The `src` field is the player's server id; depending on convoy/passenger flow it may differ from the leader — always trust `identifier` for the player.
{% endhint %}

## koja-trucker:mission:started

Fired when a player successfully starts a delivery.

```lua
{
  src,            -- server id
  identifier,     -- player identifier
  mission_id,     -- order id
  category,       -- default|urgent|dangerous|fragile|illegal|business
  required_class, -- 1|2|3
}
```

## koja-trucker:delivery:completed

Fired when a delivery is paid out (also fires for convoy passengers).

```lua
{
  src, identifier,
  money,          -- net payout
  xp,
  km,             -- route distance
  elapsed,        -- seconds taken
  category,
  from, to,       -- city names
  company_id,     -- nil if independent
  late,           -- boolean (urgent deadline missed)
}
```

## koja-trucker:company:created

```lua
{
  src, identifier,
  company_id,
  name,
  tag,            -- nil if none
}
```

## koja-trucker:skill:purchased

```lua
{
  src, identifier,
  skill_id,
  level,          -- new level
}
```

## koja-trucker:promo:redeemed

```lua
{
  src, identifier,
  code,
  kind,           -- 'money' | 'xp' | 'sp'
  multiplier,
}
```

## Example: reward streaks in another resource

```lua
local streak = {}

AddEventHandler('koja-trucker:delivery:completed', function(d)
    if d.late then streak[d.identifier] = 0; return end
    streak[d.identifier] = (streak[d.identifier] or 0) + 1
    if streak[d.identifier] == 10 then
        -- 10 on-time deliveries in a row → gift a boost
        exports['koja-trucker']:GrantPromoEffect(d.src, 'xp', 2.0, 1800)
    end
end)
```


---

# 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/events.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.
