# RD Camera

{% embed url="<https://www.youtube.com/watch?v=ZF_9uiG-Be4>" %}

## Step 1 - Items

Add the following to qb-core/shared/items.lua

```lua
camera                       = { name = 'camera', label = 'Camera', weight = 10, type = 'item', image = 'camera.png', unique = true, useable = true, shouldClose = true, combinable = nil, description = 'Camera' },
image                        = { name = 'image', label = 'Image', weight = 10, type = 'item', image = 'image_item.png', unique = true, useable = true, shouldClose = true, combinable = nil, description = 'Image Copy' },
```

## Step 2 - Item images

Add the images in the itemimages folder to your inventory system. For qb-inventory this would be qb-inventory/html/images

## How to use

### Take a photo

To take a photo use the camera item and press enter to take the photo.

### Use flash

To toggle flash on the camera press shift when you are in the camera view.

### Open camera photo directory

To see the images saved on a camera hold shift while you use the item. And the you can hold and drag the mouse to scroll through the images.

When you hover over an image you will see three buttons in the bottom left. Use these to print a copy of the image to your inventory, delete photo and copy a photos url.

### Printed images

You can view a printed images by using the item.

## Integration with other scripts

To use this script with any other script there are some options.

#### Option 1

By using the following client export you can open a menu with all the images save on cameras in the persons inventory. it will then call the callback you give it with one argument with is the image url.

Example

```
exports["RD_Camera"]:OpenImageSelectorWithCameraImages(function(imageURL)
    --Your code
end)
```

#### Option 2

By using the following client export you can open the same menu as above however you also give it the images you want it to use.

Example

```
exports["RD_Camera"]:OpenImageSelector(images, function(imageURL)
    --Your code
end)
```

#### Option 3

You can also use the QBCore callback called "getallimages" the get the images save on all cameras in your inventory. The QB variable below comes from exports\["qb-core"]:GetCoreObject()

Example

```lua
QB.Functions.TriggerCallback("getallimages", function(images)
    --You code
end)
```

#### Option 4

You can also use the QBCore callback called "getitemimages" the get the images saved on a specific camera in a slot of you inventory. The QB variable below comes from exports\["qb-core"]:GetCoreObject()

Example

```
QB.Functions.TriggerCallback("getitemimages", function(images)
    --Your code
end, slot)
```
