> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jaksam-scripts.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Successful craft

> Triggered server side after a successful craft in a laboratory.

Triggered after a successful craft in a laboratory.

```lua Event theme={null}
RegisterNetEvent("drugs_creator:laboratory:successfulCraft", function(playerId, ingredientsUsed, itemsToGive, laboratoryId)

end)
```

### Parameters

| Name              | Data Type   | Description                                                                                                |
| ----------------- | ----------- | ---------------------------------------------------------------------------------------------------------- |
| `playerId`        | integer     | Player server ID                                                                                           |
| `ingredientsUsed` | table       | Table containing the ingredients used. Key = ingredient name, Value = ingredient quantity                  |
| `itemsToGive`     | table/array | An array of tables representing the items to give. Each table has `itemName` and `itemQuantity` properties |
| `laboratoryId`    | integer     | Laboratory ID                                                                                              |

## Example

```lua theme={null}
-- An example for a xp system
RegisterNetEvent("drugs_creator:laboratory:successfulCraft", function(playerId, ingredientsUsed, itemsToGive, laboratoryId)
    for k, resultItem in pairs(itemsToGive) do
        local itemName = resultItem.itemName
        local quantity = resultItem.itemQuantity

        TriggerEvent("xp_system:addXp", playerId, quantity)
    end
end)
```


## Related topics

- [Laboratories](/drugs-creator/server/laboratories/index.md)
- [Item crafted](/jobs-creator/server/crafting-table/item-crafted.md)
- [Crafting Table](/jobs-creator/server/crafting-table/index.md)
- [Crafting Recipes (Drag & Drop)](/jaksam-inventory/guides/crafting.md)
- [Open inventory](/jaksam-inventory/functions/client/open-inventory.md)
