> For the complete documentation index, see [llms.txt](https://mango-5m.gitbook.io/mango5m-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mango-5m.gitbook.io/mango5m-docs/resources/mango-achievements/developer-guide/example-integrations.md).

# Example Integrations

Copy-paste snippets for prison, EMS, jobs and garages.

## Prison

```lua
-- once the player is actually inside
exports['mango_achievements']:AddStat(source, 'prison_sentences', 1)

-- released having served the full sentence
exports['mango_achievements']:AddStat(source, 'sentence_completed', 1)

-- got out the other way
exports['mango_achievements']:AddStat(source, 'prison_escapes', 1)
```

One call advances *Not Again*, *Hardened* and *Repeat Offender* together.

## Ambulance

```lua
RegisterNetEvent('hospital:server:RevivePlayer', function(targetId)
    local medic = source
    exports['mango_achievements']:AddStat(medic, 'revives', 1)

    if downedSince[targetId] and os.time() - downedSince[targetId] > 300 then
        exports['mango_achievements']:AddStat(medic, 'late_revive', 1)
    end
end)
```

## Jobs

```lua
local function onTaskComplete(src)
    exports['mango_achievements']:AddStat(src, 'job_tasks', 1)
end
```

## Garages and dealerships

`vehicles_owned` is an absolute count read from your vehicle table, so recount after a purchase or sale rather than incrementing:

```lua
RegisterNetEvent('dealership:server:buyVehicle', function(...)
    -- insert the row first, then:
    exports['mango_achievements']:RefreshVehicleCount(source)
end)
```

*Behind the Wheel* and *Collector* both update immediately.

## A one-off secret

```lua
if atTheRightPlace then
    exports['mango_achievements']:UnlockAchievement(source, 'kifflom')
end
```

{% hint style="success" %}
Most of these already work without any code, through [Integrations](/mango5m-docs/resources/mango-achievements/configuration/integrations.md) — these snippets are for anything your resources do that no standard event covers.
{% endhint %}
