# Successful craft

Triggered after a successful craft in a laboratory

## Event

```lua
RegisterNetEvent("drugs_creator:laboratory:successfulCraft", function(playerId, ingredientsUsed, itemsToGive, laboratoryId)

end)
```

### Parameters

| Name              | Data Type   | Description                                                                                                    |
| ----------------- | ----------- | -------------------------------------------------------------------------------------------------------------- |
| `playerId`        | int         | Player server ID                                                                                               |
| `ingredientsUsed` | table       | Table containing the ingredients used. Key = ingredient name, Value = intedient quantity                       |
| `itemsToGive`     | table/array | An array containing a table of the items to give. The table will have `itemName` and `itemQuantity` properties |
| `laboratoryId`    | int         | laboratory ID                                                                                                  |

## Example

```lua
-- 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)
```


---

# Agent Instructions: 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:

```
GET https://documentation.jaksam-scripts.com/drugs-creator/server/laboratories/successful-craft.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
