> For the complete documentation index, see [llms.txt](https://docs.rainmad.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rainmad.com/resources/chopshop-with-welding-minigame/events-and-exports.md).

# Events & Exports

## Start a job from your own script

The job flow can be triggered externally, from an item, a phone app or a mission script:

```lua
---@param targetPlayerServerId? number  defaults to the triggering player
TriggerServerEvent('rm_chopshop:server:createJob', targetPlayerServerId, {
    ignorePoliceCount    = false,
    ignorePlayerCooldown = false,
    ignoreGlobalCooldown = false,
    ignoreLockdown       = false,
})
```

The options table is optional; every flag defaults to `false`. Server-side, `TriggerEvent` works the same way, and cancelling mirrors it:

```lua
TriggerEvent('rm_chopshop:server:cancelJob', playerId)
```

Set `cfg.disableServerEvent = true` if you want this API off entirely.

## Lockdown

```lua
exports.rm_chopshop:setLockdown(true) -- true | false | nil (nil toggles)
exports.rm_chopshop:getLockdown()
```

While lockdown is active, new jobs are refused with a notification, so you can pause the job during events or police raids.

## Server hook: parts on the rack

`rm_chopshop/server/editable_functions.lua` ships open with a commented example:

```lua
function vehiclePartAddedToRack(playerId, vehicle, partIndex, parts)
    -- fires every time a part lands on the rack
    -- parts[partIndex].item is the item that part will pay out
end
```

## Client hook: part dismantled

`rm_chopshop/client/events.lua` is an open file with a ready handler:

```lua
AddEventHandler('rm_chopshop:client:partDismantled', function(partType)
    -- 'door' | 'hood' | 'trunk' | 'wheel'
end)
```

## Discord logging

Job starts/finishes/cancels and every shop transaction route through `rm_chopshop/server/discord_log.lua`, an open file you can rewrite entirely. Logging is **off by default**: set `enabled = true` and your webhook URL in the file's config to turn it on.
