# rgb (Shared)

> Packs a colour's components into a single ARGB number. It is the same function as `tocolor`.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Data and utilities
- **URL**: https://wiki.mymp.gg/en/rgb

## Syntax

```lua
int rgb(int red, int green, int blue [, int alpha = 255])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `red` | `int` | The red, from 0 to 255. |
| `green` | `int` | The green, from 0 to 255. |
| `blue` | `int` | The blue, from 0 to 255. |
| `alpha` | `int` | The opacity, from 0 to 255. *(default: `255`)* |

## Returns

The colour as a number. If an argument is not an integer, opaque black.

Values outside 0 to 255 are clamped.

## Example

```lua
local orange = rgb(255, 140, 0)
setSunColor(orange)
```

## See also

- [tocolor (Shared)](https://wiki.mymp.gg/en/tocolor.md): Packs a colour's components into a single ARGB number. It is the same function as rgb.
- [rgba (Shared)](https://wiki.mymp.gg/en/rgba.md): Packs a colour's components into a single ARGB number, with the opacity from 0 to 1.
